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!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...