All Apps and Add-ons

Splunk 6.x Dashboard Examples: How to change table_icons_inline to show Icons based on Text Values from a column called 'Status'?

hgehrts_splunk
Splunk Employee
Splunk Employee

Hi all

I'm stuck. How do I change the table_icons_inline.js so that it uses the values "OK" and "Error" from a Column called "Status"? I want to have a green check when the Status is OK in a row... and of course red x or something similar when I get "Error" for Status in the row.
The only feedback I get is a blank report where it says " Search is waiting for input... ".

I thought this would work, but I have to admit I am somewhat new to javascript:

require([
    'underscore',
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {
    var CustomIconRenderer = TableView.BaseCellRenderer.extend({
        canRender: function(cell) {
            return cell.field === 'Status';
        },
        render: function($td, cell) {
            var count = cell.value;
            // Compute the icon base on the field value
            var icon;
            if(count == "Error") {
                icon = 'alert-circle';
            } else if(count == "-") {
                icon = 'alert';
            } else {
                icon = 'check';
            }
            // 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

alacercogitatus
SplunkTrust
SplunkTrust

That Javascript looks pretty correct, If the table isn't loading, it means that the search isn't being returned with Data. What search are you using to populate the table? If you perform the search in the search bar, does it return results over the same time range?

Are you using an HTML Dashboard? Simple XML? How are you setting the search manager to the table?

0 Karma
Get Updates on the Splunk Community!

Take the 2021 Splunk Career Survey for $50 in Amazon Cash

Help us learn about how Splunk has impacted your career by taking the 2021 Splunk Career Survey. Last year’s ...

Using Machine Learning for Hunting Security Threats

WATCH NOW Seeing the exponential hike in global cyber threat spectrum, organizations are now striving more for ...

Observability Newsletter Highlights | March 2023

 March 2023 | Check out the latest and greatestSplunk APM's New Tag Filter ExperienceSplunk APM has updated ...