Splunk Search

Extract field with multiple potential formats

yk010123
Path Finder

I have log entries that have the following format :

[<connectorName>|<scope>]<sp>

The following are examples of the connector context for a connector named "my-connector":

  • [my-connector|worker]
  • [other-connector|task-0]
  • [my-connector|task-0|offsets]

I would like to extract the name of the connectors and build stats. The tasks or other metadata are not needed. For example :

ConnectorCount
my-connector2
other-connector2

 

As the entries have different formats, how can I do this?

Labels (1)
0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @yk010123,

You use below;

| rex field=_raw "\[(?<connector>[^\|]+)"
| stats count by connector
If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...