Splunk Search

Custom CSS stylesheet and inline CSS not working on tables, any suggestions?

SLoBello
Explorer
  • Made a custom css stylesheet. Referenced it in the form tag:
    <form stylesheet="customColors.css">

  • Then I restarted the splunkweb and splunkd services, nothing changes...

  • Decided to write SUPER SIMPLE inline css within a panel:

    table{ /tried [tbody / tr / even the container divs (classes associated)]/
    background-color: #303030 !important;/tried [bgcolor / background / color]/
    }
    The css below works fine for other areas
    .highcharts-background {
    fill: #303030 !important;
    }
    .highcharts-grid-line{
    fill: #ffffff !important;
    }
    text {
    fill: #ffffff !important;
    text-shadow: none;
    }
    .dashboard-panel, .with-title, .title-editor{
    background-color: #303030 !important;
    }
    .main-section-body, .dashboard-body,.title-editor{
    background-color: #393939 !important;
    }
    h1, h2, h3, p {
    color: #ffffff !important;
    }

  • I am testing locally (ie localhost..)

  • I have looked keenly at the documentation, nothing provides any details.

  • Tried all of splunk's referenced html classes (seen through 'inspect' via chrome). Tried all named classes for a table col/row/thread/etc/etc/etc, even tried".shared-resultstable-resultstablerow." Literally everything you can think of. Only the <td> tag worked. <th> does not, why?

I cant find a reason as to why this is happening. Am I missing something? Does anyone have a suggestion?

Tags (1)
0 Karma
1 Solution

niketn
Legend

@SLoBello, if you are on Splunk Enterprise 6.5 or higher, Table Cell Coloring can be done directly via the UI Edit options where each column/field name will have a pen icon to edit column and apply color based on criteria selected.

You can also get the Splunk Dashboard Examples App to use Simple XML JavaScript and CSS extension with Splunk JS Stack to apply Table Cell Highlighting or Table Row Highlighting by using tableView.addCellRenderer()

Having said these, if your Dashboard has static CSS based style to be applied without any dependency with dynamic JavaScript based code, then you can definitely apply the same via <style> tag in the form or external CSS file. Custom Layout Dark example in the Splunk Dashboard Examples App, also has few configurations.

There are several Examples on Splunk Answers for all above:
https://answers.splunk.com/answers/588394/change-the-color-of-rows-in-a-table-based-on-text-1.html
https://answers.splunk.com/answers/615411/how-to-format-table-range-per-week-automatically.html
https://answers.splunk.com/answers/581747/change-row-color-when-the-field-time-value-increas.html
https://answers.splunk.com/answers/612296/how-to-change-the-header-color-dynamically-using-j.html
https://answers.splunk.com/answers/593399/column-headers-color.html

If none of the above I working then you might need to share some mock up dashboard with Simple XML and CSS code.

PS: While Static css file requires Splunk refresh/restart/bump and possible clearing of browser cache. The CSS changes within dashboard using <style> element within <html> panel does not require the above. Such changes should be reflected immediately by refreshing the browser with dashboard alone.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

niketn
Legend

@SLoBello, if you are on Splunk Enterprise 6.5 or higher, Table Cell Coloring can be done directly via the UI Edit options where each column/field name will have a pen icon to edit column and apply color based on criteria selected.

You can also get the Splunk Dashboard Examples App to use Simple XML JavaScript and CSS extension with Splunk JS Stack to apply Table Cell Highlighting or Table Row Highlighting by using tableView.addCellRenderer()

Having said these, if your Dashboard has static CSS based style to be applied without any dependency with dynamic JavaScript based code, then you can definitely apply the same via <style> tag in the form or external CSS file. Custom Layout Dark example in the Splunk Dashboard Examples App, also has few configurations.

There are several Examples on Splunk Answers for all above:
https://answers.splunk.com/answers/588394/change-the-color-of-rows-in-a-table-based-on-text-1.html
https://answers.splunk.com/answers/615411/how-to-format-table-range-per-week-automatically.html
https://answers.splunk.com/answers/581747/change-row-color-when-the-field-time-value-increas.html
https://answers.splunk.com/answers/612296/how-to-change-the-header-color-dynamically-using-j.html
https://answers.splunk.com/answers/593399/column-headers-color.html

If none of the above I working then you might need to share some mock up dashboard with Simple XML and CSS code.

PS: While Static css file requires Splunk refresh/restart/bump and possible clearing of browser cache. The CSS changes within dashboard using <style> element within <html> panel does not require the above. Such changes should be reflected immediately by refreshing the browser with dashboard alone.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

SLoBello
Explorer

The first thing I tried when looking for a solution was the Dashboard examples but my version is 6.3...sadly no longer compatible (in most areas). And no easy peasy UI edit for me haha. However, the other links you posted of other questions helps a lot for finding other workarounds. You made an excellent point (that I forgot about); dynamic js! I thought I avoided it but looking at my panels now I think I have a few dependencies. I tried a few things just now that seem to be working. Thank you very much Niket, I appreciate your time for my question.

0 Karma

niketn
Legend

@SLoBello, Simple XML JS Extension would be the only option if you are on 6.3. Glad you found one of the solution you were looking for.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

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

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...