Splunk Search

Could somebody assist with this query?

kelvinJE
Engager

Hi All

We're importing our WAF logs into Splunk, and I'd like to create a table to shows where traffic is originating, and how its being actioned. This can be generated from 2 fields -

Country - List of Countries
Action - What action was taken

The issue is, I want to use Action to generate the dynamic columns, and add a couple of additional data points, such as:

Country     Blocked     Allowed    Held          Total Requests     % Blocked
UK               10     80         10            100                10% 
IRE
IT

I managed to get a table based upon country and action using

 | chart count over country by action

and

 | chart count over action by country

But using this method, I don't think its possible to add the Totals Requests or the % blocked.

Tags (1)
0 Karma

adonio
Ultra Champion

hello there,

maybe try something like this:

... | stats count as "Total" count(eval(action=="Allowed")) as Allowed count(eval(action=="Blocked")) as Blocked count(eval(action=="Held")) as Held by Country
| eval perc_blocked = round(Blocked/Total*100, 2)

hope it helps

0 Karma

elliotproebstel
Champion

Try this:

| chart count over country by action 
| addtotals fieldname="Total Requests"   
| eval "% Blocked"=tostring(round((blocked/'Total Requests'*100), 2))."%"
0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...