Splunk Enterprise Security

Regex for CEF

pavanbmishra
Path Finder

Hi SMEs,

 

I am trying to write regex to parse/map CEF format fields as below. so that all corresponding fieldname can capture values, i am not able to capture values having spaces in between. Seeking suggestion. Attached snap shot for ref.

regex101regex101

c[n|s]\dlabel\=(\w+).*?c[n|s]\d\=([\.a-zA-Z0-9_-]+)

 

CEF:0|vendor|product|1.1|1234|PolicyAssetUpdated|1|cn1label=EventUserId cn1=-3 cs1label=EventUserDisplayName cs1=Automated System cs2label=EventUserDomainName cs2= cn2label=AssetId cn2=20888 cs3label=AssetName cs3=ABCDPQRS.domain.com cn3label=DirectoryId cn3=856 cs4label=DirectoryName cs4=Active Directory cs5label=DomainName cs5=domain.com

Labels (1)
Tags (2)
0 Karma

pavanbmishra
Path Finder

Thanks johnhua,

Could you please suggest me how this can be called out in props.conf & transforms.conf please

0 Karma

johnhuang
Motivator

Bunch of different ways. Here's one:

| makeresults
| eval _raw="CEF:0|vendor|product|1.1|1234|PolicyAssetUpdated|1|cn1label=EventUserId cn1=-3 cs1label=EventUserDisplayName cs1=Automated System cs2label=EventUserDomainName cs2= cn2label=AssetId cn2=20888 cs3label=AssetName cs3=ABCDPQRS.domain.com cn3label=DirectoryId cn3=856 cs4label=DirectoryName cs4=Active Directory cs5label=DomainName cs5=domain.com"
| rex field=_raw "^.*?\|(?<_raw>cn1label.*)"
| rex field=_raw mode=sed "s/\s?c[n|s]\d+label\=/;/g"
| rex field=_raw mode=sed "s/\s?c[n|s]\d+\=/:/g"
| extract pairdelim=";",kvdelim=":"
| table AssetId AssetName DirectoryId DirectoryName DomainName EventUserId EventUserDisplayName EventUserDomainName

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