2016-09-24 6 views
0

logstashログファイルは言う:フィールドタイプが以前と同じで変更されていないときに、Log-stashの解析に失敗したのはなぜですか?

"tags"=>["_grokparsefailure"]}, "status_code"]}>, @data={"@version"=>"1", "@timestamp"=>"2016-09-24T08:00:54.894Z", "path"=>"/var/log/nginx/access.log", "host"=>"sample-com", "remote_addr"=>"127.0.0.1", "remote_user"=>"-", "date"=>"05/Sep/2016:10:03:01 +0000", "method"=>"GET", "uri_path"=>"/accounts", "version"=>"HTTP/1.1", "status_code"=>"200", "body_byte_sent"=>419, "referer"=>"-", "user_agent"=>"python-requests/2.4.3 CPython/2.7.9 Linux/3.16.0-4-amd64", "request_time"=>6.161, "auth_type"=>"Bearer", "client_id"=>"beta", 
"web_client_ip"=>"172.*.131.177", "response_json"=>{"_links"=>{"applications"=>{"href"=>"/applications"}, "menus"=>{"href"=>"/menus"}, "messages"=>{"href"=>"/messages"}, "numbers"=>{"href"=>"/numbers"}, "self"=>{"href"=>"/accounts"}}, "account_status"=>"active", "creation_date"=>"2016-06-07 09:25:18", "credit"=>{"balance"=>#<BigDecimal:367dbf49,'0.19819267E4',8(12)>, "currency"=>"usd"}, "email"=>"*@gmail.com",  
"id"=>"677756yt7557", "lastname"=>"Qurbani", "name"=>"M", "notifications"=>{"black_list"=>{"uids"=>[]}, "settings"=>{"email"=>{"low_credit"=>true, "new_feature"=>true, "receive_f"=>true, "send_f"=>true, "voice"=>true}, "language"=>"en", "push_notif"=>{"low_credit"=>true, "new_feature"=>true, "receive_f"=>true, "send_f"=>true, "voice"=>true}, "sms"=>{"low_credit"=>true, "new_feature"=>true, "receive_f"=>true, "send_f"=>true, "voice"=>true}}}, "phone"=>"+9****", "status"=>"inactive", "verification_status"=>{"email"=>"unverified", "phone"=>"verified"}}, "request_json"=>{}, "tags"=>["_grokparsefailure"]}, @metadata_accessors=#<LogStash::Util::Accessors:0x6ec6acbe @store={"path"=>"/var/log/nginx/access.log"}, @lut={"[path]"=>[{"path"=>"/var/log/nginx/access.log"}, "path"]}>, 
@cancelled=false>], :response=>{"create"=>{"_index"=>"logstash-api-2016.09.24", "_type"=>"logs", "_id"=>"AVdbNisZCijYhuqEamFy", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", 

"reason"=>"failed to parse [response_json.credit]", "caused_by"=>{"type"=>"illegal_argument_exception", "reason"=>"unknown property [balance]"}}}}, :level=>:warn} 

ここで私はクレジットセクションで、以下のようなログを持っている:

"credit": {"balance": 0.0, "currency": "usd"} 

私はElasticsearchからすべてのインデックスを削除している、と私はどの.sincedb*が見つかりませんでしたhomeまたは他の場所でlogstash DBを削除してください。

実際にbalanceの値に変更がない場合にこのエラーが発生するのはなぜですか?その理由は何ですか?

  • 再起動後、Logstashログファイルのデータは集計されません。

私は/var/lib/logstash/からすべてのsince_dbs_*を削除し、Logstash構成の最初の位置からテーリング開始すると述べました。

は今、以下のエラーが発生します

object mapping for [response_json.credit] tried to parse field [credit] as object, but found a concrete value 

時々クレジットが、時には2つのフィールドを持つオブジェクトとしてスカラー値として送信されているようです!


EDIT1:異なるデータと

2別のクレジットフィールドはElasticsearchに1つのクレジットに掲載されています。だから私は、これらのフィールドの名前を変更し、logstashで両方のconfigsからの信用を削除しようとしたので、今の私がありますので、エラーが再び起こる

add_field => {"first_credit" => "%{[response_json.credit]}"} 
remove_field => ["response_json.credit"] 

