diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2023-07-12 11:24:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-12 11:24:16 +0300 |
commit | 38b38993a6547aa33a0591a7ce3e7461c197e893 (patch) | |
tree | 76d483877e6770f11f429d14a49f21af51503d39 /health | |
parent | b1bb7bd449af0567e2edabcefd325fffaea0a3fe (diff) |
Keep health log history in seconds (#15314)
* rebase
* changes queries to delete based on when
* readme changes
* no need to do migration
* wip, protect un-updated events from cleanup
* remove index on when_key
* fix query for claimed cleanup
* if set less than minimum, set minimum
* fix query
* correct config assign
Diffstat (limited to 'health')
-rw-r--r-- | health/health.c | 22 | ||||
-rw-r--r-- | health/health.h | 8 |
2 files changed, 25 insertions, 5 deletions
diff --git a/health/health.c b/health/health.c index 45a9761d84..4ae7e99974 100644 --- a/health/health.c +++ b/health/health.c @@ -22,7 +22,6 @@ char *silencers_filename; SIMPLE_PATTERN *conf_enabled_alarms = NULL; DICTIONARY *health_rrdvars; - void health_entry_flags_to_json_array(BUFFER *wb, const char *key, HEALTH_ENTRY_FLAGS flags) { buffer_json_member_add_array(wb, key); @@ -803,15 +802,28 @@ static void initialize_health(RRDHOST *host) long n = config_get_number(CONFIG_SECTION_HEALTH, "in memory max health log entries", host->health_log.max); if(n < 10) { - netdata_log_error("Host '%s': health configuration has invalid max log entries %ld. Using default %u", - rrdhost_hostname(host), - n, - host->health_log.max); + log_health("Host '%s': health configuration has invalid max log entries %ld. Using default %u", rrdhost_hostname(host), n, host->health_log.max); config_set_number(CONFIG_SECTION_HEALTH, "in memory max health log entries", (long)host->health_log.max); } else host->health_log.max = (unsigned int)n; + uint32_t m = config_get_number(CONFIG_SECTION_HEALTH, "health log history", HEALTH_LOG_DEFAULT_HISTORY); + if (m < HEALTH_LOG_MINIMUM_HISTORY) { + log_health("Host '%s': health configuration has invalid health log history %u. Using minimum %d", rrdhost_hostname(host), m, HEALTH_LOG_MINIMUM_HISTORY); + config_set_number(CONFIG_SECTION_HEALTH, "health log history", HEALTH_LOG_MINIMUM_HISTORY); + m = HEALTH_LOG_MINIMUM_HISTORY; + } + + //default health log history is 5 days and not less than a day + if (host->health_log.health_log_history) { + if (host->health_log.health_log_history < HEALTH_LOG_MINIMUM_HISTORY) + host->health_log.health_log_history = HEALTH_LOG_MINIMUM_HISTORY; + } else + host->health_log.health_log_history = m; + + log_health("[%s]: Health log history is set to %u seconds (%u days)", rrdhost_hostname(host), host->health_log.health_log_history, host->health_log.health_log_history / 86400); + conf_enabled_alarms = simple_pattern_create(config_get(CONFIG_SECTION_HEALTH, "enabled alarms", "*"), NULL, SIMPLE_PATTERN_EXACT, true); diff --git a/health/health.h b/health/health.h index 74af753858..543bc56a14 100644 --- a/health/health.h +++ b/health/health.h @@ -31,6 +31,14 @@ void health_entry_flags_to_json_array(BUFFER *wb, const char *key, HEALTH_ENTRY_ #define HEALTH_LISTEN_BACKLOG 4096 #endif +#ifndef HEALTH_LOG_DEFAULT_HISTORY +#define HEALTH_LOG_DEFAULT_HISTORY 432000 +#endif + +#ifndef HEALTH_LOG_MINIMUM_HISTORY +#define HEALTH_LOG_MINIMUM_HISTORY 86400 +#endif + #define HEALTH_SILENCERS_MAX_FILE_LEN 10000 extern char *silencers_filename; |