Dashboards & Visualizations

Writing Out to beforeLabel on SingleValue

Drainy
Champion

So at the moment there is some jquery I use which I believe @sideview posted some time ago, it begins with;

if (Splunk.Module.SingleValue) {
    Splunk.Module.SingleValue = $.klass(Splunk.Module.SingleValue, {
        renderResults: function($super, result) {

Now my problem is that I need to change the text to a link to another dashboard. If I use the linkView and linkSearch then it will pass a search through, I just want to link directly to another dashboard without using the view results link.

So, I decided to try and re-write the above to access the beforelabel but with little to no effect.
If anyone has any suggestions on how I could achieve this then I would be glad to hear it. I just need to do a text match on the contents of the beforeLabel and then assign a static URL to a custom dashboard for that text.

Tags (2)
1 Solution

Drainy
Champion

And below is the answer I eventually came up with after digging out the SingleValue module code 🙂 This code will look for a particular text match in your beforeLabel and apply a static link to it. You can extend this easily to add a link across the result and afterLabel too.

if (Splunk.Module.SingleValue) {
 Splunk.Module.SingleValue = $.klass(Splunk.Module.SingleValue, {
  renderResults: function($super, result) {
   var retVal = $super(result);
    if (this._before_label=="beforeLabel Text -") {
    $('.singleLabelBefore', this.container).html("<a href='dashboardtolinkto'>beforeLabel Text -</a>");
    } else if(this._before_label=="different beforeLabel Text -") {
     $('.singleLabelBefore', this.container).html("<a href='diffdashboard'>different beforeLabel Text -</a>");
    } 
    return retVal;
    }
});
}

View solution in original post

Drainy
Champion

And below is the answer I eventually came up with after digging out the SingleValue module code 🙂 This code will look for a particular text match in your beforeLabel and apply a static link to it. You can extend this easily to add a link across the result and afterLabel too.

if (Splunk.Module.SingleValue) {
 Splunk.Module.SingleValue = $.klass(Splunk.Module.SingleValue, {
  renderResults: function($super, result) {
   var retVal = $super(result);
    if (this._before_label=="beforeLabel Text -") {
    $('.singleLabelBefore', this.container).html("<a href='dashboardtolinkto'>beforeLabel Text -</a>");
    } else if(this._before_label=="different beforeLabel Text -") {
     $('.singleLabelBefore', this.container).html("<a href='diffdashboard'>different beforeLabel Text -</a>");
    } 
    return retVal;
    }
});
}

Drainy
Champion

No worries, glad it helped 🙂

0 Karma

606866581
Path Finder

Thanks for this!
Adding a link to a single value is unnecessarily difficult, you've been a great help

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...