Skip to content

Expose Prometheus metrics with ocserv-exporter

Author: Florian Domain


This recipe provides step by step instructions on how to run and scrape ocserv-exporter from a Prometheus instance. This exporter allows to gather various metrics on ocserv (number of connected users, failed authentication attempts, etc...).

Platforms used for testing

This recipe was tested on the following platforms:

  • CentOS 8 on amd64 architecture


  • ocserv with occtl enabled (use-occtl = true in the configuration)
  • a Prometheus instance (refer to the official documentation for its installation)


This recipe assumes the reader has a basic understanding of a GNU/linux system and all commands are run from a privileged user. It is recommended to login the system using root. If not possible, execute "su root" or "sudo -s" to get highest privileges. The ocserv-exporter must run on the same system as ocserv.


  1. Download the latest release of ocserv-exporter from ocserv server:
       curl -LO
  2. Extract the archive:
       tar xvf ocserv-exporter_x.x.x_linux_amd64.tar.gz
  3. Run the exporter
       ./ocserv-exporter -listen
  4. Check that you can get the metrics from the exporter
       curl -S
  5. On the Prometheus instance, add the following block in the scrape_configs section of the configuration:
        - job_name: 'ocserv-exporter'
            scrape_interval: 30s
                - targets:
                    - x.x.x.x:8300  # The ocserv exporter's real ip:port
            metrics_path: /metrics
  6. Restart Prometheus, ocserv-exporter metrics must have been scraped and available from the UI