如何将令牌添加到 Splunk 中的仪表板查询?
How do I added a token to the query of a dashboard in Splunk?
我使用报告查询重新创建了仪表板,并让搜索返回所有 table 结果。我有一个参考号输入作为文本框。令牌名称是:purchCostReferenceToken
我想根据此令牌限制 table 结果。这是查询:
<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>
在哪里添加令牌来限制搜索?
我尝试将此添加到 table 命令之前的查询末尾:
... | 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- 无效
我想在几个 table 列中添加过滤器。 purchCostReference 值是使用 xmlkv
在查询中提取的字段
从技术上讲,令牌可以放在查询中的任何位置,但当令牌被替换为其值时,查询必须有效。 convert timeformat="%m-%d-%Y %H:%M:%S" ctime(Time) purchCostReference=4
不是有效的 SPL。
如果令牌引用的字段是自动提取的,那么通常最好将令牌放入基本搜索中。这里不是这种情况。
您应该使用 search
或 where
命令根据令牌值过滤事件。类似于 xmlkv | search purchCostReference=$purchCostReferenceToken$
.
我使用报告查询重新创建了仪表板,并让搜索返回所有 table 结果。我有一个参考号输入作为文本框。令牌名称是:purchCostReferenceToken
我想根据此令牌限制 table 结果。这是查询:
<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>
在哪里添加令牌来限制搜索? 我尝试将此添加到 table 命令之前的查询末尾:
... | 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- 无效
我想在几个 table 列中添加过滤器。 purchCostReference 值是使用 xmlkv
在查询中提取的字段从技术上讲,令牌可以放在查询中的任何位置,但当令牌被替换为其值时,查询必须有效。 convert timeformat="%m-%d-%Y %H:%M:%S" ctime(Time) purchCostReference=4
不是有效的 SPL。
如果令牌引用的字段是自动提取的,那么通常最好将令牌放入基本搜索中。这里不是这种情况。
您应该使用 search
或 where
命令根据令牌值过滤事件。类似于 xmlkv | search purchCostReference=$purchCostReferenceToken$
.