Splunk Search

How to display rows in query to cols?

jaj
Path Finder

i have the following query that query's for a value data for a given label data pair. The query runs fine but it adds the value as rows.

source=… labelData!="" AND ("labelDataValue= " OR  labelDataValue!="")  
| eval label=if(isnull(labelDataValue),"no-value","value-present")  
| stats count by label

output:

label                  count
--------------------
no-value           100
value-present    500

I'd like to get to this output so that I can eventually roll this query into a daily volume chart so that I can use a stacked chart displaying "no-value" and "value-present" on top of eachother.....so I would need output like this?

time                                     no-value     value-present
------------------------------------------------
2/11/14 6:00:00.000 PM    100              500    
2/12/14 6:00:00.000 PM    105              510

. . .

Tags (4)
0 Karma
1 Solution

HiroshiSatoh
Champion

Is this good? Please change "_time".

source=… labelData!="" AND ("labelDataValue= " OR  labelDataValue!="")  
| eval label=if(isnull(labelDataValue),"no-value","value-present")  
| stats count(eval(label="no-value")) as "no-value",count(eval(label="value-present")) as "value-present" by _time

View solution in original post

HiroshiSatoh
Champion

Is this good? Please change "_time".

source=… labelData!="" AND ("labelDataValue= " OR  labelDataValue!="")  
| eval label=if(isnull(labelDataValue),"no-value","value-present")  
| stats count(eval(label="no-value")) as "no-value",count(eval(label="value-present")) as "value-present" by _time

HiroshiSatoh
Champion

It is an example of using the _time.

source=… labelData!="" AND ("labelDataValue= " OR labelDataValue!="")

| eval label=if(isnull(labelDataValue),"no-value","value-present")

| timechart span=d count(eval(label="no-value")) as "no-value",count(eval(label="value-present")) as "value-present"

0 Karma

jaj
Path Finder

thanks...this works beautifully! QQ: what would I change "by _time" to if i wanted data counted up in 24hr chunks? When I tested my query i took the "by _time" out and was just running as "Last 15minutes" per splunk's main query interface (green) button.

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...