splunk 仪表板包括将填充到 pdf 文件中的时间范围

splunk dashboard to include the time rage that will populate into the pdf file

我有一个 splunk 仪表板,returns 根据具有开始和结束时间范围的时间选择器生成结果 我想在仪表板中包含该时间范围,以便生成的 PDF 显示时间范围。

您可以添加 <panel><html> 以显示 $date.earliest$$date.latest$ 值:

<row>
  <panel>
    <html>
     <h1>Date Range : $date.earliest$ - $date.latest$ </h1>
   </html>
  </panel>
</row>

您可能希望设置值的格式以反映实际的日期时间值。您可以评估具有格式化日期时间值的字段:

<input type="time" token="date" searchWhenChanged="true">
  <label>date</label>
  <default>
    <earliest>-40m@m</earliest>
    <latest>now</latest>
  </default>
  <change>
    <eval token="timelabel_earliest">if(isnum($date.earliest$), strftime($date.earliest$,"%m/%d/%Y %H:%M"), strftime(relative_time(now(), $date.earliest$),"%m/%d/%Y %H:%M") )</eval>
    <eval token="timelabel_latest">if(isnum($date.latest$), strftime($date.latest$,"%m/%d/%Y %H:%M"), strftime(relative_time(now(), $date.latest$), "%m/%d/%Y %H:%M") )</eval>
  </change>
</input>

然后使用具有格式化值的字段:

<row>
  <panel>
    <html>
      <h1>$AppEnv$ : $timelabel_earliest$ - $timelabel_latest$ </h1>
    </html>
  </panel>
</row>

下面是一个完整的仪表板示例,演示了如何显示时间选择器值和格式化:

<form>
  <label>Display Time Picker</label>
  <fieldset submitButton="false">
    <input type="time" token="field1">
      <label></label>
      <default>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </default>
       <change>
         <eval token="timelabel_earliest">if(isnum($field1.earliest$), strftime($field1.earliest$,"%m/%d/%Y %H:%M"), strftime(relative_time(now(), $field1.earliest$),"%m/%d/%Y %H:%M") )</eval>
         <eval token="timelabel_latest">if(isnum($field1.latest$), strftime($field1.latest$,"%m/%d/%Y %H:%M"), strftime(relative_time(now(), $field1.latest$), "%m/%d/%Y %H:%M") )</eval>
      </change>
    </input>
  </fieldset>
  <row>
  <panel>
    <html>
     <h1>Date Range: $field1.earliest$ - $field1.latest$ </h1>
     <h1>Date Range formatted: $timelabel_earliest$ - $timelabel_latest$ </h1>
   </html>
  </panel>
</row>
</form>

呈现如下: