Skip to content

Instantly share code, notes, and snippets.

@GaryRogers
Created May 16, 2014 22:02
Show Gist options
  • Save GaryRogers/3e1d672a132a27b68ccd to your computer and use it in GitHub Desktop.
Save GaryRogers/3e1d672a132a27b68ccd to your computer and use it in GitHub Desktop.
Monolog Logstash Config example
input {
stdin { codec => "plain" }
}
filter {
# Pulls out fields from monolog text log. (Note, we don't send extra to our monolog)
grok {
match => [ "message", "%{MONOLOG} %{GREEDYDATA:mymessage}"]
}
json {
source => "context"
}
}
output {
stdout { codec => rubydebug }
}
@EdwardIII
Copy link

Hey, where does MONOLOG come from?

@erichnascimento
Copy link

(Monolog pattern):

# Define Monolog pattern
MONOLOG \[%{TIMESTAMP_ISO8601:timestamp}\] %{DATA:logger}.%{LOGLEVEL:level}:

Or inline:

\[%{TIMESTAMP_ISO8601:timestamp}\] %{DATA:logger}.%{LOGLEVEL:level}: %{GREEDYDATA:message}

Log input example:

[2016-03-29 10:27:03] payroll-app.request.INFO: 204 PUT /employments/1/integration/status

Event output exemple:

{
  "timestamp": [
    [
      "2016-03-29 10:27:03"
    ]
  ],
  "logger": [
    [
      "payroll-app.request"
    ]
  ],
  "level": [
    [
      "INFO"
    ]
  ],
  "message": [
    [
      "204 PUT /employments/1/integration/status"
    ]
  ]
}

@emxjay
Copy link

emxjay commented Nov 8, 2016

You need to add overwrite => [ "message" ] to set properly the message field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment