2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Splunk ドリルダウンでの条件分岐

Posted at

小ネタ。作ったので。

drilldown_condition.xml
<form>
  <label>drilldown condition test</label>
  <fieldset submitButton="true" autoRun="true">
    <input type="time" token="field1" searchWhenChanged="true">
      <label></label>
      <default>
        <earliest>0</earliest>
        <latest></latest>
      </default>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>| makeresults
| eval fieldA=md5(_time), fieldB=sha1(_time)</query>
          <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">cell</option>
        <option name="percentagesRow">false</option>
        <option name="refresh.display">progressbar</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <drilldown>
          <condition match="match(substr($click.value2$,1,3),&quot;^[0-9]&quot;">
            <set token="selected_sourcetype">$click.value2$</set>
            <link target="_blank">https://www.google.com/?q=$click.value2$</link>
          </condition>
          <condition match="match(substr($click.value2$,1,3),&quot;^[a-z]&quot;">
            <set token="selected_sourcetype">$click.value2$</set>
            <link target="_blank">https://www.virustotal.com/gui/search/$click.value2$</link>
          </condition>
        </drilldown>
      </table>
    </panel>
  </row>
</form>
  • 中身は、テーブル表示で、md5sha1の値で頭が数字アルファベットかでリンク先を変更している。
  • <condition match="match(substr($click.value2$,1,3),&quot;^[0-9]&quot;">
    が条件式。
  • &quot;"なので、ifでよく使うmatch()の構文そのもの。
  • else が使えるわけではないので、case()と同じく、一つ一つ条件を書いてあげる。
  • なお、条件に漏れがあると、通常のドリルダウンの動作(クリックされた値で検索)になる。
  • 最後あたり <condition match="1==1">を作ってデバッグというのもありかも
  • 下記のrefのなかでmatch="の中が $ ではなくて 'で囲っていたけどどちらでもよかった。

reference: https://docs.splunk.com/Documentation/Splunk/latest/Viz/tokens

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?