Developing for 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!

Maximize the Value from Microsoft Defender with Splunk

 Watch NowJoin Splunk and Sens Consulting for this Security Edition Tech TalkWho should attend:  Security ...

This Week's Community Digest - Splunk Community Happenings [6.27.22]

Get the latest news and updates from the Splunk Community here! News From Splunk Answers ✍️ Splunk Answers is ...

Reminder! Splunk Love Promo: $25 Visa Gift Card for Your Honest SOAR Review With ...

We recently launched our first Splunk Love Special, and it's gone phenomenally well, so we're doing it again, ...