如何查询生产环境logstash报Error parsing json

痛定思痛。 2022-09-16 04:57 691阅读 0赞
1、生产环境有部分报错

信息如下:

  1. 2021-10-15T15:49:28,932][WARN ][logstash.filters.json ][main][7e17a3dc7e2c6df08ed7012ca6bfe17e3277d05d745f2c5bf55d2b01b151e25b] Error parsing json {:source=>"message", :raw=>"查询用户详情接口", :exception=>#<LogStash::Json::ParserError: Invalid UTF-8 start byte 0x9f
  2. at [Source: (byte[])"查询用户详情接口"; line: 1, column: 3]>}
  3. [2021-10-15T15:49:28,946][ERROR][logstash.outputs.elasticsearch][main][862f1cf74fcefb4312e0b0aa2e9fdf074e2e77c675e5c24e9b7a04d1054f1947] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"%{aName}-log_2021_10", :routing=>nil, :_type=>"_doc"}, #<LogStash::Event:0x6527baeb>], :response=>{"index"=>{"_index"=>"%{aName}-log_2021_10", "_type"=>"_doc", "_id"=>nil, "status"=>400, "error"=>{"type"=>"invalid_index_name_exception", "reason"=>"Invalid index name [%{aName}-log_2021_10], must be lowercase", "index_uuid"=>"_na_", "index"=>"%{aName}-log_2021_10"}}}}
  4. [2021-10-15T15:49:29,446][WARN ][logstash.filters.json ][main][52e7421840cd9e07ac4081f9b005972562be1954f89c4f4bc5e30c5c19ebae78] Error parsing json {:source=>"message", :raw=>"spAuthAttributes ==========> {\"chainCodes\":\"60d9acb97314488689b899f4495e0857,3d01cb64635b46d4955606e6b356af70,c3283b04c2ad48a09d770b5a96b96a4c,850ff333c6664138b38344a75545ce8e\",\"customLoginStyle\":\"default\",\"samlEntityID\":\"portal\",\"securityLevel\":\"1\",\"spCode\":\"portal\",\"spLocalLogoutUrl\":\"\",\"spName\":\"portal\",\"spOsType\":0,\"tokenValidPeriod\":36000,\"url\":\"https://i.gt.cn\",\"userAttr\":\"\"}", :exception=>#<LogStash::Json::ParserError: Unrecognized token 'spAuthAttributes': was expecting ('true', 'false' or 'null')
  5. at [Source: (byte[])"spAuthAttributes ==========> {"chainCodes":"60d9acb97314488689b899f4495e0857,3d01cb64635b46d4955606e6b356af70,c3283b04c2ad48a09d770b5a96b96a4c,850ff333c6664138b38344a75545ce8e","customLoginStyle":"default","samlEntityID":"portal","securityLevel":"1","spCode":"portal","spLocalLogoutUrl":"","spName":"portal","spOsType":0,"tokenValidPeriod":36000,"url":"https://i.gt.cn","userAttr":""}"; line: 1, column: 18]>}
  6. [2021-10-15T15:49:29,447][WARN ][logstash.filters.json ][main][52e7421840cd9e07ac4081f9b005972562be1954f89c4f4bc5e30c5c19ebae78] Error parsing json {:source=>"message", :raw=>"redis执行时间:{}1", :exception=>#<LogStash::Json::ParserError: Unrecognized token 'redis执行时间': was expecting ('true', 'false' or 'null')
  7. at [Source: (byte[])"redis执行时间:{}1"; line: 1, column: 21]>}

2、处理方法
这是在处理过程中有日志没有按照要进行打印,我们需要新开一个logstash把异常的日志打印出来;
配置如下:

  1. [root@k8s-master1 conf.d]# more aName1.conf
  2. input{
  3. kafka{
  4. bootstrap_servers => "10.152.17.50:9092"
  5. group_id => "gt-scs-log-new"
  6. topics => "gt-scs-log"
  7. consumer_threads => 1
  8. decorate_events => true
  9. auto_offset_reset => "latest"
  10. type => "gt-scs"
  11. }
  12. }
  13. filter {
  14. if [type] == "gt-scs" {
  15. mutate {
  16. add_field => { "types" => "%{type}"}
  17. }
  18. json {
  19. source => "message"
  20. }
  21. json {
  22. source => "message"
  23. }
  24. }
  25. }
  26. output {
  27. if [tags] {
  28. stdout {
  29. codec => "rubydebug"
  30. }
  31. }
  32. }
3、结果

在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,691人围观)

还没有评论,来说两句吧...

相关阅读