All Apps and Add-ons

how to color cells using sideview utils

abhayneilam
Contributor

Hi,

I want to make use of "sideview" utils to color the entire row. I am very week in css and html.
Please suggest me how to achieve this my making use of "sideview" utils..

Please help me as this is very urgent !!

Thanks in advance !!

Abhay

1 Solution

sideview
SplunkTrust
SplunkTrust

An example config is below.

The basic idea is to create a field on each search result row. We use some search syntax to set the values of the new field to various colors. In this case we use the PostProcess module to do the logic in a "postprocess" search. If you're not familiar with postprocess searches then you should read up. Otherwise you can avoid postProcess and instead just tack the search syntax you see onto the end of your base search.

Anyway, we use the rowClass param to tell the Table that we want it to use our field values as a classname on each row. And we use the hiddenFields param to tell the Table not to render the actual color names themselves in table cells.

<module name="PostProcess">
  <param name="search">
    | eval myClassField=case(field1=="False" AND isnotnull(field2), "red", field1=="False" AND isnull(field2),"yellow", field1=="TRUE", "")
  </param>

  <module name="Pager">
    <module name="Table">
      <param name="rowClass">$row.fields.myClassField$</param>
      <param name="hiddenFields">myClassField</param>
    </module>
  </module>
</module>

The next step is putting custom css in, to actually specify the colors.

tr.yellow td {
  background-color: #aaaa00;
}
tr.red td {
  background-color:#aa0000;
}

Here's a link to general documentation about custom CSS in Splunk. http://docs.splunk.com/Documentation/Splunk/5.0/AdvancedDev/UseCSS

View solution in original post

sideview
SplunkTrust
SplunkTrust

An example config is below.

The basic idea is to create a field on each search result row. We use some search syntax to set the values of the new field to various colors. In this case we use the PostProcess module to do the logic in a "postprocess" search. If you're not familiar with postprocess searches then you should read up. Otherwise you can avoid postProcess and instead just tack the search syntax you see onto the end of your base search.

Anyway, we use the rowClass param to tell the Table that we want it to use our field values as a classname on each row. And we use the hiddenFields param to tell the Table not to render the actual color names themselves in table cells.

<module name="PostProcess">
  <param name="search">
    | eval myClassField=case(field1=="False" AND isnotnull(field2), "red", field1=="False" AND isnull(field2),"yellow", field1=="TRUE", "")
  </param>

  <module name="Pager">
    <module name="Table">
      <param name="rowClass">$row.fields.myClassField$</param>
      <param name="hiddenFields">myClassField</param>
    </module>
  </module>
</module>

The next step is putting custom css in, to actually specify the colors.

tr.yellow td {
  background-color: #aaaa00;
}
tr.red td {
  background-color:#aa0000;
}

Here's a link to general documentation about custom CSS in Splunk. http://docs.splunk.com/Documentation/Splunk/5.0/AdvancedDev/UseCSS

sideview
SplunkTrust
SplunkTrust

Yea, I'm afraid I agree with Ayn - it sounds like you should just back away slowly and leave this stuff alone. Follow the link to learn more about custom CSS in Splunk, but as far as learning what CSS is, I'm afraid I can't help you there. And indeed none of this will do anything to get the cells colored in Excel after export.

Ayn
Legend

Also the cell coloring only affects the display in Splunk, not when exporting the data in any kind of way.

0 Karma

Ayn
Legend

If you're developing something for a web environment without having a single idea about CSS and HTML, you're in a world of trouble.

abhayneilam
Contributor

Hi, thanks for this, but sorry to say that I dont have any single idea about css and html

Please let me know where to keep that code and how to execute that one..

Please help since I have not that much idea about css and html or xml.

Please tell me stepwise how "where to keep these lines", "how to execute , so that color will come when i will export it in the excel"

Kindly help

Thanks

0 Karma

abhayneilam
Contributor

Some rows which have some certain fields like :

If field1="False" AND field2!="" then "RED" color
If field1="False" AND field2="" then "YELLOW" color
If field1="TRUE" then no color

Based on above three conditions I want to color my entire row, but I am very week in understanding in css and html.

Please help !!

Thanks in Advance !!
Abhay

sideview
SplunkTrust
SplunkTrust

Do you want to color every row, or only some rows that have certain field values? Can you give some specifics?

Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...