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!

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had 3 releases of new security content via the Enterprise Security ...

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...