Skip to content

JSON parse error #25

@micahpotts

Description

@micahpotts

I'm having trouble with a high number of records not being indexed and I'm not sure what's causing the error. Can you help determine if it's a config on my end or an issue?

Here is my config:

# Config for logger_logstash_backend
config :logger,
  backends: [{LoggerLogstashBackend, :error_log}, :console],
  format: "$time $metadata[$level] $message\n",
  metadata: [:request_id]

config :logger, :error_log,
  host: "logstash.hostname.com",
  port: 10_001,
  level: :info,
  type: "elixir_log",
  metadata: [
    application_name: "og_v2",
    env: "prod"
  ]

Here's the input filter:

udp {
    codec => json
    port => 10001
    type => elixir_log
    queue_size => 10000
    workers => 10
  }

Here's the output filter:

}else if [type] == "elixir_log" {
      elasticsearch {
                hosts => ["elasticsearch.hostname.com:9200"]
                index => "%{[fields][application_name]}-%{+YYYY.MM.dd}"
                document_type => "doc"
    }

Here's an example of the log:

[2018-10-10T14:31:37,223][ERROR][logstash.codecs.json     ] JSON parse error, original data now in message field {:error=>#<LogStash::Json::ParserError: Unexpected character ('\' (code 92)): was expecting double-quote to start field name
 at [Source: (String)"{\"@timestamp\":\"2018-10-10T14:31:37+0000\",\"fields\":{\"application\":\"plug\",\"application_name\":\"og_v2\",\"env\":\"prod\",\"file\":\"lib/plug/logger.ex\",\"function\":\"call/2\",\"level\":\"info\",\"line\":34,\"module\":\"Elixir.Plug.Logger\",\"pid\":\"#PID<0.9798.1>\",\"request_id\":\"ha8cd41ahpu56t1905jev0a17s8k8dd3\"},\"message\":\"Sent 200 in 261\xB5s\",\"type\":\"elixir_log\"}"; line: 1, column: 3]>, :data=>"{\\\"@timestamp\\\":\\\"2018-10-10T14:31:37+0000\\\",\\\"fields\\\":{\\\"application\\\":\\\"plug\\\",\\\"application_name\\\":\\\"og_v2\\\",\\\"env\\\":\\\"prod\\\",\\\"file\\\":\\\"lib/plug/logger.ex\\\",\\\"function\\\":\\\"call/2\\\",\\\"level\\\":\\\"info\\\",\\\"line\\\":34,\\\"module\\\":\\\"Elixir.Plug.Logger\\\",\\\"pid\\\":\\\"#PID<0.9798.1>\\\",\\\"request_id\\\":\\\"ha8cd41ahpu56t1905jev0a17s8k8dd3\\\"},\\\"message\\\":\\\"Sent 200 in 261\\xB5s\\\",\\\"type\\\":\\\"elixir_log\\\"}"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions