2017-03-06 1 views
1

저는 ELK를 처음 사용했습니다. 내가 Elasticsearch에 인덱스를 생성 한ElasticSearch 색인 생성 문제가 타임 스탬프를 구문 분석하지 못했습니다.

다음
{ 
    "logstash": { 
    "aliases": {}, 
    "mappings": { 
     "log": { 
     "dynamic_templates": [ 
      { 
      "message_field": { 
       "path_match": "message", 
       "match_mapping_type": "string", 
       "mapping": { 
       "norms": false, 
       "type": "text" 
       } 
      } 
      }, 
      { 
      "string_fields": { 
       "match": "*", 
       "match_mapping_type": "string", 
       "mapping": { 
       "fields": { 
        "keyword": { 
        "type": "keyword" 
        } 
       }, 
       "norms": false, 
       "type": "text" 
       } 
      } 
      } 
     ], 
     "properties": { 
      "@timestamp": { 
      "type": "date" 
      }, 
      "@version": { 
      "type": "keyword", 
      "include_in_all": false 
      }, 
      "activity": { 
      "type": "text", 
      "norms": false, 
      "fields": { 
       "keyword": { 
       "type": "keyword" 
       } 
      } 
      }, 
      "beat": { 
      "properties": { 
       "hostname": { 
       "type": "text", 
       "norms": false, 
       "fields": { 
        "keyword": { 
        "type": "keyword" 
        } 
       } 
       }, 
       "name": { 
       "type": "text", 
       "norms": false, 
       "fields": { 
        "keyword": { 
        "type": "keyword" 
        } 
       } 
       }, 
       "version": { 
       "type": "text", 
       "norms": false, 
       "fields": { 
        "keyword": { 
        "type": "keyword" 
        } 
       } 
       } 
      } 
      }, 
      "filename": { 
      "type": "text", 
      "norms": false, 
      "fields": { 
       "keyword": { 
       "type": "keyword" 
       } 
      } 
      }, 
      "host": { 
      "type": "text", 
      "norms": false, 
      "fields": { 
       "keyword": { 
       "type": "keyword" 
       } 
      } 
      }, 
      "input_type": { 
      "type": "text", 
      "norms": false, 
      "fields": { 
       "keyword": { 
       "type": "keyword" 
       } 
      } 
      }, 
      "message": { 
      "type": "text", 
      "norms": false 
      }, 
      "offset": { 
      "type": "long" 
      }, 
      "source": { 
      "type": "text", 
      "norms": false, 
      "fields": { 
       "keyword": { 
       "type": "keyword" 
       } 
      } 
      }, 
      "tags": { 
      "type": "text", 
      "norms": false, 
      "fields": { 
       "keyword": { 
       "type": "keyword" 
       } 
      } 
      }, 
      "timestamp": { 
      "type": "date", 
      "include_in_all": false, 
      "format": "YYYY-MM-DD HH:mm:ss.SSS" 
      }, 
      "type": { 
      "type": "text", 
      "norms": false, 
      "fields": { 
       "keyword": { 
       "type": "keyword" 
       } 
      } 
      }, 
      "user": { 
      "type": "text", 
      "norms": false, 
      "fields": { 
       "keyword": { 
       "type": "keyword" 
       } 
      } 
      } 
     } 
     } 
    }, 
    "settings": { 
     "index": { 
     "creation_date": "1488805244467", 
     "number_of_shards": "1", 
     "number_of_replicas": "0", 
     "uuid": "5ijhh193Tr6y_hxaQrW9kg", 
     "version": { 
      "created": "5020199" 
     }, 
     "provided_name": "logstash" 
     } 
    } 
    } 
} 

내 logstash 구성

input{ 
    beats{ 
     port=>5044 
    } 
}filter{ 
    grok{ 
     match=>{"message" => "\[%{TIMESTAMP_ISO8601:timestamp}\] ALL AUDIT: User \[%{GREEDYDATA:user}\] is %{GREEDYDATA:activity} \[%{GREEDYDATA:filename}\] for transfer."} 
    } 
}output{ 
    elasticsearch{ 
     hosts=>"localhost:9200" 
     index=> "logstash" 
    } 

샘플 데이터

[2017-03-05 12:37:21.465] ALL AUDIT: User [user1] is opening file [filename1] for transfer. 

있지만 난을 통해 파일을로드하고 때 filebeat> logstash> elasticsearch elasticsearch에서 오류가 발생했습니다.

org.elasticsearch.index.mapper.MapperParsingException: failed to parse [timestamp] 
Caused by: java.lang.IllegalArgumentException: Invalid format: "2017-03-05T12:36:33.606" is malformed at "12:36:33.606" 
    at org.joda.time.format.DateTimeParserBucket.doParseMillis(DateTimeParserBucket.java:187) ~[joda-time-2.9.5.jar:2.9.5] 

구성해야 할 타임 스탬프 형식을 알려주십시오. 당신의 타임 스탬프 매핑에서

+0

: "YYYY-MM-DD'T'HH:mm:ss.SSS"

(자본 T 통지) 자세한 내용은 설명서를 참조하십시오 확인란. 그것은 Stackoverflow에 대답하지 않은 질문에 초점을 유지하는 데 도움이됩니다. – Adonis

답변

2

당신이 비트를 통해 보내는 형식이 동일하지 않습니다 여기에 "format": "YYYY-MM-DD HH:mm:ss.SSS" 등의 형식을 나타냅니다 확인 : 탄성이 형식에 대해 불평 이유 2017-03-05T12:36:33.606

합니다. 귀하의 형식은 다음과 같아야합니다 내 대답은 문제를 해결하는 경우, 당신은 큰를 사용하여 대답으로 동의 할 수있는 방법으로 https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html

+0

@asettouf에게 답장을 보내 주셔서 감사합니다. 날짜 - 시간 패턴을 joda 형식으로 변경 한 후 해결 된 문제 - \t "형식": "yyyy-MM-dd HH : mm : ss.SSS" – niting

관련 문제