如何将不同搜索的计数累积到一个(饼图)图表中?

How to accumulate counts from different searches into one (pie) chart?

我在 Splunk 中进行了 5 次不同的搜索,我正在计算该搜索查询的结果数量。

我在这里看过这个帖子:

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

但它不太适合我,我不能 100% 确定它是否是我想要的。

我的搜索查询都是这样的:

index=变量="foo" 消息="Created*" |统计数据

index=一个变量="foo" message="Deleted*" |统计数据

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

以下应该足够了。

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