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!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

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 ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...