我使用报告查询重新创建了仪表板,并让搜索返回了所有表结果。我有一个参考数字输入作为文本框。令牌名称为: purchCostReferenceToken
我想基于此令牌限制表结果。这是查询:
<form>
<label>Thru Train Dashboard</label>
<fieldset submitButton="false" autoRun="true">
<input type="text" token="purchCostReferenceToken" searchWhenChanged="true">
<label>Enter a TMS Reference Number to Filter Table</label>
<default>*</default>
<initialValue>*</initialValue>
</input>
</fieldset>
<row>
<panel>
<title>Thru Train Data</title>
<table>
<search>
<query>index=... "<billingMethod>RULE</billingMethod>" "createMessage MsgSource" | 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</query>
<earliest>-30d@d</earliest>
<latest>now</latest>
</search>
<option name="drilldown">none</option>
</table>
</panel>
</row>
</form>
我在哪里添加令牌以限制搜索? 我尝试将其添加到表命令之前的查询末尾:
... | eval Time =_time | convert timeformat="%m-%d-%Y %H:%M:%S" ctime(Time) purchCostReference=$purchCostReferenceToken$ | table purchCostReference, eventType, Time, Segments, Carriers, BillingMethod, Origin, Destination, StopOffLocation | sort Time
我得到一个错误... 转换命令中的错误:purchCostReference-参数无效
我想在几个表列中添加过滤器。 purchCostReference值是使用 xmlkv
在查询中提取的字段答案 0 :(得分:1)
从技术上讲,令牌可以放置在查询中的任何位置,但是当令牌被其值替换时,查询必须有效。 convert timeformat="%m-%d-%Y %H:%M:%S" ctime(Time) purchCostReference=4
是无效的SPL。
如果标记引用的字段是自动提取的,那么通常最好将标记放入基本搜索中。这里不是这种情况。
您应该使用search
或where
命令根据令牌值过滤事件。像xmlkv | search purchCostReference=$purchCostReferenceToken$
之类的东西。