Skip to content

Files

Latest commit

Jul 31, 2020
df2efce · Jul 31, 2020

History

History
57 lines (50 loc) · 2.15 KB

README.md

File metadata and controls

57 lines (50 loc) · 2.15 KB

fancy let's you fanout rsyslog to Loki and is meant to be executed by rsyslog under omprog

Usage

➜  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

Setup

  1. Download fancy from releases or compile it from sources (go build .)
  2. Make fancy executable using chmod +x fancy.
  3. Move fancy to /opt with mv fancy /opt/.
  4. 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"
        )
  1. Make sure you have set the right Loki URL.
  2. Restart rsyslog using systemctl restart rsyslog.
  3. Profit.