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
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();
});
});