All Apps and Add-ons

Dashboards and icons help

strawi
New Member

Hi

Im a newbie to splunk and just started developing dashboards etc
I have been following some examples in the Splunk "dashboard examples" app but still struggling to achieve the result.

As a test I have a csv file that has several headers such as Hostname, ServiceA, ServiceB, ServiceC etc etc

My js file ICONS is set to

TRUE: 'check-circle'
FALSE: 'alert-circle'
Stopped: 'alert-circle'
Running: 'check-circle'

I am trying to produce a dashboard that shows the host name and the either a tick or an alert in each cell depending if the cell reads , TRUE, FALSE, stopped or running.

So far i Can only get one volume to show ticks. Can anyone help?
Thank you

Tags (1)
0 Karma

strawi
New Member

here is my latest script? any ideas?

require([
'underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {

         var CustomIconRenderer = TableView.BaseCellRenderer.extend({
             canRender: function(cell) {
               var allowedCells = ["service1","service2", "serviceA", "serviceB", "servicec", "serviced"]
                           return (allowedCells.indexOf(cell.field)) > -1;
             },

              render: function($td, cell) {
                 var count = cell.value;

                 // Compute the icon base on the field value
                 var icon;
                 if(count == "TRUE" || "Running" ) {
                     icon = 'check';
                // } else if(count != TRUE && count != Running) {
                  //   icon = 'severe';
                 //} else if(count == 100) {
                 //    icon = 'low';
                 } else {
                     icon='alert';
                 }

                 // Create the icon element and add it to the table cell
                 $td.addClass('icon-inline numeric').html(_.template('<%- text %> <i class="icon-<%-icon%>"></i>', {
                     icon: icon,
                     text: cell.value
                 }));
             }
         });

         mvc.Components.get('table1').getVisualization(function(tableView){
             // Register custom cell renderer
             tableView.table.addCellRenderer(new CustomIconRenderer());
             // Force the table to re-render
             tableView.table.render();
         });
     });
0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...