Query Exporter is available as a Docker image from Docker Hub, making it easy to deploy in containerized environments.
Official Docker Image
The official Docker image is available at adonato/query-exporter on Docker Hub.
Supported Databases
The Docker image includes drivers for the following databases:
- PostgreSQL (
postgresql://)
- MySQL (
mysql://)
- SQLite (
sqlite://)
- Microsoft SQL Server (
mssql+pymssql://)
- IBM DB2 (
db2://) - x86_64 architecture only
- Oracle (
oracle+oracledb://)
- ClickHouse (
clickhouse+native://)
- Teradata (
teradatasql://)
Running the Container
Prepare your configuration directory
Create a directory containing your config.yaml file:mkdir -p /path/to/config
# Create or copy your config.yaml to this directory
Run the container
Use the following command to run Query Exporter:docker run --rm -it -p 9560:9560/tcp -v "/path/to/config:/config" adonato/query-exporter:latest
Replace /path/to/config with the absolute path to your configuration directory. Access the metrics endpoint
The metrics endpoint will be available at:http://localhost:9560/metrics
Docker Run Options
Basic Configuration
docker run --rm -it \
-p 9560:9560/tcp \
-v "$CONFIG_DIR:/config" \
adonato/query-exporter:latest
With Volume Name
Instead of a directory path, you can use a named Docker volume:
docker run --rm -it \
-p 9560:9560/tcp \
-v query-exporter-config:/config \
adonato/query-exporter:latest
With Environment Variables
docker run --rm -it \
-p 9560:9560/tcp \
-v "$CONFIG_DIR:/config" \
-e QE_LOG_LEVEL=debug \
-e QE_PORT=9560 \
-e QE_PROCESS_STATS=true \
adonato/query-exporter:latest
With Custom Configuration File
docker run --rm -it \
-p 9560:9560/tcp \
-v "$CONFIG_DIR:/config" \
-e QE_CONFIG=/config/custom-config.yaml \
adonato/query-exporter:latest
Environment Variables
The following environment variables can be used to configure Query Exporter:
| Variable | Default | Description |
|---|
QE_HOST | 0.0.0.0 | Host address to bind (IPv4 only by default) |
QE_PORT | 9560 | Port for the webserver |
QE_METRICS_PATH | /metrics | Path for metrics endpoint |
QE_LOG_LEVEL | info | Log level: critical, error, warning, info, debug |
QE_LOG_FORMAT | plain | Log format: plain, json |
QE_PROCESS_STATS | false | Include process stats in metrics |
QE_CONFIG | config.yaml | Configuration file path |
QE_DOTENV | $PWD/.env | Path to dotenv file |
Using .env File
You can create a .env file in your configuration directory to set environment variables:
Create .env file
Create a .env file in your config directory:# .env
QE_LOG_LEVEL=debug
QE_PROCESS_STATS=true
QE_METRICS_PATH=/metrics
Run the container
The .env file will be automatically loaded if present in the /config volume:docker run --rm -it \
-p 9560:9560/tcp \
-v "$CONFIG_DIR:/config" \
adonato/query-exporter:latest
Custom .env File Location
To use a custom location for the .env file:
docker run --rm -it \
-p 9560:9560/tcp \
-v "$CONFIG_DIR:/config" \
-e QE_DOTENV=/config/.env.production \
adonato/query-exporter:latest
Base Image Variant
A base image variant is available that contains only Query Exporter without additional database drivers. This is useful for creating custom images with only the drivers you need.
Using the Base Image
Create a custom Dockerfile:
FROM adonato/query-exporter:<version>-base
# Install only the database drivers you need
RUN apt-get update && apt-get install -y \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*
RUN /virtualenv/bin/pip install psycopg2-binary
Build and run your custom image:
docker build -t my-query-exporter .
docker run --rm -it -p 9560:9560/tcp -v "$CONFIG_DIR:/config" my-query-exporter
Development Builds
Automated builds from the main branch are available on GitHub Container Registry:
docker pull ghcr.io/albertodonato/query-exporter:main
GHCR images are periodically cleaned up and shouldn’t be used for production. They’re meant for testing unreleased features.
Volume Mounting
The container expects configuration at /config and sets this as the working directory.
Configuration Directory Structure
config/
├── config.yaml # Main configuration file (required)
└── .env # Environment variables (optional)
Example with Multiple Files
docker run --rm -it \
-p 9560:9560/tcp \
-v "$CONFIG_DIR:/config" \
-v "$CERTS_DIR:/certs:ro" \
-e QE_SSL_PRIVATE_KEY=/certs/private.key \
-e QE_SSL_PUBLIC_KEY=/certs/public.crt \
-e QE_SSL_CA=/certs/ca.crt \
adonato/query-exporter:latest
Docker Compose
Example docker-compose.yml file:
version: '3.8'
services:
query-exporter:
image: adonato/query-exporter:latest
ports:
- "9560:9560"
volumes:
- ./config:/config
environment:
- QE_LOG_LEVEL=info
- QE_PROCESS_STATS=true
restart: unless-stopped
Run with: