prometheus.prometheus.prometheus role – Installs and configures prometheus

Note

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

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_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.rules.

Alerting rules can be also provided by other files located in {{ prometheus_config_dir }}/rules/ which have *.rules 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 *.rules extension

Default: ["prometheus/rules/*.rules"]

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_local_dir

string

Allows to use local packages instead of ones distributed on github.

As parameter it takes a directory where prometheus AND promtool binaries are stored on host on which ansible is ran.

This overrides prometheus_version parameter

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 }}.linux-{{ go_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: { storage.tsdb.retention: 15d, 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_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_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_skip_install

boolean

Prometheus installation tasks gets skipped when set to true.

Choices:

  • false ← (default)

  • true

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_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_targets

dictionary

Targets which will be scraped.

prometheus_version

string

Prometheus package version. Also accepts latest as parameter.

Only prometheus 2.x is supported

Default: "2.27.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