OP#188 add env file
This commit is contained in:
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@@ -4,8 +4,14 @@
|
||||
"GITEA",
|
||||
"GOMAXPROCS",
|
||||
"Iseconds",
|
||||
"PGDATABASE",
|
||||
"PGHOST",
|
||||
"PGPASSWORD",
|
||||
"PGPORT",
|
||||
"PGUSER",
|
||||
"pipefail",
|
||||
"procs",
|
||||
"readaccess",
|
||||
"reqpackage",
|
||||
"rpms",
|
||||
"sslcacert",
|
||||
|
||||
@@ -56,10 +56,28 @@ class prometheus_cd::main::files (
|
||||
content => template('prometheus_cd/prune_blocks.erb'),
|
||||
# notify Service ToDo,
|
||||
}
|
||||
file { $ps_env_file:
|
||||
ensure => file,
|
||||
owner => 'prometheus',
|
||||
group => 'prometheus',
|
||||
mode => '0750',
|
||||
selrange => s0,
|
||||
selrole => object_r,
|
||||
seltype => usr_,
|
||||
seluser => unconfined_u,
|
||||
content => template('prometheus_cd/prune.env.erb'),
|
||||
# notify Service ToDo,
|
||||
}
|
||||
}
|
||||
|
||||
if $ps_enable_pruning == false {
|
||||
file { $ps_pruning_file:
|
||||
ensure => absent,
|
||||
# notify Service ToDo,
|
||||
}
|
||||
file { $ps_env_file:
|
||||
ensure => absent,
|
||||
# notify Service ToDo,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,16 @@
|
||||
# @param [String] ps_external_url the full url for the remote write point
|
||||
# @param [Boolean] ps_enable_pruning whether to allow pruning local blocks
|
||||
# @param [String] ps_pruning_dir the directory for the pruning script
|
||||
# @param [String] ps_pruning_file the url and filename for the pruning script
|
||||
# @param [String] ps_env_file the url and filename for the env file
|
||||
# @param [String] ps_pg_host the host running the database for cold metrics
|
||||
# @param [String] ps_pg_port the port for the database for cold metrics
|
||||
# @param [String] ps_pg_db the database for cold metrics
|
||||
# @param [String] ps_pg_user the read-only user for the db for cold metrics
|
||||
# @param [String] ps_pg_pass the password for the db for cold metrics
|
||||
# @param [Boolean] ps_dry_run (true = just log, false = actually delete blocks)
|
||||
# @param [String] ps_min_age_hours Minimum block age in hours before pruning
|
||||
# @param [String] ps_grace_hours Grace period in hours to be extra safe
|
||||
##############################################################################
|
||||
class prometheus_cd::params (
|
||||
|
||||
@@ -79,6 +89,15 @@ class prometheus_cd::params (
|
||||
Boolean $ps_enable_pruning = false,
|
||||
String $ps_pruning_dir = '/opt/prometheus-prune',
|
||||
String $ps_pruning_file = "${ps_pruning_dir}/prune_prometheus_pg.sh",
|
||||
String $ps_env_file = "${ps_pruning_dir}/prune.env",
|
||||
String $ps_pg_host = 'localhost',
|
||||
String $ps_pg_port = '5432',
|
||||
String $ps_pg_db = 'prometheus',
|
||||
String $ps_pg_user = 'readaccess',
|
||||
String $ps_pg_pass = 'Changeme',
|
||||
Boolean $ps_dry_run = true,
|
||||
String $ps_min_age_hours = '4',
|
||||
String $ps_grace_hours = '1',
|
||||
|
||||
) {
|
||||
# defaults
|
||||
|
||||
20
templates/prune.env.erb
Normal file
20
templates/prune.env.erb
Normal file
@@ -0,0 +1,20 @@
|
||||
# /opt/prometheus-prune/prune.env
|
||||
|
||||
# PostgreSQL connection
|
||||
PGHOST=<%= @ps_pg_host %>
|
||||
PGPORT=<%= @ps_pg_port %>
|
||||
PGDATABASE=<%= @ps_pg_db %>
|
||||
PGUSER=<%= @ps_pg_user %>
|
||||
PGPASSWORD=<%= @ps_pg_pass %>
|
||||
|
||||
# Dry-run mode (true = just log, false = actually delete)
|
||||
DRY_RUN=<%= @ps_dry_run %>
|
||||
|
||||
# Minimum block age in hours before pruning
|
||||
MIN_AGE_HOURS=<%= @ps_min_age_hours %>
|
||||
|
||||
# Grace period in hours to be extra safe
|
||||
GRACE_HOURS=<%= @ps_grace_hours %>
|
||||
|
||||
# SQL template to check if block exists in PostgreSQL
|
||||
CHECK_SQL_TEMPLATE="SELECT 1 FROM metric_values WHERE metric_time >= to_timestamp({min}/1000.0) AND metric_time <= to_timestamp({max}/1000.0) LIMIT 1;"
|
||||
Reference in New Issue
Block a user