2016-08-01 3 views
1

Twitter에서 웹 서비스 데이터를 받고 파일에 기록하면 Logstash에 데이터를 보내야합니다. Elasticsearch에 색인이 생성됩니다. events.json에서Logstash : 트위터/페이스 북과 같은 웹 서비스를 통해받은 Json 데이터를 구문 분석하는 동안 구문 분석을 수행하지 못합니다.

input 
    { 
     file 
     { 
      path => ["/mnt/volume2/ELK_Prashant/at/events.json"] 
      codec => json 
      type => json 
     start_position => "beginning" 
      sincedb_path => "/dev/null" 
     } 
    } 
    output 
    { 
     stdout { codec => rubydebug } 
    } 

그리고 데이터와 https://dev.twitter.com/rest/reference/get/search/tweets에서 참조 할 수 있습니다 : 같은

내가 설정 아래에 이용하고 있고 그

JSON parse failure. Falling back to plain-text {:error=>#> LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a >valid value (number, String, array, object, 'true', 'false' or 'null')

로 내 logstash의 conf 파일을 제외 jsonparsefailure를주고 보인다 일부 샘플은 다음과 같습니다. events.json

[ 
{ "location": "LA, CA", 
     "follow_request_sent": null, 
     "profile_link_color": "0084B4", 
     "is_translator": false, 
     "id_str": "137238150", 
     "entities": { 
      "url": { 
      "urls": [ 
       { 
       "expanded_url": null, 
       "url": "" 
       } 
      ] 
      } 
     } 
} 
] 
+0

'events.json' 파일에서 한 줄에 개행 문자가없는 각 JSON 이벤트가 있습니까? – Val

답변

1

샘플 events.json 파일에서 logstash file 플러그인에 완전한 json 객체를 사용하고 있음이 분명하지만 플러그인은 기본적으로 각 이벤트가 단일 행으로 가정하므로 플러그인에서만 새 이벤트를 감지 할 수 있다고 가정합니다. 이벤트가 들어오고 현재 위치를 추적합니다.

그래서 입력 파일은 각 이벤트는 새 라인 문자

{"location":"LA, CA","follow_request_sent":null,"profile_link_color":"0084B4","is_translator":false,"id_str":"137238150","entities":{"url":{"urls":[{"expanded_url":null,"url":""}]}}} 
{"location":"LA, CA","follow_request_sent":null,"profile_link_color":"0084B4","is_translator":false,"id_str":"137238150","entities":{"url":{"urls":[{"expanded_url":null,"url":""}]}}} 
{"location":"LA, CA","follow_request_sent":null,"profile_link_color":"0084B4","is_translator":false,"id_str":"137238150","entities":{"url":{"urls":[{"expanded_url":null,"url":""}]}}} 

로 구분 곳, 같이해야하거나 입력 플러그인에 여러 코덱이나 필터를 사용해야합니다. 더 많은 정보는 here에서 확인할 수 있습니다.