Splunk Search

How to remove value in event field?

lehoang47tin
Engager

Hi, I have processes logs like this:
event1:

{"snapshot":[{"name":"systemd"},{"name":"gvfsd-trash"},{"name":"gvfsd-metadata"},{"name":"qterminal"},{"name":"bash"},{"name":"systemd-journal"},{"name":"systemd-udevd"},],"action":"snapshot"}

event2:

{"snapshot":[{"name":"systemd"},{"name":"gvfsd-trash"},{"name":"bash"},{"name":"systemd-journal"},{"name":"systemd-udevd"},],"action":"snapshot"}

How do I stats all of name except "systemd*" processes? Output is:

"gvfsd-trash", "gvfsd-metadata","qterminal", "bash"

Thanks.

0 Karma

jadengoho
Builder

You can do Search Command

| makeresults 
    | eval value="{\"snapshot\":[{\"name\":\"systemd\"},{\"name\":\"gvfsd-trash\"},{\"name\":\"gvfsd-metadata\"},{\"name\":\"qterminal\"},{\"name\":\"bash\"},{\"name\":\"systemd-journal\"},{\"name\":\"systemd-udevd\"},],\"action\":\"snapshot\"}
    {\"snapshot\":[{\"name\":\"systemd\"},{\"name\":\"gvfsd-trash\"},{\"name\":\"bash\"},{\"name\":\"systemd-journal\"},{\"name\":\"systemd-udevd\"},],\"action\":\"snapshot\"}" 
    | rex field=value "name\"\:\"(?<Name>[^\"]+)" max_match=20 
    | table Name 
    | mvexpand Name 
    | stats count by Name 

OR Dont include it using regex

| makeresults 
| eval value="{\"snapshot\":[{\"name\":\"systemd\"},{\"name\":\"gvfsd-trash\"},{\"name\":\"gvfsd-metadata\"},{\"name\":\"qterminal\"},{\"name\":\"bash\"},{\"name\":\"systemd-journal\"},{\"name\":\"systemd-udevd\"},],\"action\":\"snapshot\"}
{\"snapshot\":[{\"name\":\"systemd\"},{\"name\":\"gvfsd-trash\"},{\"name\":\"bash\"},{\"name\":\"systemd-journal\"},{\"name\":\"systemd-udevd\"},],\"action\":\"snapshot\"}" 
| rex field=value "name\"\:\"(systemd\")*(?<Name>[\w\-]*)" max_match=20 
| table Name 
| mvexpand Name 
| stats count by Name
0 Karma
Get Updates on the Splunk Community!

Splunk App for Anomaly Detection End of Life Announcment

Q: What is happening to the Splunk App for Anomaly Detection?A: Splunk is officially announcing the ...

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...