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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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