新しいフィールドが追加されますが、値は文字通り%{[response_json.credit]}で、フィールドが削除されません。私は信用の価値を得て、それを最初の信用の中に入れ、信用そのものを取り除きたいと思う。私も以下を試しました:

add_field => {"first_credit" => "%{[response_json][credit]}"} 
remove_field => ["response_json.credit"] 

私は間違っていますか?


EDIT:2
私は1つのファイルaccess.logが異なる値でcreditフィールドを持っていることに気づきました。 creditcreditは、数値です。は、数値です。
creditは、JSON:{"currency": "usd"、 "balance":2です。99}

を私は問題を解決し、ESstringとしてそれらすべてを保存するには、以下のlogstashコンフィギュレーションを使用:

if ([response_json][credit]) { 
     mutate { 
      add_field => {"new_credit" => "%{[response_json][credit]}"} 
      remove_field => [ "[response_json][credit]" ] 
     } 
    } 

それは以下のエラー与える:あなたを見てから

"new_credit"=>"{\"balance\":3.102,\"currency\":\"usd\"}", "tags"=>["_grokparsefailure"]}, 

@metadata_accessors=#<LogStash::Util::Accessors:0x46761362 @store={"path"=>"/var/log/nginx/access.log.1"}, 

@lut={"[path]"=>[{"path"=>"/var/log/nginx/access.log.1"}, "path"]}>, 

@cancelled=false>], :response=>{"create"=>{"_index"=>"logstash-api-2016.09.27", "_type"=>"logs", "_id"=>"AVdqrION3CJVjhZgZcnl", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", 

     "reason"=>"failed to parse [new_credit]", "caused_by"=>{"type"=>"number_format_exception", "reason"=>"For input string: \"{\"balance\":3.102,\"currency\":\"usd\"}\""}}}}, :level=>:warn 
+0

設定は何ですか? – alpert

+0

Elasticsearchにインデックスマッピングを投稿できますか? :9200/logstash-api-2016.09.24/_mapping – fylie

+0

これは大きなマッピングです。私はクレジットに関するセクションをコメントしました。 – ALH

答えて

0

をログ、"credit"=>{"balance"=>#<BigDecimal:367dbf49,'0.19819267E4',8(12)>,私はthis issueと関連しているかもしれないと思います。

インデックスのElasticsearchマッピングを{elasticsearch:ip}:9200/logstash-api-2016.09.24/_mappingにチェックすると、残高フィールドに整数マッピングがあることになります。最初に整数マッピングがあった場合、整数ではない値(たとえば、オブジェクト)は失敗します。

これを解決するには、平衡をフロートとして指定するindex templateを作成します。これを行う場合は、既存のマッピングを変更できないため、古い索引を削除するか、新しい索引を作成してください。

また、バランスがログのソースに常に同じデータタイプであることを確認することもできます。

また、mutate filterを追加して、残高フィールドを目的のデータタイプに変換することもできます。

あなたのマッピングをチェックし、私の理論が正しいかどうか教えてください。 :)

EDIT: あなたはちょうど私が以前と全く同じ問題があります送信されたコードブロック - オブジェクト信用とint型クレジットが同じフィールドに保存されます。以下の例では、同じフィールドに「new_credit」というクレジット[残高](int)とクレジットを格納します。これはIntegerにマップする必要があります。

if ([response_json][credit][balance]) { 
    mutate { 
     add_field => {"new_credit" => "%{[response_json][credit][balance}"} 
     remove_field => [ "[response_json][credit]" ] 
    } 
} 
else { 
    mutate { 
     add_field => {"new_credit" => "%{[response_json][credit]}"} 
     remove_field => [ "[response_json][credit]" ] 
    } 
} 
+0

フィールドで何が起こっているのかを知るために私は木場を使いました。私はそれを見ました: 'response_json.credit:number' – ALH

+0

クレジットフィールドはオブジェクトでなければなりません。キバナでは、文字列として型を設定できます。オブジェクトはありません!どうすればよいですか? – ALH

+0

これは私がバランスのためのインデックスを見つけることができなかったwearedです!そのためのマッピングはありません。これはクレジットファイルタイプのためです。 – ALH

関連する問題