splunk - 如果今天的日志量比过去三天每项服务的平均值高 10%,则 Splunk 发出警报
问题描述
我想创建一个警报,当今天的日志数量比过去三天每个服务的平均值多 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
而且我无法计算阈值,因为我不知道如何为每个服务引用此字段
解决方案
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, 行 | 其中 current_count>x AND ChangePercent>10 AND row=2
请使用上述查询并更改当前计数,您将获得所需的结果。
推荐阅读
- usb - 适用于 Kinect azure 的 USB-C 转 USB-C 电缆
- php - 如何修复我的文本“?” 当我用 str_split() 打印时
- mysql - 如何在不重复的情况下获取查询中的最新日期?
- php - 如何查找和删除数组中的重复值?
- python - 当信号到达时,python中的线程是否继续执行?
- vba - 如何访问 Word 文档中的特定表格
- perl - perl DBIx::Class 对表上的所有搜索都有一个默认过滤器
- android - 如何摆脱 Android 中的“服务未注册:android.speech.SpeechRecognizer”错误
- r - 如何向具有未知时区的日期时间数据框添加时间
- hive - Hive 没有为“插入覆盖”查询创建减速器。小文件问题?