Getting Data In

How to create regex for multiple lines of a field value?

RahulMisra
Engager

I want to extract numeric values into seperate field

"combinedrules": ["3000039", "3000081", "958052", "973335", "XSS-ANOMALY"]

 

Expected Output:

Ruleid

3000039

3000081

958052

 

Three might be a case when there could be 2 rules Id in one event and i wan to see both gets displayed in a  single line

Labels (1)
Tags (2)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

It's not about a regex as such. It's about the whole props construction.

You have two options.

1. Use one transform to parse out the set of rules contained within brackets and then use another transform with SOURCE_KEY set to your extracted field and MV_ADD=true to further split it up into single values.

or

2. Parse out the whole set within brackets and then define TOKENIZER in fields.conf

The latter approach works with such lists while the first is a bit more generic.

0 Karma

RahulMisra
Engager

So, we can;t make a regex on search to fetch the fields values ?

0 Karma

RahulMisra
Engager

{"type": "testlog", "configId": "22269", "policyId": "FIST_52163", "anomali": "34.87.65.2", "combinedrules": ["3000039", "3000081", "958052", "973335", "XSS-ANOMALY"], "ruleMessages": ["Cross-site Scripting (XSS) Attack", "Cross-site Scripting (XSS) Attack", "Cross-site Scripting (XSS) Attack", "Cross-site Scripting (XSS) Attack", "Anomaly Score Exceeded for Cross-site Scripting (XSS) Attack"], "ruleTags": ["ASE/WEB_ATTACK/XSS", "ASE/WEB_ATTACK/XSS", "ASE/WEB_ATTACK/XSS", "ASE/WEB_ATTACK/XSS", "ASE/WEB_ATTACK/XSS"], "ruleData": ["document.domain", ")alert(", "alert(", "')alert(document.domain)", "Vector Score: 17, Group Threshold: 7, Triggered Rules: 3000081-958052-3000039-973335, Triggered Scores: 5-5-5-2, Triggered Selector: ARGS:errorCode, Mitigated Rules: , Last Matched Message: "], "ruleActions": ["alert", "alert", "alert", "alert", "deny"], "requestId": "2ed42ca7", "method": "GET", "Host": "test.goodies.com", "path": "/carbon/admin/login.jsp", "User-Agent": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1866.237 Safari/537.36", "status": "403", "Server": "AkamaiGHost", "Date": "Fri, 25 Aug 2023 09:10:04 GMT"}

0 Karma

Thulasinathan_M
Contributor

Something like this?

| rex field=_raw "combinedrules\: \[(?<Rules>(.*[^(\]\,)?]))"
| rex field=Rules max_match=0 "(?<RuleId>(\d+))"
| stats count by RuleId
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @RahulMisra ,

could you share a sample of your full logs, not only a part of them?

Ciao.

Giuseppe

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...