Skip to main content
All command-line options can be configured using environment variables. Environment variables use the QE_ prefix followed by the option name in uppercase.

Environment Variable Prefix

All query-exporter environment variables use the QE_ prefix. This prefix is defined in the source code:
envvar_prefix = "QE"

Configuration File Loading

QE_DOTENV
path
default:"$PWD/.env"
Path to the dotenv file where environment variables can be defined. This is particularly useful when running query-exporter in Docker or other containerized environments.Note: This environment variable does not have a command-line equivalent.Example:
export QE_DOTENV=/etc/query-exporter/.env
query-exporter

Available Environment Variables

Core Configuration

QE_CONFIG
path
default:"config.yaml"
Configuration file path(s). Multiple files can be specified by providing comma-separated values or setting the variable multiple times in the environment.Command-line equivalent: --configExample:
export QE_CONFIG=/path/to/config.yaml
query-exporter
QE_CHECK_ONLY
boolean
default:"false"
Only check configuration validity without running the exporter.Command-line equivalent: --check-onlyExample:
export QE_CHECK_ONLY=true
query-exporter

Network Configuration

QE_HOST
string
default:"localhost"
Host address(es) to bind the webserver. Multiple hosts can be specified.Command-line equivalent: -H, --hostExample:
export QE_HOST=0.0.0.0
query-exporter
QE_PORT
integer
default:"9560"
Port to run the webserver on.Command-line equivalent: -p, --portExample:
export QE_PORT=8080
query-exporter
QE_METRICS_PATH
string
default:"/metrics"
Path under which Prometheus metrics are exposed.Command-line equivalent: --metrics-pathExample:
export QE_METRICS_PATH=/custom/metrics
query-exporter

Logging Configuration

QE_LOG_LEVEL
string
default:"info"
Minimum level for log messages. Valid values: critical, error, warning, info, debug.Command-line equivalent: -L, --log-levelExample:
export QE_LOG_LEVEL=debug
query-exporter
QE_LOG_FORMAT
string
default:"plain"
Log output format. Valid values: plain, json.Command-line equivalent: --log-formatExample:
export QE_LOG_FORMAT=json
query-exporter

Monitoring Configuration

QE_PROCESS_STATS
boolean
default:"false"
Include process resource usage statistics in exported metrics.Command-line equivalent: --process-statsExample:
export QE_PROCESS_STATS=true
query-exporter

SSL/TLS Configuration

QE_SSL_PRIVATE_KEY
path
Full path to the SSL/TLS private key file.Command-line equivalent: --ssl-private-keyExample:
export QE_SSL_PRIVATE_KEY=/etc/ssl/private/server.key
query-exporter
QE_SSL_PUBLIC_KEY
path
Full path to the SSL/TLS public key (certificate) file.Command-line equivalent: --ssl-public-keyExample:
export QE_SSL_PUBLIC_KEY=/etc/ssl/certs/server.crt
query-exporter
QE_SSL_CA
path
Full path to the SSL/TLS certificate authority (CA) file.Command-line equivalent: --ssl-caExample:
export QE_SSL_CA=/etc/ssl/certs/ca.crt
query-exporter

Using a .env File

You can define environment variables in a .env file instead of setting them individually. By default, query-exporter looks for a .env file in the current working directory.

Example .env File

# Core configuration
QE_CONFIG=/etc/query-exporter/config.yaml
QE_PORT=9560
QE_HOST=0.0.0.0

# Logging
QE_LOG_LEVEL=info
QE_LOG_FORMAT=json

# Metrics
QE_METRICS_PATH=/metrics
QE_PROCESS_STATS=true

# SSL/TLS (optional)
# QE_SSL_PRIVATE_KEY=/etc/ssl/private/server.key
# QE_SSL_PUBLIC_KEY=/etc/ssl/certs/server.crt
# QE_SSL_CA=/etc/ssl/certs/ca.crt

Custom .env Location

If you want to use a .env file from a different location, set the QE_DOTENV environment variable:
export QE_DOTENV=/etc/query-exporter/.env
query-exporter

Docker Usage

When running query-exporter in Docker, environment variables can be passed using the -e flag or an env file:

Using -e Flag

docker run -d \
  -e QE_PORT=9560 \
  -e QE_HOST=0.0.0.0 \
  -e QE_LOG_LEVEL=debug \
  -e QE_LOG_FORMAT=json \
  -p 9560:9560 \
  -v "$CONFIG_DIR:/config" \
  adonato/query-exporter:latest

Using —env-file

docker run -d \
  --env-file /path/to/.env \
  -p 9560:9560 \
  -v "$CONFIG_DIR:/config" \
  adonato/query-exporter:latest

.env File in Volume

If a .env file is present in the mounted volume at /config, its content is automatically loaded:
docker run -d \
  -p 9560:9560 \
  -v "$CONFIG_DIR:/config" \
  adonato/query-exporter:latest
The .env file location within the container can be customized:
docker run -d \
  -e QE_DOTENV=/custom/path/.env \
  -p 9560:9560 \
  -v "$CONFIG_DIR:/custom/path" \
  adonato/query-exporter:latest

Environment Variable Reference

Environment VariableCommand-line OptionDefaultDescription
QE_HOST-H, --hostlocalhostHost addresses to bind. Multiple values can be provided.
QE_PORT-p, --port9560Port to run the webserver on.
QE_METRICS_PATH--metrics-path/metricsPath under which metrics are exposed.
QE_LOG_LEVEL-L, --log-levelinfoMinimum level for log messages level.
QE_LOG_FORMAT--log-formatplainLog output format. One of plain, json.
QE_PROCESS_STATS--process-statsfalseInclude process stats in metrics.
QE_SSL_PRIVATE_KEY--ssl-private-keyFull path to the SSL private key.
QE_SSL_PUBLIC_KEY--ssl-public-keyFull path to the SSL public key.
QE_SSL_CA--ssl-caFull path to the SSL certificate authority (CA).
QE_CHECK_ONLY--check-onlyfalseOnly check configuration, don’t run the exporter.
QE_CONFIG--configconfig.yamlConfiguration files. Multiple values can be provided.
QE_DOTENV(none)$PWD/.envPath for the dotenv file where environment variables can be provided.

Precedence

Configuration values are applied in the following order (later values override earlier ones):
  1. Default values (defined in code)
  2. Environment variables from .env file (if exists)
  3. Environment variables from shell
  4. Command-line options

Build docs developers (and LLMs) love