Splunk Enterprise Security

API AWS query question

havatz
Explorer

Hi

This is my API AWS query:

"search index=aws userIdentity.type=Root eventName=ConsoleLogin earliest=-10d  | rex field=_raw MFAUsed\D\D\s\D(?P<Mfa>\D?\S) | rex field=_raw principalId\D:\s\D(?P<principalId>\d*)" | stats count by principalId"

its working and im getting results.

Now I need your help with add the field that I parse (Mfa)

and to add Mfa="No" to the query

but its not showing resutls.

I tried to do something like that:

"search index="aws" (userIdentity.type="Root" eventName="ConsoleLogin" Mfa="No*" earliest=-10d | rex field=_raw MFAUsed\D\D\s\D(?P<Mfa>\D?\S) | rex field=_raw principalId\D:\s\D(?P<principalId>\d*)"

What Im missing?

Thanks!

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Mfa hasn't been extracted until after the rex (that extracts it), so try something like:

"search index="aws" (userIdentity.type="Root" eventName="ConsoleLogin" earliest=-10d | rex field=_raw MFAUsed\D\D\s\D(?P<Mfa>\D?\S) | where Mfa="No*" | rex field=_raw principalId\D:\s\D(?P<principalId>\d*)"

 

0 Karma

havatz
Explorer

"search index="aws" userIdentity.type="Root" eventName="ConsoleLogin" earliest=-10d | rex field=_raw MFAUsed\D\D\s\D(?P<Mfa>\D?\S) | where Mfa="No*" | rex field=_raw principalId\D:\s\D(?P<principalId>\d*) | stats count by principalId"

Got this error:

"messages": [
{
"type": "FATAL",
"text": "Error in 'where' command: The expression is malformed. The factor is missing."

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You possibly need to add in escaping of the double-quotes(?)

"search index=\"aws\" userIdentity.type=\"Root\" eventName=\"ConsoleLogin\" earliest=-10d | rex field=_raw MFAUsed\D\D\s\D(?P<Mfa>\D?\S) | where Mfa=\"No*\" | rex field=_raw principalId\D:\s\D(?P<principalId>\d*) | stats count by principalId"

 

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

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...