Skip to content

Commit

Permalink
Merge pull request #44 from observIQ/Apache-Http
Browse files Browse the repository at this point in the history
Create Apache HTTP Server Plugin
  • Loading branch information
ericwholt authored Aug 19, 2020
2 parents 83ad9d5 + 31c577b commit fba3af3
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions plugins/apache_http.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
version: 0.0.1
title: Apache HTTP Server
description: Log parser for Apache HTTP Server
parameters:
enable_error_log:
label: Error Logs
description: Enable to collect Apache HTTP Server error logs
type: bool
default: true
error_log_path:
label: Error Log Path
description: Path to error log file
type: string
default: "/var/log/apache2/error.log"
enable_access_log:
label: Access Logs
description: Enable to collect Apache HTTP Server access logs
type: bool
default: true
access_log_path:
label: Access Log Path
description: Path to access log file
type: string
default: "/var/log/apache2/access.log"
start_at:
label: Start At
description: Start reading file from 'beginning' or 'end'
type: enum
valid_values:
- beginning
- end
default: end

# Set Defaults
#{{$enable_error_log := default true .enable_error_log}}
#{{$error_log_path := default "/var/log/apache2/error.log" .error_log_path}}
#{{$enable_access_log := default true .enable_access_log}}
#{{$access_log_path := default "/var/log/apache2/access.log" .access_log_path}}
#{{$start_at := default "end" .start_at}}

pipeline:
#{{ if $enable_error_log }}
- id: htaccess_access_reader
type: file_input
include:
- {{ $access_log_path }}
start_at: {{ $start_at }}
labels:
log_type: 'apache_http.access'
plugin_id: {{ .id }}

- id: access_regex_parser
type: regex_parser
regex: '^(?P<remote>[^ ]*) (?P<host>[^ ]*) (?P<user>[^ ]*) \[(?P<time>[^\]]*)\] "(?P<method>\S+)(?: +(?P<path>[^\"]*?)(?: +\S*)?)?" (?P<code>[^ ]*) (?P<size>[^ ]*)(?: "(?P<referer>[^\"]*)" "(?P<agent>[^\"]*)"(?:\s+(?P<http_x_forwarded_for>[^ ]+))?)?$'
timestamp:
parse_from: time
layout: '%d/%b/%Y:%H:%M:%S %z'
output: {{ .output }}
#{{ end }}

#{{ if $enable_access_log }}
- id: htaccess_error_reader
type: file_input
include:
- {{ $error_log_path }}
start_at: {{ $start_at }}
multiline:
line_start_pattern: '\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} \[\w+\] (?P<pid>\d+).(?P<tid>\d+): '
labels:
log_type: 'apache_http.error'
plugin_id: {{ .id }}

- id: error_regex_parser
type: regex_parser
regex: '^\[(?P<time>\w+ \w+ \d{2} \d{2}:\d{2}:\d{2}\.\d+ \d+)\] \[(?P<module>\w+):(?P<log_level>\w+)\] \[pid (?P<pid>\d+):tid (?P<tid>\d+)\] (?P<error_code>[^:]+): (?P<message>.*)'
timestamp:
parse_from: time
layout: '%a %b %d %T.%s %Y'
severity:
parse_from: log_level
mapping:
critical: crit
emergency: emerg
output: {{ .output }}
#{{ end }}

0 comments on commit fba3af3

Please sign in to comment.