Skip to content

pgexporter Configuration

pgexporter configuration happens either in a limited sense through the CLI arguments, or in fullest through the configuration file pgexporter.conf.

pgexporter.conf (or any preferrable name) is a file detailing configuration of pgexporter when executed, and needs to be specified as part of the arguments passed to it in the CLI.

In this file, there is one primary section followed by any number of server sections.

Sections

The configuration file is divided into sections. Sections are written with their names like:

[section-name]
[section-name]

and beneath this are key-value pairs for various configurations.

Primary section

The primary section has the name pgexporter, and it contains configurations enlisted in the table.

PropertyDefaultUnitRequiredDescription
hostStringYesThe bind address for pgexporter
unix_socket_dirStringYesThe Unix Domain Socket location
metricsIntYesThe metrics port
metrics_pathStringNoPath to customized metrics (either a YAML file or a directory with YAML files)
metrics_cache_max_age0StringNoThe number of seconds to keep in cache a Prometheus (metrics) response. If set to zero, the caching will be disabled. Can be a string with a suffix, like 2m to indicate 2 minutes
metrics_cache_max_size256kStringNoThe maximum amount of data to keep in cache when serving Prometheus responses. Changes require restart. This parameter determines the size of memory allocated for the cache even if metrics_cache_max_age or metrics are disabled. Its value, however, is taken into account only if metrics_cache_max_age is set to a non-zero value. Supports suffixes: B (bytes), the default if omitted, K or KB (kilobytes), M or MB (megabytes), G or GB (gigabytes)
management0IntNoThe remote management port (disable = 0)
cacheonBoolNoCache connection
log_typeconsoleStringNoThe logging type (console, file, syslog)
log_levelinfoStringNoThe logging level, any of the (case insensitive) strings FATAL, ERROR, WARN, INFO and DEBUG (that can be more specific as DEBUG1 thru DEBUG5). Debug level greater than 5 will be set to DEBUG5. Not recognized values will make the log_level be INFO
log_pathpgexporter.logStringNoThe log file location. Can be a strftime(3) compatible string
log_rotation_age0StringNoThe age that will trigger a log file rotation. If expressed as a positive number, is managed as seconds. Supports suffixes: S (seconds, the default), M (minutes), H (hours), D (days), W (weeks). A value of 0 disables
log_rotation_size0StringNoThe size of the log file that will trigger a log rotation. Supports suffixes: B (bytes), the default if omitted, K or KB (kilobytes), M or MB (megabytes), G or GB (gigabytes). A value of 0 (with or without suffix) disables
log_line_prefix%Y-%m-%d %H:%M:%SStringNoA strftime(3) compatible string to use as prefix for every log line. Must be quoted if contains spaces
log_modeappendStringNoAppend to or create the log file (append, create)
blocking_timeout30IntNoThe number of seconds the process will be blocking for a connection (disable = 0)
tlsoffBoolNoEnable Transport Layer Security (TLS)
tls_cert_fileStringNoCertificate file for TLS. This file must be owned by either the user running pgexporter or root
tls_key_fileStringNoPrivate key file for TLS. This file must be owned by either the user running pgexporter or root. Additionally permissions must be at least 0640 when owned by root or 0600 otherwise.
tls_ca_fileStringNoCertificate Authority (CA) file for TLS. This file must be owned by either the user running pgexporter or root
libevautoStringNoSelect the libev backend to use. Valid options: auto, select, poll, epoll, iouring, devpoll and port
buffer_size65535IntNoThe network buffer size (SO_RCVBUF and SO_SNDBUF)
keep_aliveonBoolNoHave SO_KEEPALIVE on sockets
nodelayonBoolNoHave TCP_NODELAY on sockets
non_blockingonBoolNoHave O_NONBLOCK on sockets
backlog16IntNoThe backlog for listen(). Minimum 16
hugepagetryStringNoHuge page support (off, try, on)
pidfileStringNoPath to the PID file
update_process_titleverboseStringNoThe behavior for updating the operating system process title. Allowed settings are: never (or off), does not update the process title; strict to set the process title without overriding the existing initial process title length; minimal to set the process title to the base description; verbose (or full) to set the process title to the full description. Please note that strict and minimal are honored only on those systems that do not provide a native way to set the process title (e.g., Linux). On other systems, there is no difference between strict and minimal and the assumed behaviour is minimal even if strict is used. never and verbose are always honored, on every system. On Linux systems the process title is always trimmed to 255 characters, while on system that provide a native way to set the process title it can be longer

Server Section

Each server section can be given any unique name and it may contain configurations as listed in the table below.

PropertyDefaultUnitRequiredDescription
hostStringYesThe address of the PostgreSQL instance
portIntYesThe port of the PostgreSQL instance
userStringYesThe user name
data_dirStringNoThe location of the data directory
wal_dirStringNoThe location of the WAL directory
tls_cert_fileStringNoCertificate file for TLS. This file must be owned by either the user running pgexporter or root
tls_key_fileStringNoPrivate key file for TLS. This file must be owned by either the user running pgexporter or root. Additionally permissions must be at least 0640 when owned by root or 0600 otherwise.
tls_ca_fileStringNoCertificate Authority (CA) file for TLS. This file must be owned by either the user running pgexporter or root