我在多台计算机上生成列出未运行的服务名称的事件。我想制作一个图表来显示最有问题的服务名称。
我可以使用以下内容获取仪表板的表格:
ComputerName="*.ourDomain.com" sourcetype="WinEventLog:Application" EventCode=7223 SourceName="internalSystem"
| eval Date_Time=strftime(_time, "%Y-%m-%d %H:%M")
| table host, Date_Time, Message, EventCode
典型消息将包含:
The following services were not running after 5603 seconds and a start command has been sent:
Service1
Service2
The following services were not running after 985 seconds and a start command has been sent:
Service2
Service3
使用正则表达式,我可以创建一个命名组,但第一行除外。(?<Services>((?<=\n)).*)
但是,我认为这不是正确的方法,因为我不知道如何使用这些信息对图表进行估值。
所以本质上,我如何从 Splunk 中的消息中获取和统计服务名称?
编辑1:几天后回到这个。我使用正则表达式创建了一个名为“服务”的字段提取,它在第一行之后抓取每条消息的内容。如果我使用| stats count BY Services
它将每条消息作为一个整体而不是里面的行来计数。结果如下所示:
Service1 Service2 | Count: 1
Service2 Service3 | Count: 1
我的意图是让它将每一行视为自己的值,因此结果如下所示:
Service1 | Count: 1
Service2 | Count: 2
Service3 | Count: 1
我试过| mvexpand Services
了,但它并没有改变输出,所以我认为我要么使用不当,要么在这里不适用。