Splunk Search

Splunk query help - query for URL that have values other than X,Y,Z

Splunkanator
New Member

Lets say i would like to query for message that has a URL field with values other than X,Y,Z added as query parameters , how do i go about this ?

TIA

Labels (2)
0 Karma

tscroggins
Influencer

Hi @Splunkanator,

If your events have an extracted uri_query field, which is typical for e.g. NCSA and W3C log formats, you can use != or NOT to exclude events:

index=main sourcetype=access_common uri_query!=*param=X* uri_query!=*param=Y* uri_query!=*param=Z*

or

index=main sourcetype=access_common NOT uri_query IN (*param=X* *param=Y* *param=Z*)

However, those will exclude events with partially matching names or values.

Performance will vary, but you can use the regex command to match events with fields that do no match a regular expression:

index=main sourcetype=access_common
| regex uri_query!="(^|&)param=(X|Y|Z)(&|$)"

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@Splunkanator 

Can you please share some sample events and expected output?

KV

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...