Splunk Search

how to use table with percentage?

pacifikn
Communicator

Hi ALL!!

Help me on how I can use the table function in query with percent

|table  field-1, field-2, field-3  |stats count by  field-1, field-2, field-3

| eval  percentage=round(count/total*100,2)."%" |fields - total 

This is the query I used but there's no percentage columns appeared, what query can I use to displ

Kindly help me out????

here's the column i want to have:

host       signature   action    count     percentage   

I need your help?

 

- Other Question , what makes the query to take long time loading or more time to display after pressing search button?

Thanking you in advance.

 

 

 

 

 

Labels (3)
Tags (1)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

Slow queries are generally due to

  • too much data
  • poor hardware
  • too long a time search window
  • badly written queries

In your query, you are searching all indexes - what is your time range and how much data are you dealing with.

 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

You do not need to use table if you are following this with an aggregation, like stats.

You don't have a total calculated anywhere, so cannot do the eval you are trying to do

index=* action=*  
| stats count by  host, signature, action
| eventstats sum(count) as total
| eval percentage=round(count/total*100,2)."%" 
| fields - total 

The eventstats will then sum all the counts to get the total and you can then do your percentage calculation afterwards

 

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!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...