我有以下在Logstash和Kibana的grok调试器中工作的Grok模式。
\[%{TIMESTAMP_ISO8601:req_time}\] %{IP:client_ip} (?:%{IP:forwarded_for}|\(-\)) (?:%{QS:request}|-) %{NUMBER:response_code:int} %{WORD}:%{NUMBER:request_length:int} %{WORD}:%{NUMBER:body_bytes_sent:int} %{WORD}:(?:%{QS:http_referer}|-) %{WORD}:(?:%{QS:http_user_agent}|-) (%{WORD}:(\")?(%{NUMBER:request_time:float})(\")?)?"我试图通过PUT方法创建一个新的摄取管道,但我得到了一个包含以下内容的错误:
"type": "parse_exception",
"reason": "Failed to parse content to map",
"caused_by": {
"type": "i_o_exception",
"reason": "Unrecognized character escape '[' (code 91)\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@61326735; line: 7, column: 25]"
} 发布于 2018-07-26 07:27:32
Elasticsearch要求使用PUT方法提交的管道中使用的grok模式是正确转义的JSON,而Logstash模式使用不同的转义。
这包括前面带双反斜杠的括号(\\[)和带三反斜杠的双引号(\\\")。工作模式(在运行JSON转义工具之后)是:
\\[%{TIMESTAMP_ISO8601:req_time}\\] %{IP:client_ip} (?:%{IP:forwarded_for}|\\(-\\)) (?:%{QS:request}|-) %{NUMBER:response_code:int} %{WORD}:%{NUMBER:request_length:int} %{WORD}:%{NUMBER:body_bytes_sent:int} %{WORD}:(?:%{QS:http_referer}|-) %{WORD}:(?:%{QS:http_user_agent}|-) (%{WORD}:(\\\")?(%{NUMBER:request_time:float})(\\\")?)?https://stackoverflow.com/questions/51529009
复制相似问题