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!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...