Splunk Search

Regex expression

hashsplunk
Loves-to-Learn Lots

prd-sso-data-science-711-3006-compute-role

dev-1000-535-aibench-mlops-service-compute-role

 

above are the field values . I need to extract the code 711-3006 & 1000-535

I have given the regular expression  |rex field="Role" ".*(?<Projectcode>\d{3,4}-\d+)" but its not fetching the code properly . It give 000-535 in the second value. Kindly help

Labels (1)
0 Karma

manjunathmeti
Champion

Try this:

| rex field=Role "\w+-(?<Projectcode>\d{3,4}-\d+)-\w+"

 

If this reply helps you, an upvote/like would be appreciated.

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...