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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...