2025년 2월 14일 금요일

Splunk 대시보드 - 3rd

스플렁크 대시보드 생성 시 조건 입력창은 다섯 가지인데 UI만 다를 뿐 기능은 모두 동일하다.


프로토콜 조건 입력창 추가. 프로토콜 리스트는 최근 30일 데이터에서 선택.


아직은 조건을 선택해도 차트에 적용되지 않는다.


원본 소스를 보면 프로토콜 조건 입력창의 선택값은 field2 토큰에 저장된다. 해당 토큰을 검색어에 적용해줘야 차트에 반영된다는 얘기.
<form version="1.1" theme="light">
<label>Windows Firewall</label> <fieldset submitButton="false" autoRun="true"> <input type="time" token="field1"> <label></label> <default> <earliest>-15m</earliest> <latest>now</latest> </default> </input> <input type="radio" token="field2"> <label>Protocol</label> <fieldForLabel>protocol</fieldForLabel> <fieldForValue>protocol</fieldForValue> <search> <query>index=winfirewall | stats count by protocol</query> <earliest>-30d@d</earliest> <latest>now</latest> </search> </input> </fieldset> <row> <panel> <table> <title>목적지별 발생 현황</title> <search> <query>index=winfirewall protocol=$field2$ | stats count by protocol, dst_ip, dst_port, action, path | sort - count</query> <earliest>$field1.earliest$</earliest> <latest>$field1.latest$</latest> </search> <option name="drilldown">none</option> </table> </panel> </row> </form>

다른 입력창 동작 방식도 모두 마찬가지.


Multiselect(다중 선택)는 약간 다르다. 다른 입력창은 검색 구문에 선택값만 반영하는 구조인데, 다중 입력은 둘 이상의 값을 선택하기 위한 구문까지 정해줘야 함.

<form version="1.1" theme="light">
  <label>Windows Firewall</label>
  <fieldset submitButton="false" autoRun="true">
    <input type="time" token="field1">
      <label></label>
      <default>
        <earliest>-15m</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="multiselect" token="field2">
      <label>Protocol</label>
      <valuePrefix>protocol=</valuePrefix>
      <delimiter> OR </delimiter>
      <fieldForLabel>protocol</fieldForLabel>
      <fieldForValue>protocol</fieldForValue>
      <search>
        <query>index=winfirewall
| stats count by protocol</query>
        <earliest>-30d@d</earliest>
        <latest>now</latest>
      </search>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <title>목적지별 발생 현황</title>
        <search>
          <query>index=winfirewall $field2$
| stats count by protocol, dst_ip, dst_port, action, path
| sort - count</query>
          <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>

그냥 Text 옵션 이용해서 검색창을 붙이자.
<form version="1.1" theme="light">
<label>Windows Firewall</label> <fieldset submitButton="false" autoRun="true"> <input type="time" token="field1"> <label></label> <default> <earliest>-15m</earliest> <latest>now</latest> </default> </input> <input type="text" token="search_keyword"> <label></label> <default></default> </input> </fieldset> <row> <panel> <table> <title>목적지별 발생 현황</title> <search> <query>index=winfirewall $search_keyword$ | stats count by protocol, dst_ip, dst_port, action, path | sort - count</query> <earliest>$field1.earliest$</earliest> <latest>$field1.latest$</latest> </search> <option name="drilldown">none</option> </table> </panel> </row>
</form>

크리에이티브 커먼즈 라이선스