10. Prometheus Exporter for QuasarDB metrics#

The Prometheus exporter is a standalone application that exposes QuasarDB metrics to Prometheus monitoring system. It connects to a QuasarDB cluster, collects metrics and serves them over HTTP in a format that Prometheus can scrape.

10.1. Installation#

The exporter is distributed as a Python package and can be installed using pip: .. code:: bash

python3 -m pip install qdb-prometheus-exporter

This will install qdb-prometheus-exporter command line tool.

10.2. Supported python versions#

The exporter works with Python version 3.9 and later. The exporter depends on the QuasarDB Python API package.

10.3. Usage#

10.3.1. Running the exporter#

10.3.1.1. Arguments#

  • --cluster: QuasarDB cluster URI. Default: qdb://127.0.0.1:2836

  • --cluster-public-key-file: Path to cluster security file for secure clusters.

  • --user-security-file: Path to user security file for secure clusters.

  • --filter-include: Optional comma-separated list of regex patterns to filter metrics. Only metrics that match at least one of the patterns will be reported.

  • --filter-exclude: Optional comma-separated list of regex patterns to filter metrics. Only metrics that contain none of the patterns will be reported.

  • --exporter-port: Port on which the Prometheus exporter will listen. Default: 9000

  • --listen-address: Address on which the Prometheus exporter will listen. Defaults to 127.0.0.1

  • --help: Show help message and exit.

10.3.1.2. Endpoints#

  • /metrics: Exposes QuasarDB metrics in Prometheus format.

  • /health: Health check endpoint. Returns HTTP 200 if the exporter is running. Note: this does not check the connection to QuasarDB cluster only the exporter status.

10.3.1.3. Insecure QuasarDB cluster configuration#

qdb-prometheus-exporter --cluster qdb://127.0.0.1:2836

10.3.1.4. Secure QuasarDB cluster configuration#

qdb-prometheus-exporter --cluster qdb://127.0.0.1:2836 --cluster-public-key-file /path/to/cluster_public_key.pem --user-security-file /path/to/user_security_file.key

10.3.2. Connecting Prometheus to the exporter#

This is an example Prometheus server configuration to connect to the exporter running on localhost:9000:

global:
    scrape_interval: 60s

scrape_configs:
  - job_name: "quasardb-cluster"
    metrics_path: /metrics
    scrape_interval: 30s
    static_configs:
      - targets: ["localhost:9000"]
        labels:
          cluster: "my-quasardb-cluster"
          service: "quasardb"

10.3.3. Gathering OS level metrics from QuasarDB server#

For gathering OS level metrics from QuasarDB server, you can install and configure node_exporter (on linux and other *nix systems) or windows_exporter (on Windows) on the same host where QuasarDB server is running. Then, you can configure Prometheus to scrape metrics from the exporter as well.

global:
    scrape_interval: 60s

scrape_configs:
  - job_name: "quasardb-cluster"
    metrics_path: /metrics
    scrape_interval: 30s
    static_configs:
      - targets: ["localhost:9000"]
        labels:
          cluster: "my-quasardb-cluster"
          service: "quasardb"
  - job_name: "quasardb-cluster-os-metrics"
    static_configs:
      - targets: ["localhost:9182"]
        labels:
          cluster: "my-quasardb-cluster"
          service: "quasardb"

10.4. Deployment#

This section explores options for deploying Prometheus Exporter for QuasarDB metrics in a production environment.

10.4.1. systemd service#

To ensure that Prometheus Exporter for QuasarDB metrics runs continuously and starts on system boot, you can set it up as a systemd service. This assumes that the Python package is installed system-wide and the qdb-prometheus-exporter command is available in /usr/local/bin/. Create a file named qdb-prometheus-exporter.service in /etc/systemd/system/ with the following content:

[Unit]
Description=Prometheus Exporter for QuasarDB metrics
After=network.target

[Service]
ExecStart=/usr/local/bin/qdb-prometheus-exporter --cluster qdb://127.0.0.1:2836
Restart=always
RestartSec=5s

[Install]
WantedBy=multi-user.target

Once the service file is created, you can enable and start the service using the following commands:

sudo systemctl enable --now qdb-prometheus-exporter

Prometheus Exporter should now be running as a background service and will automatically start on system boot. You can check the status of the service with:

sudo systemctl status qdb-prometheus-exporter