Splunk Dev

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

Ashwini008
Builder

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
Builder

@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>

Ashwini008
Builder

@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

Bart
Explorer

Hi,

Have you manage to come up with solution? Been trying this for a while now to appy hyperlink just for selected column value or just column instead of the whole row.

Regards

Bartek

Tags (2)
0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...