-
Notifications
You must be signed in to change notification settings - Fork 0
/
fluent.conf
80 lines (75 loc) · 2.88 KB
/
fluent.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Input and parse HAProxy syslog.
<source>
@type syslog
tag haproxy
port 514
bind 0.0.0.0
<parse>
@type regexp
# Matches HAProxy 1.8 rfc5424 HTTP logs, with a catch-all for other log types.
expression /^(?<syslog_id>\<\d{1,5}\>)?\d{1,2} (?<syslog_time>[^ ]+) (?<syslog_host>[^ ]+) (?<ps>\w+) (?<pid>\d+) ([^ ]+) ((\[(.*)\]|[^ ])) ((?<client_ip>[\w\.]+):(?<client_port>\d+) \[(?<req_date>.+)\] (?<frontend>[\w\~-]+) (?<backend>[\w-]+)\/(?<backend_server>[^ ]+) (?<tr_receive_time>[^\/]+)\/(?<tw_queue_time>[^\/]+)\/(?<tc_connect_time>[^\/]+)\/(?<tr_resp_time>[^\/]+)\/(?<ta_active_time>[^\/]+) (?<status_code>\d+) (?<bytes_read>\d+) (?<req_cookie>[^ ]+) (?<res_cookie>[^ ]+) (?<term_state>[\w-]+) (?<actconn>\d+)\/(?<feconn>\d+)\/(?<beconn>\d+)\/(?<srv_conn>\d+)\/(?<retries>\d+) (?<srv_queue>\d+)\/(?<backend_queue>\d+) \{?(?<req_headers>[^}]*)\}? ?\{?(?<res_headers>[^}]*)\}? ?"(?<request>(?<method>[A-Z]+)\s(?<url>[^?\s]+)[^"]*)"|(?<message>.+))/
types actconn:integer,backend:string,backend_queue:integer,beconn:integer,backend_server:string,bytes_read:integer,client_ip:string,client_port:integer,feconn:integer,frontend:string,message:string,pid:integer,ps:string,req_date:string,req_headers:string,req_cookie:string,request:string,res_headers:string,retries:string,res_cookie:string,srv_conn:integer,srv_queue:integer,status_code:integer,syslog_time:string,term_state:string,tc_connect_time:integer,tr_resp_time:integer,tr_receive_time:integer,ta_active_time:integer,tw_queue_time:integer
</parse>
</source>
# Setup the Prometheus plugin.
<source>
@type prometheus
bind 0.0.0.0
port 24231
metrics_path /metrics
</source>
# Tag our log types.
<match haproxy.local0.**>
@type rewrite_tag_filter
<rule>
key frontend
pattern .
tag haproxy.http
</rule>
<rule>
key message
pattern .
tag haproxy.general
</rule>
</match>
# Following Prometheus best practice by converting to base unit.
<filter haproxy.http>
@type record_modifier
enable_ruby
<record>
ta_active_time_seconds ${record["ta_active_time"].to_f / 1000}
</record>
</filter>
# Create the histogram.
<filter haproxy.http>
@type prometheus
<metric>
name http_requests_total
type counter
desc A count of the requests.
<labels>
tag ${tag}
# Could also label by backend server if desired.
backend ${backend}
status_code ${status_code}
</labels>
</metric>
<metric>
name http_request_duration_seconds
type histogram
desc A histogram of the request duration.
key ta_active_time_seconds
# Buckets chosen in mind of relevant SLO.
buckets 0.1, 0.5, 1, 2.5, 5, 10, 30, 60, 120, 180, 240, 300
<labels>
tag ${tag}
# Could also label by backend server if desired.
backend ${backend}
status_code ${status_code}
method ${method}
</labels>
</metric>
</filter>
<match **>
@type stdout
</match>