Splunk仪表板-搜索查询中的令牌

时间:2020-09-01 15:31:32

标签: splunk

我是Splunk的新手,并且正在研究XML仪表板的结构。我在代码中看到以下内容:

    <input id="input" type="dropdown" token="serve" searchWhenChanged="false">
      <label>Serve</label>
      <fieldForLabel>serve</fieldForLabel>
      <fieldForValue>name</fieldForValue>
      <search id="search_serve">
        <query>$custom_search$</query>
        <earliest></earliest>
        <latest></latest>
      </search>
    </input>

搜索完整的XML文件,看不到

$custom_search$

令牌在任何地方列出。可以在其他位置定义此令牌吗?

1 个答案:

答案 0 :(得分:0)

尝试在XML中搜索custom_search而不是$custom_search$。 定义后,令牌将不包含美元($)符号。仅在使用令牌时才包含它们。

提供的下拉菜单的作用是,它基于通过custom_search令牌传递的另一个搜索的输出动态填充下拉列表值

下面是一个示例,其中使用_internal_introspection索引的源类型填充下拉列表。请注意,令牌在定义时如何称为custom_search

<input type="radio" token="custom_search">

,并且在使用令牌时将其用作$custom_search$

<query>$custom_search$</query>

可以随意在控制面板中拍一下示例,以查看实际操作

<form>
  <label>Search as token</label>
  <fieldset submitButton="false">
    <input type="radio" token="custom_search">
      <label>Select Index</label>
      <choice value="index=_internal |stats c by sourcetype|table sourcetype">_internal</choice>
      <choice value="index=_introspection |stats c by sourcetype|table sourcetype">_introspection</choice>
      <default>index=_internal |stats c by sourcetype|table sourcetype</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <input id="input" type="dropdown" token="serve" searchWhenChanged="false">
        <label>Sourcetype</label>
        <fieldForLabel>Sourcetype</fieldForLabel>
        <fieldForValue>sourcetype</fieldForValue>
        <search id="search_serve">
          <query>$custom_search$</query>
          <earliest></earliest>
          <latest></latest>
        </search>
      </input>
    </panel>
  </row>
</form>

enter image description here

如果这可以解决您的问题,请花一点时间接受答案。这可以通过单击答案旁边的复选标记将其从灰色切换为填充来完成!