prometheus.prometheus.prometheus role – Installs and configures prometheus

Note

This role is part of the prometheus.prometheus collection (version 0.23.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it use: ansible-galaxy collection install prometheus.prometheus.

To use it in a playbook, specify: prometheus.prometheus.prometheus.

Entry point main – Installs and configures prometheus

Synopsis

  • Prometheus monitoring system configuration and management

Parameters

Parameter

Comments

prometheus_agent_mode

boolean

The Agent mode optimizes Prometheus for the remote write use case. It disables querying, alerting, and local storage, and replaces it with a customized TSDB WAL. Everything else stays the same.

This feature is available starting from Prometheus v2.32.0.

Choices:

  • false ← (default)

  • true

prometheus_alert_relabel_configs

list / elements=string

Alert relabeling rules. This should be specified as list in yaml format.

It is compatible with the official alert_relabel_configs

prometheus_alert_rules

list / elements=dictionary

Full list of alerting rules which will be copied to {{ prometheus_config_dir }}/rules/ansible_managed.yml.

Alerting rules can be also provided by other files located in {{ prometheus_config_dir }}/rules/ which have a *.yml or *.yaml extension

Please see default values in role defaults/main.yml

prometheus_alert_rules_files

list / elements=string

List of folders where ansible will look for files containing alerting rules which will be copied to {{ prometheus_config_dir }}/rules/.

Files must have a *.yml or *.yaml extension

Default: ["prometheus/rules/*.yml", "prometheus/rules/*.yaml"]

prometheus_alertmanager_config

list / elements=string

Configuration responsible for pointing where alertmanagers are. This should be specified as list in yaml format.

It is compatible with the official alertmanager_config

prometheus_binary_install_dir

string

Advanced

Directory to install binaries

Default: "/usr/local/bin"

prometheus_binary_url

string

URL of the prometheus binaries .tar.gz file

Default: "https://github.com/{{ _prometheus_repo }}/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.{{ ansible_system | lower }}-{{ _prometheus_go_ansible_arch }}.tar.gz"

prometheus_checksums_url

string

URL of the prometheus checksums file

Default: "https://github.com/{{ _prometheus_repo }}/releases/download/v{{ prometheus_version }}/sha256sums.txt"

prometheus_config_dir

string

Path to directory with prometheus configuration

Default: "/etc/prometheus"

prometheus_config_file

string

Variable used to provide custom prometheus configuration file in form of ansible template

Default: "prometheus.yml.j2"

prometheus_config_flags_extra

dictionary

Additional configuration flags passed to prometheus binary at startup

Example: prometheus_config_flags_extra: { alertmanager.timeout: 10s }

prometheus_db_dir

string

Path to directory with prometheus database

Default: "/var/lib/prometheus"

prometheus_external_labels

dictionary

Provide map of additional labels which will be added to any time series or alerts when communicating with external systems

Default: {"environment": "{{ ansible_fqdn | default(ansible_host) | default(inventory_hostname) }}"}

prometheus_global

dictionary

Prometheus global config. It is compatible with the official configuration

Default: {"evaluation_interval": "15s", "scrape_interval": "60s", "scrape_timeout": "15s"}

prometheus_local_cache_path

string

Local path to stash the archive and its extraction

Default: "/tmp/prometheus-{{ ansible_system | lower }}-{{ _prometheus_go_ansible_arch }}/{{ prometheus_version }}"

prometheus_metrics_path

string

Prometheus external metrics path

Default: "/{{ (prometheus_web_external_url + '/metrics') | regex_replace('^(.*://)?(.*?)/') }}"

prometheus_read_only_dirs

list / elements=string

Additional paths that Prometheus is allowed to read (useful for SSL certs outside of the config directory)

prometheus_remote_read

list / elements=string

Remote read. It is compatible with the official configuration

prometheus_remote_write

list / elements=string

Remote write. Compatible with the official configuration

prometheus_scrape_config_files

list / elements=string

List of folders where ansible will look for files containing custom scrape config configuration files which will be copied to {{ prometheus_config_dir }}/scrape_configs/.

This feature is available starting from Prometheus v2.43.0.

Default: ["prometheus/scrape_configs/*.yml", "prometheus/scrape_configs/*.json"]

prometheus_scrape_configs

list / elements=dictionary

Prometheus scrape jobs provided in same format as in the official docs

Default: [{"job_name": "prometheus", "metrics_path": "{{ prometheus_metrics_path }}", "static_configs": [{"targets": ["{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:9090"]}]}, {"file_sd_configs": [{"files": ["{{ prometheus_config_dir }}/file_sd/node.yml"]}], "job_name": "node"}]

prometheus_static_targets_files

list / elements=string

List of folders where ansible will look for files containing custom static target configuration files which will be copied to {{ prometheus_config_dir }}/file_sd/.

Default: ["prometheus/targets/*.yml", "prometheus/targets/*.json"]

prometheus_stop_timeout

string

How long to wait for Prometheus to shutdown. This is passed as a systemd TimeoutStopSec time spec.

Default: "600s"

prometheus_storage_retention

string

Data retention period

Default: "30d"

prometheus_storage_retention_size

string

Data retention period by size

Maximum number of bytes that can be stored for blocks.

Units supported: KB, MB, GB, TB, PB.

Default: "0"

prometheus_system_group

string

System group for Prometheus.

Default: "prometheus"

prometheus_system_user

string

System user for Prometheus.

Default: "prometheus"

prometheus_targets

dictionary

Targets which will be scraped.

prometheus_version

string

Prometheus package version. Also accepts latest as parameter.

Prometheus >= 2.x is supported

Default: "3.0.0"

prometheus_web_config

dictionary

A Prometheus web config yaml for configuring TLS and auth.

prometheus_web_external_url

string

External address on which prometheus is available. Useful when behind reverse proxy. Ex. `http://example.org/prometheus`

prometheus_web_listen_address

string

Address on which prometheus will be listening

Default: "0.0.0.0:9090"

Authors

  • Prometheus Community