Prometheus exporter in syslog-ng

Last year, we published a Prometheus exporter for syslog-ng, implemented in Python. However, syslog-ng 4.9.0 will include one that runs as part of syslog-ng. Needless to say, testing and feedback are very welcome!

Before you begin

As syslog-ng 4.9.0 is not yet released, you need to run a development snapshot of syslog-ng to test this feature. You can compile syslog-ng from source, but luckily there are many other options available as well, especially if you want to run syslog-ng on Linux or FreeBSD. I collected these in a recent blog at https://www.syslog-ng.com/community/b/blog/posts/a-call-for-testing-the-upcoming-syslog-ng-releases. You also need Prometheus. I used the version available in openSUSE Leap as a package in the distribution.

Configuring syslog-ng

Append the following configuration snippet to your syslog-ng.conf or create a new .conf file under the /etc/syslog-ng/conf.d/ directory, if your syslog-ng deployment is configured to use it.

source s_prometheus_stat {
    stats-exporter(
        ip("0.0.0.0")
        port(8080)
        stat-type("stats")
        stat-query("*")
        scrape-freq-limit(1)
        single-instance(no)
    );
};

log {
    source(s_prometheus_stat);
    destination { file(/var/log/scraper.log); };
};

This will open port 8080 to serve Prometheus scrapers and log requests to a file. You can find the documentation of possible parameters at https://syslog-ng.github.io/admin-guide/060_Sources/153_stats_exporter/README

Configuring Prometheus

In my case, Prometheus is running on the same host as syslog-ng, so this is what I appended to /etc/prometheus/prometheus.yml

  - job_name: mysngexp
    # syslog-ng from localhost.
    static_configs:
      - targets: ['localhost:8080']

Testing

After reloading Prometheus and syslog-ng, I could see syslog-ng statistics on the Prometheus web interface and even create some basic graphs for its values.

What is next?

Please share your experiences with us! Reporting issues helps development, especially before a release. However, we are also very happy to hear positive feedback and learning that one of our long-requested features is actually used :-) You can do both at https://github.com/syslog-ng/syslog-ng/

-

If you have questions or comments related to syslog-ng, do not hesitate to contact us. You can reach us by email or even chat with us. For a list of possibilities, check our GitHub page under the “Community” section at https://github.com/syslog-ng/syslog-ng. On Twitter, I am available as @PCzanik, on Mastodon as @Pczanik@fosstodon.org.

Related Content