@cryptotaxi247 / netdata-1 / commits / c5c83a30d

Don't send alert variables to the cloud (#14325)

filter alert events from variables alert config

Emmanuel Vasilakis committed Feb 1, 2023 at 19:04 UTC c5c83a30dd8f0e79dfbf92ba25effd20b018fc99
1 file changed +31
database/sqlite/sqlite_aclk_alert.c
+31
@@ -43,6 +43,34 @@ void update_filtered(ALARM_ENTRY *ae, uint32_t unique_id, char *uuid_str) {
43 ae->flags |= HEALTH_ENTRY_FLAG_ACLK_QUEUED;
44 }
45
46 +static inline bool is_event_from_alert_variable_config(uint32_t unique_id, char *uuid_str) {
47 + sqlite3_stmt *res = NULL;
48 + int rc = 0;
49 + bool ret = false;
50 +
51 + char sql[ACLK_SYNC_QUERY_SIZE];
52 + snprintfz(sql,ACLK_SYNC_QUERY_SIZE-1, "select hl.unique_id from health_log_%s hl, alert_hash ah where hl.unique_id = %u " \
53 + "and hl.config_hash_id = ah.hash_id " \
54 + "and ah.warn is null and ah.crit is null;", uuid_str, unique_id);
55 +
56 + rc = sqlite3_prepare_v2(db_meta, sql, -1, &res, 0);
57 + if (rc != SQLITE_OK) {
58 + error_report("Failed to prepare statement when trying to check for alert variables.");
59 + return false;
60 + }
61 +
62 + rc = sqlite3_step_monitored(res);
63 + if (likely(rc == SQLITE_ROW)) {
64 + ret = true;
65 + }
66 +
67 + rc = sqlite3_finalize(res);
68 + if (unlikely(rc != SQLITE_OK))
69 + error_report("Failed to finalize statement when trying to check for alert variables, rc = %d", rc);
70 +
71 + return ret;
72 +}
73 +
74 #define MAX_REMOVED_PERIOD 86400
75 //decide if some events should be sent or not
76 int should_send_to_cloud(RRDHOST *host, ALARM_ENTRY *ae)
@@ -59,6 +87,9 @@ int should_send_to_cloud(RRDHOST *host, ALARM_ENTRY *ae)
87 if (unlikely(uuid_is_null(ae->config_hash_id)))
88 return 0;
89
90 + if (is_event_from_alert_variable_config(ae->unique_id, uuid_str))
91 + return 0;
92 +
93 char sql[ACLK_SYNC_QUERY_SIZE];
94 uuid_t config_hash_id;
95 RRDCALC_STATUS status;