Splunk Search

Is splunk counting key/value in referer too?

mplungjan
Path Finder

Assuming I have an access log file with referer

If I have

111.111.111.111 - - [.......] "GET /cart.do?action=checkout&productId=prod1" "//..../searchresult"
111.111.111.111 - - [.......] "GET /cart.do?action=purchase&productId=prod2" "//..../cart.do?action=checkout&productId=prod1"

If I count productId will I get 2 and prod1 counted twice?

If I count action=checkout, do I get 2?

Can I make my search ignore the referer completely?

Tags (1)
0 Karma
1 Solution

alacercogitatus
SplunkTrust
SplunkTrust

Yes it is probably counting. The fastest way might be to rex it.

your_search | rex field=uri "action=(?<count_action>[^&]*)&productId=(?<count_product>\w+)" | stats count by count_action, count_product

A more complicated example would do it automatically in props/transforms.

props.conf
[access_combined]
EXTRACT-action = action=(?<count_action>[^&]*) in uri
EXTRACT-product = productId=(?<count_product>[^&]*) in uri

http://docs.splunk.com/Documentation/Splunk/latest/admin/propsconf

View solution in original post

0 Karma

alacercogitatus
SplunkTrust
SplunkTrust

Yes it is probably counting. The fastest way might be to rex it.

your_search | rex field=uri "action=(?<count_action>[^&]*)&productId=(?<count_product>\w+)" | stats count by count_action, count_product

A more complicated example would do it automatically in props/transforms.

props.conf
[access_combined]
EXTRACT-action = action=(?<count_action>[^&]*) in uri
EXTRACT-product = productId=(?<count_product>[^&]*) in uri

http://docs.splunk.com/Documentation/Splunk/latest/admin/propsconf

0 Karma

alacercogitatus
SplunkTrust
SplunkTrust

Yeah that might backfire because if it find action=purchase in the referer, it would grab it. I'd have to test and see, but I don't think we are setup with that structure.

0 Karma

mplungjan
Path Finder

If I didn't I could imagine this would give false information sourcetype=access_*
|
transaction
clientip
startswith=eval(action="addtocart")
endswith=eval(action="purchase")

0 Karma

mplungjan
Path Finder

Thanks a lot. I think Splunk needs to mention that in the course materials

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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...