0
가치를 변환 한 후

I는 로그 I의 값을 가져 logstash 구성을add_field의 logstash JSON

input { 
beats { 
    port => "5043" 
} 
} 
filter{ 
    grok { 
     match => { "message" => "%{QS:mydata}"} 
    } 
    json { 
     source => "message" 
     target => "parsedJson" 
    } 
    mutate { 
     add_field =>{ 
     "user_id" => "%{[parsedJson.user_id]}" 
     "operation" => "%{[parsedJson][operation]}" 
     "data"=> "%{[parsedJson][operation]}" 
     } 
    } 
} 
output { 
    elasticsearch { 
     hosts => [ "localhost:9200" ] 
    } 
} 

기본적 I 시도한 많은 순열을 기록한하는 양식

"{\"user_id\":\"79\",\"timestamp\":\"2016-12-28T11:10:26Z\"‌​,\"operation\":\"ver‌​3 - Requested for recommended,verified handle information\",\"data\":\"\",\"content_id\":\"\",\"channel_id‌​\":\"\"}" 

로그인 함유했지만 elasticsearch 데이터는 아래 이미지와 같습니다. JSON에서 데이터를 가져 와서 새 값을 할당 할 수 없습니다. 도와주세요. enter image description here

답변

0

당신이 당신의 sourcejson에서와 당신의 json 필터 내에서 add_field 및 확인 mydata를 포함하려고합니다. 또한이 . 점으로 add_field 값을 분리하지 않는 것이 확인하십시오 :

json { 
    source => "mydata" 
    target => "parsedJson" 
    add_field => { 
     "user_id" => "%{[parsedJson][user_id]}}" 
     "operation" => "%{[parsedJson][operation]}}" 
     "data" => "%{[parsedJson][data]}}" 
    } 
    remove_field=>["mydata"] <-- you can ignore this if you really don't want to remove 
} 

는 희망이 도움이!

+0

난 이미 .. –

+0

작동 \t \t%을 작동하지 않습니다이 시도 아니오 {[parsedJson] [작업은]}} USER_ID \t \t% {[parsedJson] [USER_ID]}} 이 값을 구문 분석하지 않습니다지고 있지 않습니다 나는 parsedJson에서 가져온다. –

+0

@ YatenderSingh 안녕하세요, 대답을 업데이트했습니다. 'json' 필터 자체 내에 필드를 추가하려고하면 어떻게 될까요? 이 [thread] (https://discuss.elastic.co/t/accessing-field-of-json-input/56068)도보십시오. – Kulasangar