如何将来自不同搜索的计数累加到一张(饼图)中?

问题描述 投票:0回答:1

我在Splunk中进行了5种不同的搜索,我从该搜索查询中获得了多少结果的计数。

我在这里看过这个线程:

https://answers.splunk.com/answers/757081/pie-chart-with-count-from-different-search-criteri.html

但是它对我来说不是很有效,我不能100%确定它是否是我想要的。

我的搜索查询都看起来像这样:

index = A变量=“ foo”消息=“已创建*” |统计数

index = A变量=“ foo”消息=“已删除*” |统计数

理想情况下,我想将每个查询分配给一个关键字-例如创建,删除等,然后根据计数创建饼图。

splunk splunk-query
1个回答
1
投票

以下内容就足够了。

index=A variable="foo" message="Created*" OR message="Deleted*" OR message="<repeat this for any other message types you want>" | stats count by message

如果您可以提供其他一些要绘制的事件的示例,则可能有其他方法可以为您服务。

此版本将消息的关键部分(已创建,已删除等)提取到名为mtype的字段中,然后您可以对该字段执行stats

index=A variable="foo" message="Created*" OR message="Deleted*" OR message="<repeat this for any other message types you want>" | rex field=message "(?<mtype>Created|Deleteted|...)" | stats count by mtype
© www.soinside.com 2019 - 2024. All rights reserved.