小ネタ。作ったので。
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),"^[0-9]"">
<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),"^[a-z]"">
<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>
- 中身は、テーブル表示で、
md5
とsha1
の値で頭が数字
かアルファベット
かでリンク先を変更している。 -
<condition match="match(substr($click.value2$,1,3),"^[0-9]"">
が条件式。 -
"
は"
なので、if
でよく使うmatch()
の構文そのもの。 -
else が使えるわけではないので、
case()
と同じく、一つ一つ条件を書いてあげる。 - なお、条件に漏れがあると、通常のドリルダウンの動作(クリックされた値で検索)になる。
- 最後あたり
<condition match="1==1">
を作ってデバッグというのもありかも - 下記のrefのなかで
match="
の中が$
ではなくて'
で囲っていたけどどちらでもよかった。
reference: https://docs.splunk.com/Documentation/Splunk/latest/Viz/tokens