2023년 11월 6일 월요일

Logstash 필터 dns

IP의 도메인 주소를 질의해주는 dns 필터.
filter {
 mutate { 
  remove_field => ["@timestamp", "@version", "path", "host"] 
  strip => "message"
 }

 dns {
  reverse => "message"
 }
}
[2023-11-05T21:04:58,538][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
{
    "message" => [
        [0] "8.8.8.8",
[1] "dns.google"
    ]
}

beat에서는 이렇게.
processors:
  - drop_fields:
      fields: ["log", "input", "ecs", "host", "agent"]
  - dns:
      type: reverse
      fields:
        message: reverse
{
  "@timestamp": "2023-11-05T11:24:42.476Z",
  "@metadata": {
    "beat": "filebeat",
    "type": "_doc",
    "version": "8.10.4"
  },
  "reverse": "dns.google",
  "message": "8.8.8.8"
}

윈도우 환경에서는 nameservers 옵션을 지정해줘야 한다.
Exiting: error initializing processors: no dns servers configured
PS D:\ELK\filebeat-8.5.0-windows-x86_64>
processors:
  - drop_fields:
      fields: ["log", "input", "ecs", "host", "agent"]
  - dns:
      type: reverse
      nameservers: "8.8.8.8"
      fields:
        message: reverse

참고로 ingest pipeline은 해당 기능을 지원하지 않으며, 스플렁크는 내장된 lookup 기능을 사용하면 된다.



관련 글

댓글 없음:

댓글 쓰기

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