fluent-plugin-haproxy 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/fluent/plugin/parser_haproxy.rb +69 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2e5493dc96c8b311f9f3cb665c01d8db86b89504f4899ea2173216a03183e0f2
|
4
|
+
data.tar.gz: 0ac6be10316f3825b5e4934659d5327ac1c5c7803bb2e60ea210276645e544e1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c7ff79ec7f474c1a935ca9379a8fc8153c2a2fcefd90a8a4bd60222e2ad3e91a82be8811d4f95f17777d8bafb074f4cd0289f84838925c973b8336b3cc0a3006
|
7
|
+
data.tar.gz: 81ec1c2d5a9ea0e905be2829ab13b726c41f16de137ec4e6f75fcedd533cba774ebf89c1017c66ed343036dae9a6f4f0ae7147239f08c274d917c39d3b9a3e1d
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require "fluent/plugin/parser"
|
2
|
+
require "base64"
|
3
|
+
|
4
|
+
module Fluent
|
5
|
+
module Plugin
|
6
|
+
class HaproxyParser < Parser
|
7
|
+
Plugin.register_parser("haproxy", self)
|
8
|
+
|
9
|
+
REGEXP = /^(?<time>[^ ]*\s*[^ ]* [^ ]*) (?<ps>\w+)\[(?<pid>\d+)\]: ((?<c_ip>[\w\.]+):(?<c_port>\d+) \[(?<hatime>.+)\] (?<f_end>[\w-]+)~ (?<b_end>[\w-.]+)\/(?<b_server>[\w-]+) (?<tq>\d+)\/(?<tw>\d+)\/(?<tc>\d+)\/(?<tr>\d+)\/(?<tt>\d+) (?<status_code>\d+) (?<bytes>\d+) (?<req_cookie>\S+) (?<res_cookie>\S+) (?<t_state>[\w-]+) (?<actconn>\d+)\/(?<feconn>\d+)\/(?<beconn>\d+)\/(?<srv_conn>\d+)\/(?<retries>\d+) (?<srv_queue>\d+)\/(?<backend_queue>\d+) \{?(?<req_headers>[^}]*)\}? ?\{?(?<res_headers>[^}]*)\}? ?"(?<request>[^"]*)"|(?<message>.+))/
|
10
|
+
|
11
|
+
config_param :headers, :array, default: []
|
12
|
+
|
13
|
+
def configure(conf)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse(text)
|
18
|
+
m = REGEXP.match(text)
|
19
|
+
unless m
|
20
|
+
yield nil, nil
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
r = {}
|
25
|
+
m.names.each do |name|
|
26
|
+
if value = m[name]
|
27
|
+
r[name] = value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# request
|
32
|
+
if r["request"]
|
33
|
+
request = r["request"].split(" ")
|
34
|
+
r.delete("request")
|
35
|
+
uri = request[1].split("?")
|
36
|
+
r["method"] = request[0]
|
37
|
+
r["path"] = uri[0]
|
38
|
+
r["query_string"] ||= uri[1]
|
39
|
+
r["http_version"] = request[2]
|
40
|
+
end
|
41
|
+
|
42
|
+
# headers
|
43
|
+
if r["req_headers"]
|
44
|
+
parsed_headers = r["req_headers"].split("|")
|
45
|
+
r.delete("req_headers")
|
46
|
+
parsed_headers.each_with_index do |header, index|
|
47
|
+
if @headers.empty?
|
48
|
+
r["header_#{index}"] = header
|
49
|
+
else
|
50
|
+
r[@headers[index]] = header
|
51
|
+
end
|
52
|
+
end
|
53
|
+
if r["auth"]
|
54
|
+
type = r["auth"].split(" ")[0]
|
55
|
+
cred = r["auth"].split(" ")[1]
|
56
|
+
r.delete("auth")
|
57
|
+
r["auth_type"] = type
|
58
|
+
if type == "Basic"
|
59
|
+
r["user"] = Base64.decode64(cred).split(":")[0]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
time, record = convert_values(parse_time(r), r)
|
65
|
+
yield time, record
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-haproxy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- pierreozoux
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.14.10
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.14.10
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
33
|
+
description: An haproxy log parser
|
34
|
+
email:
|
35
|
+
- pierre@ozoux.net
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- "./lib/fluent/plugin/parser_haproxy.rb"
|
41
|
+
homepage: https://github.com/libresh/fluent-plugin-haproxy
|
42
|
+
licenses:
|
43
|
+
- AGPL-3.0
|
44
|
+
metadata: {}
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 2.7.6
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: An haproxy log parser
|
65
|
+
test_files: []
|