Splunk Search

Merge results of multiple queries

twh1
Communicator

I have used the multiple queries and merged them in single output. When I using timechart, getting the expected result but when using bar chart we are not getting first query result as bar. Instead of bar it's showing the x-axis value.

Below is sample type of my query.

index=index1 | stats count as Field1 | appendcols [ search index=index2 | stats count as Field2] | appendcols [ search index=index3 | stats count as Field3] | appendcols [ search index=index4 | stats count as Field4] | appendcols [ search index=index5 | stats count as Field5]

We are getting write value in statistics tab, but in visualization tab after selecting bar chart, I am not getting field1.

0 Karma
1 Solution

niketn
Legend

@ twh1.... Pipe transpose and see if it helps (your five queries clubbed together does not have row names for Index and Count.

| transpose column_name=count

Check out following Splunk documentation example to tackle the scenario you are facing.
https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transpose#3._Transpose_a_set_of_...

However, if you are just counting total events in your indexes you should use dbinspect, tstats, metadata or eventcount command which have been specifically designed for this task (following command using eventcount will give you all eventcount for all indexes including Splunk's internal index, you can mention your index1 thru index5 using OR in the example below or with a wildcard pattern if possible):

| eventcount summarize=false index=* OR index=_*
| table index count
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

@ twh1.... Pipe transpose and see if it helps (your five queries clubbed together does not have row names for Index and Count.

| transpose column_name=count

Check out following Splunk documentation example to tackle the scenario you are facing.
https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transpose#3._Transpose_a_set_of_...

However, if you are just counting total events in your indexes you should use dbinspect, tstats, metadata or eventcount command which have been specifically designed for this task (following command using eventcount will give you all eventcount for all indexes including Splunk's internal index, you can mention your index1 thru index5 using OR in the example below or with a wildcard pattern if possible):

| eventcount summarize=false index=* OR index=_*
| table index count
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...