Splunk Search

How to extract IDs?

beepbop
Explorer

I have a field called APM_ID and i want to get the output for only APMs from this field (for eg: A1002, A0001) and want to group the rest of the output as "shared service". What query can i write for the desired output?

APM_ID
ABCDE-FVG-HH
HBBB-NDBXB-SM
A1001
SBSKS
A0002
JJSKM

A0009

A2002
Labels (4)
0 Karma

woodcock
Esteemed Legend

|makeresults
| eval APM_ID = "ABCDE-FVG-HH HBBB-NDBXB-SM A1001 SBSKS A0002 JJSKM"
| rex max_match=0 field=APM_ID "(?<APM>A\d{4})"

rut
Path Finder

@beepbop  The following would group by id or "shared service", the regex may need to be a bit more strict depending on the field values.

 

| eval APM_ID_GROUP=if(match(APM_ID, "^[A-Z]\d+$"), APM_ID, "shared service")
| stats values(APM_ID) as APM_ID by APM_ID_GROUP

 

 

Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...