2022년 12월 15일 목요일

엘라스틱의 해시 변환 - 2nd

다음은 beat processor 중 fingerprint 사용 결과.
processors:
  - drop_fields:
      fields: ["log", "input", "ecs", "host", "agent"]
  - fingerprint:
      fields: "message"
      target_field: "hash"
      method: "md5"      
{
  "@timestamp": "2022-12-15T01:47:12.316Z",
  "@metadata": {
    "beat": "filebeat",
    "type": "_doc",
    "version": "8.5.0"
  },
  "message": "abc",
  "hash": "97c62dbf21c25b8a6c597ac16e80d9e8",
}

다음은 로그스태시 fingerprint 필터 사용 결과. 출력값이 다르다. 입력값이 같으면 출력값도 같아야 하는 거 아닌가? 
filter {
 mutate {remove_field => ["@timestamp", "@version", "path", "host"]}
 fingerprint {
  method => "MD5"
 }
}
[2022-12-15T10:56:47,625][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
{
    "fingerprint" => "8ae0dd80d1260fd836d8dd1624fed14e",
        "message" => "abc\r"
}

다음은 ingest processor 중 fingerprint 사용 결과.
POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "fingerprint": {
          "fields": ["message"],
          "method": "MD5"
        }
      }
    ]
  },
  "docs": [
    {
      "_source": {
        "message": "abc"
      }
    }
  ]
}
{
  "docs": [
    {
      "doc": {
        "_index": "_index",
        "_id": "_id",
        "_version": "-3",
        "_source": {
          "message": "abc",
          "fingerprint": "ejlJ6rGks2CfsF8mmevrjw=="
        },
        "_ingest": {
          "timestamp": "2022-12-15T11:05:48.1327213Z"
        }
      }
    }
  ]
}

ingest processor는 beat나 로그스태시와 달리 출력값이 16진수가 아니다. 왜죠? 

댓글 없음:

댓글 쓰기

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