Building for the Splunk Platform

How to add URL as hyperlink for the column values in dashboard?

Ashwini008
Contributor

Hi,

My requirement is i need to show URL (ex: https://google.com) as hyperlink on "109" value of  'SFG Request ID' column and when clicked on 109 it should take me to the URL added.

The below details are from lookup file.Similarly i need to display Different URL for on values of 'SFG Request ID' column

Ashwini008_0-1650873835390.png

URL details are not present in the csv file,It is present in another lookup file.

Can anyone please suggest me how to do this?

0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

I assume this is in a dashboard table, so see this example

<dashboard>
  <label>sfg</label>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults count=10
| eval SFG=random() % 5 + 109
| eval URL="https://google.com?q=".SFG
| table _time SFG URL</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">100</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <option name="drilldown">row</option>
        <fields>_time, SFG</fields>
        <drilldown>
          <link target="_blank">$row.URL|n$</link>
        </drilldown>
      </table>
    </panel>
  </row>
</dashboard>

What you need to do is to lookup/generate the relevant URL for the SFG code, but hide that URL field from the display. In the above dashboard code, it does NOT show the URL field (using <fields> element).

However that field is still available to the drilldown, so you can then just use the standard <link> element with the token value from the clicked row ($row.URL|n$). Note the |n at the end, which prevents the dashboard from encoding the token, so it is treated as a URL.

 

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

I assume this is in a dashboard table, so see this example

<dashboard>
  <label>sfg</label>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults count=10
| eval SFG=random() % 5 + 109
| eval URL="https://google.com?q=".SFG
| table _time SFG URL</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">100</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <option name="drilldown">row</option>
        <fields>_time, SFG</fields>
        <drilldown>
          <link target="_blank">$row.URL|n$</link>
        </drilldown>
      </table>
    </panel>
  </row>
</dashboard>

What you need to do is to lookup/generate the relevant URL for the SFG code, but hide that URL field from the display. In the above dashboard code, it does NOT show the URL field (using <fields> element).

However that field is still available to the drilldown, so you can then just use the standard <link> element with the token value from the clicked row ($row.URL|n$). Note the |n at the end, which prevents the dashboard from encoding the token, so it is treated as a URL.

 

Ashwini008
Contributor

@bowesmana Thank You,

Can you please help me only on click of 129 it should take me to External URL.

Currently drilldown is enabled on whole row so clicking on anywhere in row will take me to the external Link.

Ashwini008_0-1650989738767.png

 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Make the drilldown "cell" and set conditions on the drilldown, like this

<dashboard>
  <label>sfg</label>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults count=10
| eval SFG=random() % 5 + 109
| eval URL="https://google.com?q=".SFG
| table _time SFG URL</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">100</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <option name="drilldown">cell</option>
        <fields>_time, SFG</fields>
        <drilldown>
          <condition field="SFG">
            <link target="_blank">$row.URL|n$</link>
          </condition>
          <condition field="*"/>
        </drilldown>
      </table>
    </panel>
  </row>
</dashboard>

Azeemering
Builder
0 Karma

Ashwini008
Contributor

@Azeemering Thank you for the link.

In the table i have many other such values for the column like '109,110,111,112 and so on. For each value i need to add a different URL .

I am not sure how this can be done

0 Karma
Get Updates on the Splunk Community!

Routing Data to Different Splunk Indexes in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. The OpenTelemetry project is the second largest ...

Getting Started with AIOps: Event Correlation Basics and Alert Storm Detection in ...

Getting Started with AIOps:Event Correlation Basics and Alert Storm Detection in Splunk IT Service ...

Register to Attend BSides SPL 2022 - It's all Happening October 18!

Join like-minded individuals for technical sessions on everything Splunk!  This is a community-led and run ...