summaryrefslogtreecommitdiffstats
path: root/pkg/config/history_retention.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/config/history_retention.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/pkg/config/history_retention.go b/pkg/config/history_retention.go
new file mode 100644
index 0000000..d4373b7
--- /dev/null
+++ b/pkg/config/history_retention.go
@@ -0,0 +1,30 @@
+package config
+
+import (
+ "github.com/icinga/icingadb/pkg/icingadb/history"
+ "github.com/pkg/errors"
+ "time"
+)
+
+// Retention defines configuration for history retention.
+type Retention struct {
+ HistoryDays uint64 `yaml:"history-days"`
+ SlaDays uint64 `yaml:"sla-days"`
+ Interval time.Duration `yaml:"interval" default:"1h"`
+ Count uint64 `yaml:"count" default:"5000"`
+ Options history.RetentionOptions `yaml:"options"`
+}
+
+// Validate checks constraints in the supplied retention configuration and
+// returns an error if they are violated.
+func (r *Retention) Validate() error {
+ if r.Interval <= 0 {
+ return errors.New("retention interval must be positive")
+ }
+
+ if r.Count == 0 {
+ return errors.New("count must be greater than zero")
+ }
+
+ return r.Options.Validate()
+}