Skip to content

Commit

Permalink
Feature/enhance icingadb retention config (#253)
Browse files Browse the repository at this point in the history
* added retention config variables

* added local tests, added testinfra test for configs

* added test for default build

* added documentation for the variables

* added changelog fragment
  • Loading branch information
mkayontour authored Jan 12, 2024
1 parent ae4e337 commit 00d0608
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
minor_changes:
- "Enhance IcingaDB retention configs #200"
- "Added tests for retention configs"
15 changes: 15 additions & 0 deletions doc/role-icingadb/role-icingadb.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ For logging, currently only the **logging level** can be set. The default is `in
|----------|------|-------------|---------|
| `icingadb_logging_level` | `fatal\|error\|warn\|info\|debug` | Defines the logging level for IcingaDB. | `info` |

### IcingaDB Retention

| Variable | Type | Description | Default |
|----------|------|-------------|---------|
|`icingadb_retention_history_days`|`number`|Number of days to retain full historical data.|By default, historical data is retained forever.|
|`icingadb_retention_sla_days`|`number`|Number of days to retain historical data for SLA reporting.|By default, it is retained forever.|
|`icingadb_retention_acknowledgement`|`number`|Number of days to retain acknowledgements|If not limited by icingadb_retention_history_days, forever|
|`icingadb_retention_comment`|`number`|Number of days to retain comments|If not limited by icingadb_retention_history_days, forever|
|`icingadb_retention_downtime`|`number`|Number of days to retain downtimes|If not limited by icingadb_retention_history_days, forever|
|`icingadb_retention_flapping`|`number`|Number of days to retain flapping events|If not limited by icingadb_retention_history_days, forever|
|`icingadb_retention_notification`|`number`|Number of days to retain notifications|If not limited by icingadb_retention_history_days, forever|
|`icingadb_retention_state`|`number`|Number of days to retain states|If not limited by icingadb_retention_history_days, forever|



### Miscellaneous

The following variables are used for the IcingaDB setup and are not directly related to the configuration of IcingaDB itself. Normally, you can rely on the defaults to work and should **not** change them unless you know what you are doing.
Expand Down
11 changes: 11 additions & 0 deletions molecule/default/host_vars/icinga-default.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# test_icingadb_retentions.py
icingadb_retention_history_days: 10
icingadb_retention_sla_days: 11
icingadb_retention_acknowledgement: 20
icingadb_retention_comment: 30
icingadb_retention_downtime: 10
icingadb_retention_state: 60
icingadb_retention_notification: 4
icingadb_retention_flapping: 2


icinga2_custom_config:
- name: icinga2_command
path: zones.d/main/commands/custom_commands.conf
Expand Down
13 changes: 13 additions & 0 deletions molecule/default/tests/integration/test_icingadb_retentions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Vars in host_vars

def test_icingadb_config(host):
i2_file = host.file("/etc/icingadb/config.yml")
assert i2_file.is_file
assert i2_file.contains(' history-days: 10')
assert i2_file.contains(' sla-days: 11')
assert i2_file.contains(' acknowledgement: 20')
assert i2_file.contains(' comment: 30')
assert i2_file.contains(' state: 60')
assert i2_file.contains(' downtime: 10')
assert i2_file.contains(' notification: 4')
assert i2_file.contains(' flapping: 2')
11 changes: 11 additions & 0 deletions molecule/local-default/host_vars/icinga-default.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# test_icingadb_retentions.py
icingadb_retention_history_days: 10
icingadb_retention_sla_days: 11
icingadb_retention_acknowledgement: 20
icingadb_retention_comment: 30
icingadb_retention_downtime: 10
icingadb_retention_state: 60
icingadb_retention_notification: 4
icingadb_retention_flapping: 2


icinga2_objects:
icinga-default:
- name: root
Expand Down
5 changes: 5 additions & 0 deletions molecule/local-default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ provisioner:
inventory:
link:
host_vars: host_vars/
verifier:
name: testinfra
options:
sudo: true
directory: tests/integration/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def test_icingadb_config(host):
i2_file = host.file("/etc/icingadb/config.yml")
assert i2_file.is_file
assert i2_file.contains(' history-days: 10')
assert i2_file.contains(' sla-days: 11')
assert i2_file.contains(' acknowledgement: 20')
assert i2_file.contains(' comment: 30')
assert i2_file.contains(' state: 60')
assert i2_file.contains(' downtime: 10')
assert i2_file.contains(' notification: 4')
assert i2_file.contains(' flapping: 2')
39 changes: 24 additions & 15 deletions roles/icingadb/templates/icingadb.ini.j2
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,28 @@ logging:
# Retention is an optional feature to limit the number of days that historical data is available,
# as no historical data is deleted by default.
retention:
# Number of days to retain full historical data. By default, historical data is retained forever.
# history-days:

# Number of days to retain historical data for SLA reporting. By default, it is retained forever.
# sla-days:

# Map of history category to number of days to retain its data in order to
# enable retention only for specific categories or to
# override the number that has been configured in history-days.
{% if icingadb_retention_history_days is defined and icingadb_retention_history_days is number %}
history-days: {{ icingadb_retention_history_days }}
{% endif %}
{% if icingadb_retention_sla_days is defined and icingadb_retention_sla_days is number %}
sla-days: {{ icingadb_retention_sla_days }}
{% endif %}
options:
# acknowledgement:
# comment:
# downtime:
# flapping:
# notification:
# state:
{% if icingadb_retention_acknowledgement is defined and icingadb_retention_acknowledgement is number %}
acknowledgement: {{ icingadb_retention_acknowledgement }}
{% endif %}
{% if icingadb_retention_comment is defined and icingadb_retention_comment is number %}
comment: {{ icingadb_retention_comment }}
{% endif %}
{% if icingadb_retention_downtime is defined and icingadb_retention_downtime is number %}
downtime: {{ icingadb_retention_downtime }}
{% endif %}
{% if icingadb_retention_flapping is defined and icingadb_retention_flapping is number %}
flapping: {{ icingadb_retention_flapping }}
{% endif %}
{% if icingadb_retention_notification is defined and icingadb_retention_notification is number %}
notification: {{ icingadb_retention_notification }}
{% endif %}
{% if icingadb_retention_state is defined and icingadb_retention_state is number %}
state: {{ icingadb_retention_state }}
{% endif %}

0 comments on commit 00d0608

Please sign in to comment.