Skip to content

Instantly share code, notes, and snippets.

@sawanoboly
Created July 13, 2012 01:10
Show Gist options
  • Save sawanoboly/3102129 to your computer and use it in GitHub Desktop.
Save sawanoboly/3102129 to your computer and use it in GitHub Desktop.
syslog-ng setting for haproxy. Divide logs between accesslog and systeminfo.
<source>
type tail
format /(?<c_ip>[\w\.]+):(?<c_port>\d+) \[(?<a_date>.+)\] (?<f_end>[\w-]+) (?<b_end>[\w-]+)\/(?<b_server>[\w-]+) (?<tw>\d+)\/(?<tc>\d
+)\/(?<tt>\d+) (?<bytes>\d+) (?<t_state>[\w-]+) (?<actconn>\d+)\/(?<feconn>\d+)\/(?<beconn>\d+)\/(?<srv_conn>\d+)\/(?<retries>\d+) (?<
srv_queue>\d+)\/(?<backend_queue>\d+)/
time_format %d/%B/%Y:%H:%M:%S
path /var/log/haproxy/haproxy_access.log
pos_file /opt/fluentd/var/pos/haproxy_access.pos
tag haproxy.access
</source>
template t_haproxy_acc {
template("$MSG\n");
template_escape(no);
};
template t_haproxy_sys {
template("$DATE $HOST $PRIORITY $MSGHDR$MSG\n");
template_escape(no);
};
destination t_haproxy_acc {
file(
"/var/log/haproxy/haproxy_access.log",
template(t_haproxy_acc));
};
destination t_haproxy_sys {
file(
"/var/log/haproxy/haproxy_system.log",
template(t_haproxy_sys));
};
filter f_haproxy_acc {
program(haproxy) and level(info);
};
filter f_haproxy_sys {
program(haproxy) and not level(info);
};
log { source(s_src); filter(f_haproxy_acc); destination(t_haproxy_acc); };
log { source(s_src); filter(f_haproxy_sys); destination(t_haproxy_sys); };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment