Create ML charts on child hosts. (#14207)
When a parent runs a ML for a child, the relevant-ML charts should be created on the child host. These charts should use the parent's hostname to differentiate multiple parents that might run ML for a child. The only exception to this rule is the training/prediction resource usage charts. These are created on the localhost of the parent host, because they provide information specific to said host.
vkalintiris committed
Jan 4, 2023 at 23:05 UTC
2ca91092a96f366e3f59869393e71b4c1599a650
1 file changed
+31
-25
ml/ADCharts.cc
+31
-25
@@ -17,10 +17,11 @@ void ml::updateDimensionsChart(RRDHOST *RH, const MachineLearningStats &MLS) {
17
if (!MachineLearningStatusRS) {
18
std::stringstream IdSS, NameSS;
19
20
- IdSS << "machine_learning_status_for_" << localhost->machine_guid;
21
- NameSS << "machine_learning_status_for_" << localhost->hostname;
20
+ IdSS << "machine_learning_status_on_" << localhost->machine_guid;
21
+ NameSS << "machine_learning_status_on_" << rrdhost_hostname(localhost);
22
23
- MachineLearningStatusRS = rrdset_create_localhost(
23
+ MachineLearningStatusRS = rrdset_create(
24
+ RH,
25
"netdata", // type
26
IdSS.str().c_str(), // id
27
NameSS.str().c_str(), // name
@@ -60,10 +61,11 @@ void ml::updateDimensionsChart(RRDHOST *RH, const MachineLearningStats &MLS) {
61
if (!MetricTypesRS) {
62
std::stringstream IdSS, NameSS;
63
63
- IdSS << "metric_types_for_" << localhost->machine_guid;
64
- NameSS << "metric_types_for_" << localhost->hostname;
64
+ IdSS << "metric_types_on_" << localhost->machine_guid;
65
+ NameSS << "metric_types_on_" << rrdhost_hostname(localhost);
66
66
- MetricTypesRS = rrdset_create_localhost(
67
+ MetricTypesRS = rrdset_create(
68
+ RH,
69
"netdata", // type
70
IdSS.str().c_str(), // id
71
NameSS.str().c_str(), // name
@@ -103,10 +105,11 @@ void ml::updateDimensionsChart(RRDHOST *RH, const MachineLearningStats &MLS) {
105
if (!TrainingStatusRS) {
106
std::stringstream IdSS, NameSS;
107
106
- IdSS << "training_status_for_" << localhost->machine_guid;
107
- NameSS << "training_status_for_" << localhost->hostname;
108
+ IdSS << "training_status_on_" << localhost->machine_guid;
109
+ NameSS << "training_status_on_" << rrdhost_hostname(localhost);
110
109
- TrainingStatusRS = rrdset_create_localhost(
111
+ TrainingStatusRS = rrdset_create(
112
+ RH,
113
"netdata", // type
114
IdSS.str().c_str(), // id
115
NameSS.str().c_str(), // name
@@ -150,7 +153,7 @@ void ml::updateDimensionsChart(RRDHOST *RH, const MachineLearningStats &MLS) {
153
std::stringstream IdSS, NameSS;
154
155
IdSS << "dimensions_on_" << localhost->machine_guid;
153
- NameSS << "dimensions_on_" << localhost->hostname;
156
+ NameSS << "dimensions_on_" << rrdhost_hostname(localhost);
157
158
PredictionRS = rrdset_create(
159
RH,
@@ -189,7 +192,7 @@ void ml::updateHostAndDetectionRateCharts(RRDHOST *RH, collected_number AnomalyR
192
std::stringstream IdSS, NameSS;
193
194
IdSS << "anomaly_rate_on_" << localhost->machine_guid;
192
- NameSS << "anomaly_rate_on_" << localhost->hostname;
195
+ NameSS << "anomaly_rate_on_" << rrdhost_hostname(localhost);
196
197
HostRateRS = rrdset_create(
198
RH,
@@ -223,7 +226,7 @@ void ml::updateHostAndDetectionRateCharts(RRDHOST *RH, collected_number AnomalyR
226
std::stringstream IdSS, NameSS;
227
228
IdSS << "anomaly_detection_on_" << localhost->machine_guid;
226
- NameSS << "anomaly_detection_on_" << localhost->hostname;
229
+ NameSS << "anomaly_detection_on_" << rrdhost_hostname(localhost);
230
231
AnomalyDetectionRS = rrdset_create(
232
RH,
@@ -302,8 +305,8 @@ void ml::updateResourceUsageCharts(RRDHOST *RH, const struct rusage &PredictionR
305
if (!RS) {
306
std::stringstream IdSS, NameSS;
307
305
- IdSS << "prediction_usage_for_" << localhost->machine_guid;
306
- NameSS << "prediction_usage_for_" << localhost->hostname;
308
+ IdSS << "prediction_usage_for_" << RH->machine_guid;
309
+ NameSS << "prediction_usage_for_" << rrdhost_hostname(RH);
310
311
RS = rrdset_create_localhost(
312
"netdata", // type
@@ -343,8 +346,8 @@ void ml::updateResourceUsageCharts(RRDHOST *RH, const struct rusage &PredictionR
346
if (!RS) {
347
std::stringstream IdSS, NameSS;
348
346
- IdSS << "training_usage_for_" << localhost->machine_guid;
347
- NameSS << "training_usage_for_" << localhost->hostname;
349
+ IdSS << "training_usage_for_" << RH->machine_guid;
350
+ NameSS << "training_usage_for_" << rrdhost_hostname(RH);
351
352
RS = rrdset_create_localhost(
353
"netdata", // type
@@ -386,10 +389,11 @@ void ml::updateTrainingStatisticsChart(RRDHOST *RH, const TrainingStats &TS) {
389
if (!RS) {
390
std::stringstream IdSS, NameSS;
391
389
- IdSS << "queue_stats_for_" << localhost->machine_guid;
390
- NameSS << "queue_stats_for_" << localhost->hostname;
392
+ IdSS << "queue_stats_on_" << localhost->machine_guid;
393
+ NameSS << "queue_stats_on_" << rrdhost_hostname(localhost);
394
392
- RS = rrdset_create_localhost(
395
+ RS = rrdset_create(
396
+ RH,
397
"netdata", // type
398
IdSS.str().c_str(), // id
399
NameSS.str().c_str(), // name
@@ -428,10 +432,11 @@ void ml::updateTrainingStatisticsChart(RRDHOST *RH, const TrainingStats &TS) {
432
if (!RS) {
433
std::stringstream IdSS, NameSS;
434
431
- IdSS << "training_time_stats_for_" << localhost->machine_guid;
432
- NameSS << "training_time_stats_for_" << localhost->hostname;
435
+ IdSS << "training_time_stats_on_" << localhost->machine_guid;
436
+ NameSS << "training_time_stats_on_" << rrdhost_hostname(localhost);
437
434
- RS = rrdset_create_localhost(
438
+ RS = rrdset_create(
439
+ RH,
440
"netdata", // type
441
IdSS.str().c_str(), // id
442
NameSS.str().c_str(), // name
@@ -474,10 +479,11 @@ void ml::updateTrainingStatisticsChart(RRDHOST *RH, const TrainingStats &TS) {
479
if (!RS) {
480
std::stringstream IdSS, NameSS;
481
477
- IdSS << "training_results_for_" << localhost->machine_guid;
478
- NameSS << "training_results_for_" << localhost->hostname;
482
+ IdSS << "training_results_on_" << localhost->machine_guid;
483
+ NameSS << "training_results_on_" << rrdhost_hostname(localhost);
484
480
- RS = rrdset_create_localhost(
485
+ RS = rrdset_create(
486
+ RH,
487
"netdata", // type
488
IdSS.str().c_str(), // id
489
NameSS.str().c_str(), // name