Skip to content

Commit

Permalink
fix grafana alerting based on version
Browse files Browse the repository at this point in the history
  • Loading branch information
voidquark committed Jun 7, 2024
1 parent 6e27e58 commit 25bb117
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
7 changes: 6 additions & 1 deletion roles/grafana/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@ grafana_smtp: {}
# password:
# from_address:

# Enable grafana alerting mechanism
# Enable grafana unified alerting mechanism for grafana v11+
grafana_unified_alerting:
enabled: true

# REMOVED FROM Grafana v11+
# Enable grafana alerting mechanism for grafana v10 and below
grafana_alerting:
execute_alerts: true
# error_or_timeout: 'alerting'
Expand Down
14 changes: 14 additions & 0 deletions roles/grafana/templates/grafana.ini.j2
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ versions_to_keep = 20
enabled = true
path = {{ grafana_data_dir }}/dashboards

{% if grafana_version == 'latest' or grafana_version.split('.')[0]|int >= 11 %}
# Unified Alerting
[unified_alerting]
{% if grafana_unified_alerting != {} %}
{% for k,v in grafana_unified_alerting.items() %}
{{ k }} = {{ v }}
{% endfor %}
{% else %}
enabled = false
{% endif %}
{% endif %}

{% if grafana_version != 'latest' and grafana_version.split('.')[0]|int < 11 %}
# Alerting
[alerting]
{% if grafana_alerting != {} %}
Expand All @@ -125,6 +138,7 @@ enabled = true
{% else %}
enabled = false
{% endif %}
{% endif %}

# SMTP and email config
{% if grafana_smtp != {} %}
Expand Down

0 comments on commit 25bb117

Please sign in to comment.