Splunk Search

Splunk query to build a table with total event count, sub event count and sub event in percent

cbiraris
Path Finder

Hi Team,
i am trying to design a query which show be result like total event count, sub event count and sub event in percent. can you please help with query

For example below table :
Work_Month_week | total_week_day|work day of week| Number of work hours | percent work hours
1                                      |  3                               | Mon                          | 2                                            |     %                                                                                                                              |Tus                             | 4                                            |     % 
                                                                              |Tus                             | 4                                            |     % 
2                                      |  2                               | Mon                          | 2                                            |     %                                                                                                                              |Tus                             | 4                                            |     % 
3                                      |  3                               | Mon                          | 3                                            |     %                                                                                                                              |Tus                             |  5                                           |     % 
                                                                              |thu                             | 4                                            |     % 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

It is usually easier for us to help you when you shows us what events you are working with, but in lieu of that, assuming you have events with the following fields: Work_Month_week, "work day of week", "Number of work hours", you could try something like this

| table Work_Month_week, "work day of week", "Number of work hours"
| eventstats count as total_week_day sum("Number of work hours") as Week_total by Work_Month_week
| eval "percent work hours"=100*'Number of work hours'/Week_total

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

It is usually easier for us to help you when you shows us what events you are working with, but in lieu of that, assuming you have events with the following fields: Work_Month_week, "work day of week", "Number of work hours", you could try something like this

| table Work_Month_week, "work day of week", "Number of work hours"
| eventstats count as total_week_day sum("Number of work hours") as Week_total by Work_Month_week
| eval "percent work hours"=100*'Number of work hours'/Week_total

yuanliu
SplunkTrust
SplunkTrust

First things first.  What is a "sub event"?  How do you get "subevent"?  How do you count "subevent"?  Secondly, please construct your desired output like a real table (e.g., by using the table template above, craft HTML table, or some means suitable for you).  The illustration you give is not even aligned and impossible to interpret.

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!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...