Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

(SUP-2137) To add parameters to configure telegraf database retention policy #188

Merged
merged 1 commit into from
Oct 11, 2021
Merged
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
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
# @param telegraf_db_name
# The InfluxDB database where Telegraf metrics are stored.
#
# @param telegraf_db_retention_duration
# The retention duration for database used for Telegraf metrics. Defaults to undef.
# Specify a value to setup retention duration. Example: `4w` is 4 weeks.
# To update a new duration, set it as undef first and run puppet agent to reset. Then, specify the new value.
#
# @param http_response_timeout
# Timeout for Telegraf HTTP requests. Defaults to `5s`
#
Expand Down Expand Up @@ -203,6 +208,7 @@
String $influx_db_password,

String $telegraf_db_name,
Optional[String[1]] $telegraf_db_retention_duration = undef,
String[2] $telegraf_agent_interval,
String[2] $http_response_timeout,
String[2] $pg_query_interval,
Expand Down
13 changes: 13 additions & 0 deletions manifests/post_start_configs.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
# lint:endignore
}

if $puppet_metrics_dashboard::telegraf_db_retention_duration =~ NotUndef {
exec { "create default telegraf database retention policy":
command => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"CREATE RETENTION POLICY telegraf_default ON ${puppet_metrics_dashboard::telegraf_db_name} DURATION ${puppet_metrics_dashboard::telegraf_db_retention_duration} REPLICATION 1 DEFAULT\"",
unless => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"SHOW RETENTION POLICIES ON ${puppet_metrics_dashboard::telegraf_db_name}\" | grep -w telegraf_default",
require => Exec["create influxdb puppet_metrics database ${puppet_metrics_dashboard::telegraf_db_name}"],
}
} else {
exec { "drop existing retention policy if ever created":
command => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"DROP RETENTION POLICY telegraf_default ON ${puppet_metrics_dashboard::telegraf_db_name}\"",
onlyif => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"SHOW RETENTION POLICIES ON ${puppet_metrics_dashboard::telegraf_db_name}\" | grep -w telegraf_default",
}
}

$_uri = $puppet_metrics_dashboard::use_dashboard_ssl ? {
true => 'https',
default => 'http',
Expand Down