Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions roles/prometheus/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ prometheus_storage_retention: "30d"
# [EXPERIMENTAL] Maximum number of bytes that can be stored for blocks. Units
# supported: KB, MB, GB, TB, PB.
prometheus_storage_retention_size: "0"
# Available since Prometheus 3.11.0
# [EXPERIMENTAL] Maximum percentage of total disk space allowed for block
# storage. Set to 0 to disable percentage-based retention.
prometheus_storage_retention_percentage: "0"

# The Agent mode optimizes Prometheus for the remote write use case: https://prometheus.io/blog/2021/11/16/agent/
prometheus_agent_mode: false
Expand Down
6 changes: 6 additions & 0 deletions roles/prometheus/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ argument_specs:
- "Maximum number of bytes that can be stored for blocks."
- "Units supported: KB, MB, GB, TB, PB."
default: "0"
prometheus_storage_retention_percentage:
description:
- "Maximum percent of total disk space allowed for block storage"
- "Set to 0 to disable percentage-based retention"
- "Supported only on Prometheus >= 3.11.0"
default: "0"
prometheus_agent_mode:
description:
- "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. L(Everything,https://prometheus.io/docs/prometheus/latest/feature_flags/#prometheus-agent) else stays the same."
Expand Down
4 changes: 2 additions & 2 deletions roles/prometheus/molecule/alternative/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ provisioner:
- /etc
prometheus_storage_retention: "60d"
prometheus_storage_retention_size: "1GB"
prometheus_storage_retention_percentage: 70
prometheus_config_flags_extra:
alertmanager.timeout: 10s
web.enable-admin-api:
enable-feature:
- promql-at-modifier
Expand Down Expand Up @@ -88,7 +88,7 @@ provisioner:
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9115 # Blackbox exporter.
prometheus_version: 2.25.2
prometheus_version: 3.13.0
prometheus_stop_timeout: 1min
prometheus_binary_url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version\
\ }}/prometheus-{{ prometheus_version }}.linux-amd64.tar.gz"
4 changes: 4 additions & 0 deletions roles/prometheus/templates/prometheus.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ ExecReload=/bin/kill -HUP $MAINPID
ExecStart={{ prometheus_binary_install_dir }}/prometheus \
{% if not prometheus_agent_mode %}
--storage.tsdb.path={{ prometheus_db_dir }} \
Comment thread
rjhenry marked this conversation as resolved.
{# If using Prometheus 3.11 or newer, don't set the TSDB retention flags at #}
{# all, instead use the config file. #}
{% if prometheus_version is version('3.11.0', '<') %}
Comment thread
rjhenry marked this conversation as resolved.
{% if prometheus_version is version('2.7.0', '>=') %}
--storage.tsdb.retention.time={{ prometheus_storage_retention }} \
--storage.tsdb.retention.size={{ prometheus_storage_retention_size }} \
{% else %}
--storage.tsdb.retention={{ prometheus_storage_retention }} \
{% endif %}
{% endif %}
{% else %}
{% if prometheus_version is version('3.0.0', '>=') %}
--agent \
Expand Down
9 changes: 9 additions & 0 deletions roles/prometheus/templates/prometheus.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ global:
external_labels:
{{ prometheus_external_labels | to_nice_yaml(indent=2,sort_keys=False) | indent(4, False) }}

{% if prometheus_version is version('3.11.0', '>=') %}
storage:
tsdb:
retention:
time: {{ prometheus_storage_retention }}
size: {{ prometheus_storage_retention_size }}
percentage: {{ prometheus_storage_retention_percentage }}
{% endif %}

{% if prometheus_remote_write != [] %}
remote_write:
{{ prometheus_remote_write | to_nice_yaml(indent=2,sort_keys=False) | indent(2, False) }}
Expand Down
Loading