fancy let's you fanout rsyslog
to Loki and is meant to be executed by rsyslog
under
omprog
➜ fancy git:(develop) ✗ ./fancy -h
Usage of fancy:
-cmd string
Send input msg to external command and use it's output as new msg
-loki-batch-size int
Loki will batch these bytes before sending them (default 1048576)
-loki-batch-wait int
Loki will send logs after these seconds (default 4)
-loki-chan-size int
Loki buffered channel capacity (default 10000)
-loki-labels string
Additional label value pair separated by , to send with logs. e.g env=dev,foo=bar
-loki-url string
Loki Server URL (default "http://localhost:3100")
-prom-addr string
Prometheus scrape endpoint address (default ":9090")
-prom-only
Only metrics for Prometheus will be exposed
-static-tag string
Will be used as a static label value with the name static_tag
-static-tag-filter string
Set static-tag only when msg contains this string
- Download fancy from releases or compile it from sources (
go build .
) - Make fancy executable using
chmod +x fancy
. - Move fancy to /opt with
mv fancy /opt/
. - Edit rsyslog config with
vim /etc/rsyslog.conf
.
module(load="omprog")
template(
name="LokiFormat"
type="string"
string="%timegenerated:::date-rfc3339% %syslogseverity% %hostname% %programname%%msg%\n"
)
action(
type="omprog"
name="loki"
template="LokiFormat"
binary="/opt/fancy --loki-labels environment=dev,service=fancy_example --loki-url https://your_endpoint/api/prom/push"
)
- Make sure you have set the right Loki URL.
- Restart
rsyslog
usingsystemctl restart rsyslog
. - Profit.