Splunk Search

Why is my search not showing the count in the resulting table?

dbcase
Motivator

Hi,

I have this query

index=cox UCE-|rex "UCE-(?<UCE_Code>(\d+))"|lookup UCECodes.csv UCE-Code as UCE_Code|eval ud=UCE_Code+" - "+Desc|eventstats count as grandtotal |eventstats count as ptotal by UCE_Code|eval aatype=if(match(source,"managedServer"),"managed","access")|chart values(Desc) as Description  count(UCE_Code) as "UCE Code Count" count(aatype="managed") as "Managed Server Log" count(aatype="access") as "Access Log" values(eval(round(ptotal/grandtotal*100,2))) as Percentage by UCE_Code |rename UCE_Code as "UCE Code - Click for Detail"|sort - "Percentage"|rename ud as "UCE Code - Description"

And I'm interested in the aatype field. When the query runs, the resulting table has everything correct, EXCEPT the columns "Managed Server Log" and "Access Log" are all zeros. However, when I view the event fields, the aatype field shows the correct values.

What am I missing?

Here is the statistics table and event fieldalt text

0 Karma
1 Solution

alemarzu
Motivator

Hi there @dbcase

Try like this,

index=cox UCE- 
| rex "UCE-(?<UCE_Code>(\d+))" 
| lookup UCECodes.csv UCE-Code AS UCE_Code 
| eval ud=UCE_Code+" - "+Desc 
| eventstats count AS grandtotal 
| eventstats count AS ptotal by UCE_Code 
| eval aatype=if(match(source,"managedServer"), "managed", "access") 
| chart values(Desc) AS Description, count(UCE_Code) AS "UCE Code Count", count(eval(aatype="managed")) AS "Managed Server Log", count(eval(aatype="access")) AS "Access Log", values(eval(round(ptotal/grandtotal*100,2))) AS Percentage by UCE_Code 
| rename UCE_Code AS "UCE Code - Click for Detail" 
| sort - "Percentage"
| rename ud AS "UCE Code - Description"

Let me know if it works.

View solution in original post

0 Karma

alemarzu
Motivator

Hi there @dbcase

Try like this,

index=cox UCE- 
| rex "UCE-(?<UCE_Code>(\d+))" 
| lookup UCECodes.csv UCE-Code AS UCE_Code 
| eval ud=UCE_Code+" - "+Desc 
| eventstats count AS grandtotal 
| eventstats count AS ptotal by UCE_Code 
| eval aatype=if(match(source,"managedServer"), "managed", "access") 
| chart values(Desc) AS Description, count(UCE_Code) AS "UCE Code Count", count(eval(aatype="managed")) AS "Managed Server Log", count(eval(aatype="access")) AS "Access Log", values(eval(round(ptotal/grandtotal*100,2))) AS Percentage by UCE_Code 
| rename UCE_Code AS "UCE Code - Click for Detail" 
| sort - "Percentage"
| rename ud AS "UCE Code - Description"

Let me know if it works.

0 Karma

dbcase
Motivator

Hey alemarzu! That worked perfectly!!! Many thanks!

0 Karma

alemarzu
Motivator

Nice, I'm glad it helped!

0 Karma
Get Updates on the Splunk Community!

What the End of Support for Splunk Add-on Builder Means for You

Hello Splunk Community! We want to share an important update regarding the future of the Splunk Add-on Builder ...

Solve, Learn, Repeat: New Puzzle Channel Now Live

Welcome to the Splunk Puzzle PlaygroundIf you are anything like me, you love to solve problems, and what ...

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...