d3vilh/openvpn_exporter

By d3vilh

Updated almost 3 years ago

Fast OpenVPN Exporter for v2 and v3 status files

Image
Networking
Security
Monitoring & observability
0

2.1K

d3vilh/openvpn_exporter repository overview

Prometheus OpenVPN exporter

This repository provides code for a simple Prometheus metrics exporter for OpenVPN. Right now it can parse files generated by OpenVPN's --status, having one of the following formats:

  • Client statistics,
  • Server statistics with --status-version 2 (comma delimited),
  • Server statistics with --status-version 3 (tab delimited).

As it is not uncommon to run multiple instances of OpenVPN on a single system (e.g., multiple servers, multiple clients or a mixture of both), this exporter can be configured to scrape and export the status of multiple status files, using the -openvpn.status_paths command line flag. Paths need to be comma separated. Metrics for all status files are exported over TCP port 9176.

Please refer here for a full list of supported command line flags.

Run in Docker

To run latest openvpn_exporter image from docker hub:

docker run --interactive --tty --rm -v /home/philipp/openvpn-server/log:/etc/openvpn/log -e OVPN_STATUS_FILE=/etc/openvpn/log/openvpn-status.log -p 9176:9176/tcp --privileged d3vilh/openvpn_exporter:latest

With Docker compose:

version: "3.5"

services:
    openvpn_exporter:
       container_name: openvpn_exporter
       image: d3vilh/openvpn_exporter:latest
       environment:
           - OVPN_STATUS_FILE=/etc/openvpn/log/openvpn-status.log
       privileged: true
       ports:
           - "9176:9176/tcp"
       volumes:
           - /etc/openvpn/log:/etc/openvpn/log
       restart: always

Exposed metrics example

Client statistics

For clients status files, the exporter generates metrics that may look like this:

openvpn_client_auth_read_bytes_total{status_path="..."} 3.08854782e+08
openvpn_client_post_compress_bytes_total{status_path="..."} 4.5446864e+07
openvpn_client_post_decompress_bytes_total{status_path="..."} 2.16965355e+08
openvpn_client_pre_compress_bytes_total{status_path="..."} 4.538819e+07
openvpn_client_pre_decompress_bytes_total{status_path="..."} 1.62596168e+08
openvpn_client_tcp_udp_read_bytes_total{status_path="..."} 2.92806201e+08
openvpn_client_tcp_udp_write_bytes_total{status_path="..."} 1.97558969e+08
openvpn_client_tun_tap_read_bytes_total{status_path="..."} 1.53789941e+08
openvpn_client_tun_tap_write_bytes_total{status_path="..."} 3.08764078e+08
openvpn_status_update_time_seconds{status_path="..."} 1.490092749e+09
openvpn_up{status_path="..."} 1
Server statistics

For server status files (both version 2 and 3), the exporter generates metrics that may look like this:

openvpn_server_client_received_bytes_total{common_name="...",connection_time="...",real_address="...",status_path="...",username="...",virtual_address="..."} 139583
openvpn_server_client_sent_bytes_total{common_name="...",connection_time="...",real_address="...",status_path="...",username="...",virtual_address="..."} 710764
openvpn_server_route_last_reference_time_seconds{common_name="...",real_address="...",status_path="...",virtual_address="..."} 1.493018841e+09
openvpn_status_update_time_seconds{status_path="..."} 1.490089154e+09
openvpn_up{status_path="..."} 1
openvpn_server_connected_clients 1

Usage

Usage of openvpn_exporter:

  -openvpn.status_paths string
    	Paths at which OpenVPN places its status files. (default "examples/client.status,examples/server2.status,examples/server3.status")
  -web.listen-address string
    	Address to listen on for web interface and telemetry. (default ":9176")
  -web.telemetry-path string
    	Path under which to expose metrics. (default "/metrics")
  -ignore.individuals bool
        If ignoring metrics for individuals (default false)

E.g:

openvpn_exporter -openvpn.status_paths /etc/openvpn/log/openvpn-status.log

Metrics should be available at http://localhost:9176/metrics.

Build new binary

To build new binary run:

go build -o openvpn_exporter main.go
Build new Docker Image

To build the container locally:

docker build --force-rm=true -t local/openvpn_exporter .
Run new Docker Image

Run container locally:

docker run --interactive --tty --rm -v /etc/openvpn/log:/etc/openvpn/log -e OVPN_STATUS_FILE=/etc/openvpn/log/openvpn-status.log -p 9176:9176/tcp --privileged local/openvpn_exporter:latest

Buy Me A Coffee

Tag summary

Content type

Image

Digest

sha256:d5514c3f3

Size

9.6 MB

Last updated

almost 3 years ago

docker pull d3vilh/openvpn_exporter