我如何将输入参数数据发送到Splunk中的仪表板上的报告

问题描述 投票:0回答:1

我正在使用Splunk创建仪表板。我向仪表板添加了一个报告,该报告将来自搜索的所有数据返回到表中。我想添加一些输入字段,以便用户选择过滤报表的数据。第一个输入是文本框字段。默认和初始值用*设置。我希望什么都重要。这是从仪表板创建的xml:

<form>
  <label>Thru Train Dashboard</label>
  <fieldset submitButton="false" autoRun="true">
    <input type="text" token="purchCostReferenceToken" searchWhenChanged="true">
      <label>TMS Reference Number</label>
      <default>*</default>
      <initialValue>*</initialValue>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Thru Train XML DATA</title>
      <table>
        <search ref="ThruTrainReportNestedResults"></search>
        <option name="drilldown">row</option>
        <option name="rowNumbers">true</option>
      </table>
    </panel>
  </row>
</form>

我知道我必须将令牌值purchCostReferenceToken用作报告ThruTrainReportNestedResults的输入。但由于报告搜索没有输入参数,因此不确定如何执行此操作。

这是创建报告的搜索查询,ThruTrainReportNestedResults

 sourcetype... | xmlkv | rex max_match=0 "\<purchasedCostTripSegment\>(?P<segment>[^\<]+)" |eval Segments =  mvrange(1,mvcount(mvindex(segment, 0, 2))+1,1) | rex max_match=0 "\<carrier\>(?P<Carriers>[^\<]+)" | rex max_match=0 "\<billingMethod\>(?P<BillingMethod>[^\<]+)" | rex max_match=0 "<purchasedCostTripSegment>[\s\S]*?<origin>\s*<ns2:numberCode>(?P<Origin>\d+)"  | rex max_match=0 "<purchasedCostTripSegment>[\s\S]*?<destination>\s*<ns2:numberCode>(?P<Destination>\d+)" | rex max_match=0 "<purchasedCostTripSegment>[\s\S]*?<stopOff>\s*<ns2:stopOffLocation>\s*<ns2:numberCode>(?P<StopOffLocation>\d+)" | eval Time =_time | convert timeformat="%m-%d-%Y %H:%M:%S" ctime(Time) | table purchCostReference, eventType, Time, Segments, Carriers, BillingMethod, Origin, Destination, StopOffLocation | sort Time

是否有一种方法可以使用输入数据从仪表板中过滤此查询的结果?我要过滤的输入数据是purchCostReference,eventType和Segments

splunk splunk-query
1个回答
0
投票

您无法将参数发送到报告。 https://docs.splunk.com/Documentation/Splunk/8.0.4/Viz/PanelreferenceforSimplifiedXML#search

您将需要使用内联搜索,如下所示。您需要包括搜索并使用令牌$purchaseCoseReferenceToken

适当地对其进行过滤。
<form>
  <label>Thru Train Dashboard</label>
  <fieldset submitButton="false" autoRun="true">
    <input type="text" token="purchCostReferenceToken" searchWhenChanged="true">
      <label>TMS Reference Number</label>
      <default>*</default>
      <initialValue>*</initialValue>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Thru Train XML DATA</title>
      <table>
        <search>
            <query>
            sourcetype=blah somefield=$purchCostReferenceToken$
            </query>
        </search>
        <option name="drilldown">row</option>
        <option name="rowNumbers">true</option>
      </table>
    </panel>
  </row>
</form>
© www.soinside.com 2019 - 2024. All rights reserved.