Dashboards & Visualizations

Colour-coded columns from stats avg by field

benhooper
Communicator

I want to have a colour-coded column chart for the average amount of time that an incident has been open by its severity.

So far, I think I have achieved most of this with the following search query:

 

index=* | where match(status, "resolved")
| stats earliest(creation_time) as creation_time, earliest(modification_time) as resolve_time, latest(severity) as severity by incident_id
| eval creation_time_epoch = strptime(creation_time, "%Y/%m/%d %H:%M:%S") | eval resolve_time_epoch = strptime(resolve_time, "%Y/%m/%d %H:%M:%S") | eval timedifference_hours = ((resolve_time_epoch - creation_time_epoch) / 60) / 60
| stats avg(timedifference_hours) as timedifference_hours_average by severity | eval timedifference_hours_average = round(timedifference_hours_average, 2)
| table severity, timedifference_hours_average

 

2020 ∕ 11 ∕ 12 16꞉06꞉21 - Search__Splunk_8.1.0_-_Google_Chrome.png

The problem is that, probably due to a flaw with my search query, the legend is not per severity and, seemingly as a result, the dashboard XML <option name="charting.fieldColors">{"low": 0x3391FF, "medium": 0xF8BE34, "high": 0xDF4D58}</option> is not applying.

Can anyone point me in the right direction?

Thanks.

Labels (2)
0 Karma

to4kawa
Ultra Champion

work around:

| makeresults 
| eval _raw="severity,time_diff_avg
high,9.09
low,9.08
medium,19.51"
| multikv forceheader=1
| table severity time_diff_avg
| rex "(?<comment>(?# the logic))"
| xyseries severity severity time_diff_avg
| table severity high medium low

It's the only way to be satisfied with everything you want to do.

 

0 Karma

to4kawa
Ultra Champion

sample:

<dashboard>
  <label>chart color</label>
  <row>
    <panel>
      <chart>
        <search>
          <query>| makeresults 
| eval _raw="severity,time_diff_avg
high,9.09
low,9.08
medium,19.51"
| multikv forceheader=1
| table severity time_diff_avg
| eval severities="severity"
| xyseries  severities severity time_diff_avg</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="charting.axisTitleX.visibility">collapsed</option>
        <option name="charting.chart">column</option>
        <option name="charting.drilldown">all</option>
        <option name="charting.fieldColors">{"low": 0x3391FF, "medium": 0xF8BE34, "high": 0xDF4D58}</option>
      </chart>
    </panel>
  </row>
</dashboard>

benhooper
Communicator

Hi @to4kawa ,

Thanks for that. It's very promising.

Is there any way to preserve the following aspects of my method with yours?

  • Display the severity under each column.
  • Preserve sort order of severity.
  • Display the following in the hover element:
    "severity: <severity>
    timedifference_hours_average: <number>"

How it currently looks using my method:

2020 ∕ 11 ∕ 24 13꞉28꞉54 - Keeper_Desktop_Applet.png

How it currently looks using your method:

2020 ∕ 11 ∕ 24 13꞉29꞉49 - Search__Splunk_8.1.0_-_Google_Chrome.png

Thanks.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...