Skip to content

Instantly share code, notes, and snippets.

@ilosamart
Last active April 13, 2020 23:32
Show Gist options
  • Select an option

  • Save ilosamart/5dc5903a24802f16d6c163cee2917b59 to your computer and use it in GitHub Desktop.

Select an option

Save ilosamart/5dc5903a24802f16d6c163cee2917b59 to your computer and use it in GitHub Desktop.
Graylog2 (apache and nginx)
# Configures graylog format (GELF)
LogFormat "{ \"version\": \"1.1\", \"host\": \"%V\", \"short_message\": \"%r\", \"timestamp\": %{%s}t, \"level\": 6, \"_user_agent\": \"%{User-Agent}i\", \"_source_ip\": \"%a\", \"_duration_usec\": %D, \"_duration_sec\": %T, \"_request_size_byte\": %O, \"_http_status\": %s, \"_http_request_path\": \"%U\", \"_http_request\": \"%U%q\", \"_http_method\": \"%m\", \"_http_referer\": \"%{Referer}i\" }" graylog2_access
log_format graylog2_format '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" <msec=$msec|connection=$connection|connection_requests=$connection_requests|millis=$request_time>';
{
"extractors": [
{
"title": "Nginx fields",
"extractor_type": "json",
"converters": [],
"order": 1,
"cursor_strategy": "cut",
"source_field": "json_message",
"target_field": "",
"extractor_config": {
"list_separator": ", ",
"kv_separator": "=",
"key_prefix": "",
"key_separator": "_",
"replace_key_whitespace": false,
"key_whitespace_replacement": "_"
},
"condition_type": "none",
"condition_value": ""
},
{
"title": "Nginx to JSON",
"extractor_type": "regex",
"converters": [],
"order": 0,
"cursor_strategy": "copy",
"source_field": "message",
"target_field": "json_message",
"extractor_config": {
"regex_value": "^.*nginx: (\\{.*\\})$"
},
"condition_type": "string",
"condition_value": "nginx"
}
],
"version": "2.2.0-SNAPSHOT"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment