Dashboards & Visualizations

Color the Table Cell based on inputlookup variable

vyulun
Explorer

Hi.
I have next script panel. I have saved limit values to csv. For ex. gc_perc90_standart=0.01. I need to color cell in green if value < 0.01 and red if more. But problem here - if (value > gc_perc90_standart, "#53A051", "#DC4E41")
How I should use variable within colorPalette?

<panel depends="$tok_GC_statistic$">
      <title>GC statistics in seconds</title>
      <table>
        <search>
          <query>
                      index="all" source="*/log/gc_log_memory.log"
                        | rex "Total time for which application threads were stopped:\s(?<GC_TIME_THREADS>[0-9]+\.{0,1}[0-9]*)\sseconds"
                        | stats count(GC_TIME_THREADS) as cntGC, perc90(GC_TIME_THREADS) as proc90GC by host                    
                        | join type=inner
                        [                    
                           | inputlookup gc_standarts.csv | fields gc_perc90_standart
                        ]                    
                        | table host cntGC proc90GC gc_perc90_standart
                    </query>
          <earliest>$TimeToken.earliest$</earliest>
          <latest>$TimeToken.latest$</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="drilldown">cell</option>
        <format type="color" field=proc90GC >
          <colorPalette type="expression">if (value > gc_perc90_standart, "#53A051", "#DC4E41")</colorPalette>
        </format>
        <drilldown>none</drilldown>
      </table>
    </panel>
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@vyulun

Can you please check my answer on below link? I have used Javascript and CSS to achieve same requirement. Let me know for any further assistance.

https://answers.splunk.com/answers/661894/how-to-color-cell-contents-with-css-and-js.html#answer-661...

Thanks

vyulun
Explorer

thx, I will try css.

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@vyulun

Can you please try this?

     <format type="color" field=proc90GC >
       <colorPalette type="expression">if (value > 'gc_perc90_standart', "#53A051", "#DC4E41")</colorPalette>
     </format>

My Sample Code :

<dashboard>
  <label>test</label>
  <row>
    <panel>
      <table>
        <search>
          <query>index=main |stats count by sourcetype | eval step=20000</query>
          <earliest>-30d@d</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">row</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="wrap">true</option>
        <format type="color" field="count">
          <colorPalette type="expression">if (value > 'step',"#FF5733","#247bc1")</colorPalette>
        </format>

      </table>
    </panel>
  </row>
</dashboard>

Thanks

0 Karma

vyulun
Explorer

also with constant works correct
.... if (value > 0.01, .....

0 Karma

vyulun
Explorer

I have made experiment with integers (1 2 3...), but the same problems

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@vyulun

Can you please share sample output of your search??

0 Karma

vyulun
Explorer
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@vyulun

I have tried with the same. Yes it is working if we defined hard coded value. But it is not when we mentioned field name. I think we can only use value of that field which in mentioned in colorPalette tag.

I have posted another answer to this question. I have achieved same thin using Javascript & CSS. Can you please check the same?

0 Karma

vyulun
Explorer

Hi, kamlesh_vaghela. Thx for help. But, unfortunatelly, not resolve my problem. All values are red. Maybe because gc_perc90_standart is float value == 0.01?
Splunk version 7.1.2.

0 Karma
Get Updates on the Splunk Community!

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...