diff options
author | vkalintiris <vasilis@netdata.cloud> | 2023-08-03 13:13:36 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-03 13:13:36 +0300 |
commit | 0e230a260ec7d8b4d6dc5c7165da6ab103d096b3 (patch) | |
tree | b46528e5ace00358c342ea3d571d85bda5c546ed /ml/ad_charts.cc | |
parent | 72549b3a2247f763180925d7c84b0eee8086fa14 (diff) |
Revert "Refactor RRD code. (#15423)" (#15723)
This reverts commit 440bd51e08fdfa2a4daa191fb68643456028a753.
dbengine was still being used for non-zero tiers
even on non-dbengine modes.
Diffstat (limited to 'ml/ad_charts.cc')
-rw-r--r-- | ml/ad_charts.cc | 113 |
1 files changed, 55 insertions, 58 deletions
diff --git a/ml/ad_charts.cc b/ml/ad_charts.cc index 88dbbfa66d..ca4dca1393 100644 --- a/ml/ad_charts.cc +++ b/ml/ad_charts.cc @@ -1,21 +1,18 @@ // SPDX-License-Identifier: GPL-3.0-or-later -#include "database/rrd.h" #include "ad_charts.h" -#define BUF_LEN 1024 - void ml_update_dimensions_chart(ml_host_t *host, const ml_machine_learning_stats_t &mls) { /* * Machine learning status */ if (Cfg.enable_statistics_charts) { if (!host->machine_learning_status_rs) { - char id_buf[BUF_LEN + 1]; - char name_buf[BUF_LEN + 1]; + char id_buf[1024]; + char name_buf[1024]; - snprintfz(id_buf, BUF_LEN, "machine_learning_status_on_%s", rrdb.localhost->machine_guid); - snprintfz(name_buf, BUF_LEN, "machine_learning_status_on_%s", rrdhost_hostname(rrdb.localhost)); + snprintfz(id_buf, 1024, "machine_learning_status_on_%s", localhost->machine_guid); + snprintfz(name_buf, 1024, "machine_learning_status_on_%s", rrdhost_hostname(localhost)); host->machine_learning_status_rs = rrdset_create( host->rh, @@ -29,7 +26,7 @@ void ml_update_dimensions_chart(ml_host_t *host, const ml_machine_learning_stats NETDATA_ML_PLUGIN, // plugin NETDATA_ML_MODULE_TRAINING, // module NETDATA_ML_CHART_PRIO_MACHINE_LEARNING_STATUS, // priority - rrdb.localhost->update_every, // update_every + localhost->rrd_update_every, // update_every RRDSET_TYPE_LINE // chart_type ); rrdset_flag_set(host->machine_learning_status_rs , RRDSET_FLAG_ANOMALY_DETECTION); @@ -53,11 +50,11 @@ void ml_update_dimensions_chart(ml_host_t *host, const ml_machine_learning_stats */ if (Cfg.enable_statistics_charts) { if (!host->metric_type_rs) { - char id_buf[BUF_LEN + 1]; - char name_buf[BUF_LEN + 1]; + char id_buf[1024]; + char name_buf[1024]; - snprintfz(id_buf, BUF_LEN, "metric_types_on_%s", rrdb.localhost->machine_guid); - snprintfz(name_buf, BUF_LEN, "metric_types_on_%s", rrdhost_hostname(rrdb.localhost)); + snprintfz(id_buf, 1024, "metric_types_on_%s", localhost->machine_guid); + snprintfz(name_buf, 1024, "metric_types_on_%s", rrdhost_hostname(localhost)); host->metric_type_rs = rrdset_create( host->rh, @@ -71,7 +68,7 @@ void ml_update_dimensions_chart(ml_host_t *host, const ml_machine_learning_stats NETDATA_ML_PLUGIN, // plugin NETDATA_ML_MODULE_TRAINING, // module NETDATA_ML_CHART_PRIO_METRIC_TYPES, // priority - rrdb.localhost->update_every, // update_every + localhost->rrd_update_every, // update_every RRDSET_TYPE_LINE // chart_type ); rrdset_flag_set(host->metric_type_rs, RRDSET_FLAG_ANOMALY_DETECTION); @@ -95,11 +92,11 @@ void ml_update_dimensions_chart(ml_host_t *host, const ml_machine_learning_stats */ if (Cfg.enable_statistics_charts) { if (!host->training_status_rs) { - char id_buf[BUF_LEN + 1]; - char name_buf[BUF_LEN + 1]; + char id_buf[1024]; + char name_buf[1024]; - snprintfz(id_buf, BUF_LEN, "training_status_on_%s", rrdb.localhost->machine_guid); - snprintfz(name_buf, BUF_LEN, "training_status_on_%s", rrdhost_hostname(rrdb.localhost)); + snprintfz(id_buf, 1024, "training_status_on_%s", localhost->machine_guid); + snprintfz(name_buf, 1024, "training_status_on_%s", rrdhost_hostname(localhost)); host->training_status_rs = rrdset_create( host->rh, @@ -113,7 +110,7 @@ void ml_update_dimensions_chart(ml_host_t *host, const ml_machine_learning_stats NETDATA_ML_PLUGIN, // plugin NETDATA_ML_MODULE_TRAINING, // module NETDATA_ML_CHART_PRIO_TRAINING_STATUS, // priority - rrdb.localhost->update_every, // update_every + localhost->rrd_update_every, // update_every RRDSET_TYPE_LINE // chart_type ); @@ -150,11 +147,11 @@ void ml_update_dimensions_chart(ml_host_t *host, const ml_machine_learning_stats */ { if (!host->dimensions_rs) { - char id_buf[BUF_LEN + 1]; - char name_buf[BUF_LEN + 1]; + char id_buf[1024]; + char name_buf[1024]; - snprintfz(id_buf, BUF_LEN, "dimensions_on_%s", rrdb.localhost->machine_guid); - snprintfz(name_buf, BUF_LEN, "dimensions_on_%s", rrdhost_hostname(rrdb.localhost)); + snprintfz(id_buf, 1024, "dimensions_on_%s", localhost->machine_guid); + snprintfz(name_buf, 1024, "dimensions_on_%s", rrdhost_hostname(localhost)); host->dimensions_rs = rrdset_create( host->rh, @@ -168,7 +165,7 @@ void ml_update_dimensions_chart(ml_host_t *host, const ml_machine_learning_stats NETDATA_ML_PLUGIN, // plugin NETDATA_ML_MODULE_TRAINING, // module ML_CHART_PRIO_DIMENSIONS, // priority - rrdb.localhost->update_every, // update_every + localhost->rrd_update_every, // update_every RRDSET_TYPE_LINE // chart_type ); rrdset_flag_set(host->dimensions_rs, RRDSET_FLAG_ANOMALY_DETECTION); @@ -190,11 +187,11 @@ void ml_update_dimensions_chart(ml_host_t *host, const ml_machine_learning_stats // ML running { if (!host->ml_running_rs) { - char id_buf[BUF_LEN + 1]; - char name_buf[BUF_LEN + 1]; + char id_buf[1024]; + char name_buf[1024]; - snprintfz(id_buf, BUF_LEN, "ml_running_on_%s", rrdb.localhost->machine_guid); - snprintfz(name_buf, BUF_LEN, "ml_running_on_%s", rrdhost_hostname(rrdb.localhost)); + snprintfz(id_buf, 1024, "ml_running_on_%s", localhost->machine_guid); + snprintfz(name_buf, 1024, "ml_running_on_%s", rrdhost_hostname(localhost)); host->ml_running_rs = rrdset_create( host->rh, @@ -208,7 +205,7 @@ void ml_update_dimensions_chart(ml_host_t *host, const ml_machine_learning_stats NETDATA_ML_PLUGIN, // plugin NETDATA_ML_MODULE_DETECTION, // module NETDATA_ML_CHART_RUNNING, // priority - rrdb.localhost->update_every, // update_every + localhost->rrd_update_every, // update_every RRDSET_TYPE_LINE // chart_type ); rrdset_flag_set(host->ml_running_rs, RRDSET_FLAG_ANOMALY_DETECTION); @@ -229,11 +226,11 @@ void ml_update_host_and_detection_rate_charts(ml_host_t *host, collected_number */ { if (!host->anomaly_rate_rs) { - char id_buf[BUF_LEN + 1]; - char name_buf[BUF_LEN + 1]; + char id_buf[1024]; + char name_buf[1024]; - snprintfz(id_buf, BUF_LEN, "anomaly_rate_on_%s", rrdb.localhost->machine_guid); - snprintfz(name_buf, BUF_LEN, "anomaly_rate_on_%s", rrdhost_hostname(rrdb.localhost)); + snprintfz(id_buf, 1024, "anomaly_rate_on_%s", localhost->machine_guid); + snprintfz(name_buf, 1024, "anomaly_rate_on_%s", rrdhost_hostname(localhost)); host->anomaly_rate_rs = rrdset_create( host->rh, @@ -247,7 +244,7 @@ void ml_update_host_and_detection_rate_charts(ml_host_t *host, collected_number NETDATA_ML_PLUGIN, // plugin NETDATA_ML_MODULE_DETECTION, // module ML_CHART_PRIO_ANOMALY_RATE, // priority - rrdb.localhost->update_every, // update_every + localhost->rrd_update_every, // update_every RRDSET_TYPE_LINE // chart_type ); rrdset_flag_set(host->anomaly_rate_rs, RRDSET_FLAG_ANOMALY_DETECTION); @@ -266,11 +263,11 @@ void ml_update_host_and_detection_rate_charts(ml_host_t *host, collected_number */ { if (!host->detector_events_rs) { - char id_buf[BUF_LEN + 1]; - char name_buf[BUF_LEN + 1]; + char id_buf[1024]; + char name_buf[1024]; - snprintfz(id_buf, BUF_LEN, "anomaly_detection_on_%s", rrdb.localhost->machine_guid); - snprintfz(name_buf, BUF_LEN, "anomaly_detection_on_%s", rrdhost_hostname(rrdb.localhost)); + snprintfz(id_buf, 1024, "anomaly_detection_on_%s", localhost->machine_guid); + snprintfz(name_buf, 1024, "anomaly_detection_on_%s", rrdhost_hostname(localhost)); host->detector_events_rs = rrdset_create( host->rh, @@ -284,7 +281,7 @@ void ml_update_host_and_detection_rate_charts(ml_host_t *host, collected_number NETDATA_ML_PLUGIN, // plugin NETDATA_ML_MODULE_DETECTION, // module ML_CHART_PRIO_DETECTOR_EVENTS, // priority - rrdb.localhost->update_every, // update_every + localhost->rrd_update_every, // update_every RRDSET_TYPE_LINE // chart_type ); rrdset_flag_set(host->detector_events_rs, RRDSET_FLAG_ANOMALY_DETECTION); @@ -301,7 +298,7 @@ void ml_update_host_and_detection_rate_charts(ml_host_t *host, collected_number if (host->ml_running) { ONEWAYALLOC *OWA = onewayalloc_create(0); time_t Now = now_realtime_sec(); - time_t Before = Now - host->rh->update_every; + time_t Before = Now - host->rh->rrd_update_every; time_t After = Before - Cfg.anomaly_detection_query_duration; RRDR_OPTIONS Options = static_cast<RRDR_OPTIONS>(0x00000000); @@ -356,14 +353,14 @@ void ml_update_training_statistics_chart(ml_training_thread_t *training_thread, */ { if (!training_thread->queue_stats_rs) { - char id_buf[BUF_LEN + 1]; - char name_buf[BUF_LEN + 1]; + char id_buf[1024]; + char name_buf[1024]; - snprintfz(id_buf, BUF_LEN, "training_queue_%zu_stats", training_thread->id); - snprintfz(name_buf, BUF_LEN, "training_queue_%zu_stats", training_thread->id); + snprintfz(id_buf, 1024, "training_queue_%zu_stats", training_thread->id); + snprintfz(name_buf, 1024, "training_queue_%zu_stats", training_thread->id); training_thread->queue_stats_rs = rrdset_create( - rrdb.localhost, + localhost, "netdata", // type id_buf, // id name_buf, // name @@ -374,7 +371,7 @@ void ml_update_training_statistics_chart(ml_training_thread_t *training_thread, NETDATA_ML_PLUGIN, // plugin NETDATA_ML_MODULE_TRAINING, // module NETDATA_ML_CHART_PRIO_QUEUE_STATS, // priority - rrdb.localhost->update_every, // update_every + localhost->rrd_update_every, // update_every RRDSET_TYPE_LINE// chart_type ); rrdset_flag_set(training_thread->queue_stats_rs, RRDSET_FLAG_ANOMALY_DETECTION); @@ -398,14 +395,14 @@ void ml_update_training_statistics_chart(ml_training_thread_t *training_thread, */ { if (!training_thread->training_time_stats_rs) { - char id_buf[BUF_LEN + 1]; - char name_buf[BUF_LEN + 1]; + char id_buf[1024]; + char name_buf[1024]; - snprintfz(id_buf, BUF_LEN, "training_queue_%zu_time_stats", training_thread->id); - snprintfz(name_buf, BUF_LEN, "training_queue_%zu_time_stats", training_thread->id); + snprintfz(id_buf, 1024, "training_queue_%zu_time_stats", training_thread->id); + snprintfz(name_buf, 1024, "training_queue_%zu_time_stats", training_thread->id); training_thread->training_time_stats_rs = rrdset_create( - rrdb.localhost, + localhost, "netdata", // type id_buf, // id name_buf, // name @@ -416,7 +413,7 @@ void ml_update_training_statistics_chart(ml_training_thread_t *training_thread, NETDATA_ML_PLUGIN, // plugin NETDATA_ML_MODULE_TRAINING, // module NETDATA_ML_CHART_PRIO_TRAINING_TIME_STATS, // priority - rrdb.localhost->update_every, // update_every + localhost->rrd_update_every, // update_every RRDSET_TYPE_LINE// chart_type ); rrdset_flag_set(training_thread->training_time_stats_rs, RRDSET_FLAG_ANOMALY_DETECTION); @@ -444,14 +441,14 @@ void ml_update_training_statistics_chart(ml_training_thread_t *training_thread, */ { if (!training_thread->training_results_rs) { - char id_buf[BUF_LEN + 1]; - char name_buf[BUF_LEN + 1]; + char id_buf[1024]; + char name_buf[1024]; - snprintfz(id_buf, BUF_LEN, "training_queue_%zu_results", training_thread->id); - snprintfz(name_buf, BUF_LEN, "training_queue_%zu_results", training_thread->id); + snprintfz(id_buf, 1024, "training_queue_%zu_results", training_thread->id); + snprintfz(name_buf, 1024, "training_queue_%zu_results", training_thread->id); training_thread->training_results_rs = rrdset_create( - rrdb.localhost, + localhost, "netdata", // type id_buf, // id name_buf, // name @@ -462,7 +459,7 @@ void ml_update_training_statistics_chart(ml_training_thread_t *training_thread, NETDATA_ML_PLUGIN, // plugin NETDATA_ML_MODULE_TRAINING, // module NETDATA_ML_CHART_PRIO_TRAINING_RESULTS, // priority - rrdb.localhost->update_every, // update_every + localhost->rrd_update_every, // update_every RRDSET_TYPE_LINE// chart_type ); rrdset_flag_set(training_thread->training_results_rs, RRDSET_FLAG_ANOMALY_DETECTION); @@ -511,7 +508,7 @@ void ml_update_global_statistics_charts(uint64_t models_consulted) { , NETDATA_ML_PLUGIN // plugin , NETDATA_ML_MODULE_DETECTION // module , NETDATA_ML_CHART_PRIO_MACHINE_LEARNING_STATUS // priority - , rrdb.localhost->update_every // update_every + , localhost->rrd_update_every // update_every , RRDSET_TYPE_AREA // chart_type ); |