在 Splunk 中划分两个时间表
Divide two timecharts in Splunk
我想分两张时间图(最好看起来也像时间图,但其他强调趋势的东西也不错)。
我有两种类型的 URL,我可以像这样为它们生成时间表:
index=my-index sourcetype=access | regex _raw="GET\s/x/\w+" | timechart count
index=my-index sourcetype=access | regex _raw="/x/\w+/.*/\d+.*\s+HTTP" | timechart count
目的是强调第二类URL的相对数量在增加,第一类URL的相对数量在减少。
这就是为什么我要将它们分开(最好是第二个除以第一个)。
例如,如果第一个系列生成 2, 4, 8, 4
,第二个系列生成 4, 9, 20, 12
,我希望只有一个仪表板以某种方式显示结果 2, 2.25, 2.5, 3
。
我只是通过这样做设法收集了这些信息,但没有生成时间表也没有划分它们:
index=my-index sourcetype=access
| eval type = if(match(_raw, "GET\s/x/\w+"), "new", if(match(_raw, "/x/\w+/.*/\d+.*\s+HTTP"), "old", "other"))
| table type
| search type != "other"
| stats count as "Calls" by type
我也尝试了一些使用 eval
的方法,但其中 none 有效。
试试这个查询:
index=my-index sourcetype=access
| eval type = if(match(_raw, "GET\s/x/\w+"), "new", if(match(_raw, "/x/\w+/.*/\d+.*\s+HTTP"), "old", "other"))
| fields type
| search type != "other"
| timechart count(eval(type="new")) as "New", count(eval(type="old")) as "Old"
| eval Div=if(Old=0, 0, Old/New)
我想分两张时间图(最好看起来也像时间图,但其他强调趋势的东西也不错)。
我有两种类型的 URL,我可以像这样为它们生成时间表:
index=my-index sourcetype=access | regex _raw="GET\s/x/\w+" | timechart count
index=my-index sourcetype=access | regex _raw="/x/\w+/.*/\d+.*\s+HTTP" | timechart count
目的是强调第二类URL的相对数量在增加,第一类URL的相对数量在减少。
这就是为什么我要将它们分开(最好是第二个除以第一个)。
例如,如果第一个系列生成 2, 4, 8, 4
,第二个系列生成 4, 9, 20, 12
,我希望只有一个仪表板以某种方式显示结果 2, 2.25, 2.5, 3
。
我只是通过这样做设法收集了这些信息,但没有生成时间表也没有划分它们:
index=my-index sourcetype=access
| eval type = if(match(_raw, "GET\s/x/\w+"), "new", if(match(_raw, "/x/\w+/.*/\d+.*\s+HTTP"), "old", "other"))
| table type
| search type != "other"
| stats count as "Calls" by type
我也尝试了一些使用 eval
的方法,但其中 none 有效。
试试这个查询:
index=my-index sourcetype=access
| eval type = if(match(_raw, "GET\s/x/\w+"), "new", if(match(_raw, "/x/\w+/.*/\d+.*\s+HTTP"), "old", "other"))
| fields type
| search type != "other"
| timechart count(eval(type="new")) as "New", count(eval(type="old")) as "Old"
| eval Div=if(Old=0, 0, Old/New)