【问题标题】:Splunk alert if amount of logs for today 10% grater than average for the past three days per service如果今天的日志量比过去三天每项服务的平均数高 10%,Splunk 会发出警报
【发布时间】:2019-11-25 15:17:00
【问题描述】:

我想创建一个警报,当今天的日志数量比过去三天每项服务的平均值多 10% 时触发。

对于一个特定的服务,我可以使用下一个

index="some-index" AND "ctx.endpointname"="service-name" earliest=-3d@d |
timechart span=1d count |
timewrap d series=short |
eval threshold=(((s1+s2+s3)/3)+(((s1+s2+s3)/3)*0.1))'

但是当我添加by ctx.endpointname

index="some-index" AND "ctx.endpointname"=* earliest=-3d@d |
timechart span=1d count by ctx.endpointname|
timewrap d series=short |
eval threshold=(((s1+s2+s3)/3)+(((s1+s2+s3)/3)*0.1))'

结果字段名称:

service-name_s0
service-name_s1
service-name_s2
service-name_s3

我无法计算阈值,因为我不知道如何为每个服务引用此字段

【问题讨论】:

    标签: splunk splunk-query


    【解决方案1】:

    index="some-index" AND "ctx.endpointname"="service-name" 最早=-3d@d 最新=@d |添加信息 | eval orig_time = strftime(_time, "%H:%M:%S")|评估 min_time = info_min_time |桶跨度=1440m info_min_time |评估偏移量 = min_time - info_min_time | eval _time=_time-offset|铲斗跨度=1440m _time | eval _time=_time+offset | eval min_time = strftime(min_time, "%H:%M:%S") | eval info_min_time = strftime(info_min_time, "%H:%M:%S")|桶_时间跨度=1440m |统计数据按 _time| 计为 current_count|自动回归 current_count 作为 previous_count | eval total_count=(current_count+previous_count)|streamstats 计为行|评估更改=(当前计数-先前计数)| eval ChangePercent=(change/total_count)*100 |fields _time, current_count, previous_count, change, ChangePercent,row |其中 current_count>x AND ChangePercent>10 AND row=2

    请使用上述查询并更改当前计数,您将获得所需的结果。

    【讨论】:

    • 谢谢。有用 :-)。但对我来说主要问题是对所有服务都做同样的事情。当“ctx.endpointname”=*.我已经更改了正文中的代码。 service-1-current, service-1-previous, service-1-change ... service-x-current...
    猜你喜欢
    • 2019-06-18
    • 1970-01-01
    • 2022-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-27
    • 2016-08-26
    • 2016-11-30
    相关资源
    最近更新 更多