Splunk Search

How can I convert column value to column?

liondancer
Explorer

I have the following output from my query:

**Search Query** | eval DateHour=year."-".month."-".day."-".hour | chart event_count BY DateHour, zone

DateHour      |  event_count              |  zone
2018-04-10              14                     A
2018-04-10              14                     B
2018-04-11              18                     A
2018-04-11              18                     B

What can I do to convert my table to something like this:

DateHour              |  A                |     B
2018-04-10              14                     14
2018-04-11              18                     18
0 Karma
1 Solution

mayurr98
Super Champion

Try this

<your_base_query_to_get_first_output>| chart values(event_count) over date_hour by zone

let me know if this helps!

View solution in original post

harishalipaka
Motivator
| makeresults | eval DateHour="2018-04-10" 
| eval event_count=14 
| eval zone = "A" 
| fields - _time 
| append
    [| makeresults | eval DateHour="2018-04-10" 
| eval event_count=14 
| eval zone = "B" | fields - _time ]
| append
    [| makeresults | eval DateHour="2018-04-11" 
| eval event_count=18 
| eval zone = "A" | fields - _time ]
| append
    [| makeresults | eval DateHour="2018-04-11" 
| eval event_count=18
| eval zone = "B" | fields - _time ] 

| chart values(event_count) over DateHour by zone
Thanks
Harish

mayurr98
Super Champion

Try this

<your_base_query_to_get_first_output>| chart values(event_count) over date_hour by zone

let me know if this helps!

somesoni2
SplunkTrust
SplunkTrust

Are you sure you're using chart command like the one you showed (probably missing aggregate function)? If your chart command is ...| chart <<some aggregation>> BY DateHour zone, then you should get the output#2 which you need. You're not using stats right?

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 ...