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!

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...

September Community Champions: A Shoutout to Our Contributors!

As we close the books on another fantastic month, we want to take a moment to celebrate the people who are the ...

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...