diff options
Diffstat (limited to 'database')
-rw-r--r-- | database/contexts/api_v2.c | 6 | ||||
-rw-r--r-- | database/contexts/rrdcontext.h | 3 | ||||
-rw-r--r-- | database/sqlite/sqlite_aclk_alert.c | 8 | ||||
-rw-r--r-- | database/sqlite/sqlite_health.c | 6 |
4 files changed, 19 insertions, 4 deletions
diff --git a/database/contexts/api_v2.c b/database/contexts/api_v2.c index 5f904718fa..dacf962a30 100644 --- a/database/contexts/api_v2.c +++ b/database/contexts/api_v2.c @@ -355,6 +355,7 @@ static void alert_instances_v2_insert_callback(const DICTIONARY_ITEM *item __may t->status = rc->status; t->flags = rc->run_flags; t->info = rc->info; + t->summary = rc->summary; t->value = rc->value; t->last_updated = rc->last_updated; t->last_status_change = rc->last_status_change; @@ -1280,6 +1281,7 @@ static void contexts_v2_alert_config_to_json_from_sql_alert_config_data(struct s buffer_json_member_add_string(wb, "component", t->component); buffer_json_member_add_string(wb, "type", t->type); buffer_json_member_add_string(wb, "info", t->info); + buffer_json_member_add_string(wb, "summary", t->summary); // buffer_json_member_add_string(wb, "source", t->source); // moved to alert instance } @@ -1343,6 +1345,7 @@ static int contexts_v2_alert_instance_to_json_callback(const DICTIONARY_ITEM *it buffer_json_member_add_string(wb, "units", string2str(t->units)); buffer_json_member_add_string(wb, "fami", string2str(t->family)); buffer_json_member_add_string(wb, "info", string2str(t->info)); + buffer_json_member_add_string(wb, "sum", string2str(t->summary)); buffer_json_member_add_string(wb, "ctx", string2str(t->context)); buffer_json_member_add_string(wb, "st", rrdcalc_status2string(t->status)); buffer_json_member_add_uuid(wb, "tr_i", &t->last_transition_id); @@ -1438,6 +1441,7 @@ struct sql_alert_transition_fixed_size { char units[SQL_TRANSITION_DATA_SMALL_STRING]; char exec[SQL_TRANSITION_DATA_BIG_STRING]; char info[SQL_TRANSITION_DATA_BIG_STRING]; + char summary[SQL_TRANSITION_DATA_BIG_STRING]; char classification[SQL_TRANSITION_DATA_SMALL_STRING]; char type[SQL_TRANSITION_DATA_SMALL_STRING]; char component[SQL_TRANSITION_DATA_SMALL_STRING]; @@ -1477,6 +1481,7 @@ static struct sql_alert_transition_fixed_size *contexts_v2_alert_transition_dup( strncpyz(n->units, t->units ? t->units : "", sizeof(n->units) - 1); strncpyz(n->exec, t->exec ? t->exec : "", sizeof(n->exec) - 1); strncpyz(n->info, t->info ? t->info : "", sizeof(n->info) - 1); + strncpyz(n->summary, t->summary ? t->summary : "", sizeof(n->summary) - 1); strncpyz(n->classification, t->classification ? t->classification : "", sizeof(n->classification) - 1); strncpyz(n->type, t->type ? t->type : "", sizeof(n->type) - 1); strncpyz(n->component, t->component ? t->component : "", sizeof(n->component) - 1); @@ -1734,6 +1739,7 @@ static void contexts_v2_alert_transitions_to_json(BUFFER *wb, struct rrdcontext_ buffer_json_member_add_time_t(wb, "when", t->when_key); buffer_json_member_add_string(wb, "info", *t->info ? t->info : ""); + buffer_json_member_add_string(wb, "summary", *t->summary ? t->summary : ""); buffer_json_member_add_string(wb, "units", *t->units ? t->units : NULL); buffer_json_member_add_object(wb, "new"); { diff --git a/database/contexts/rrdcontext.h b/database/contexts/rrdcontext.h index ffc42e79a2..9c497a5a5e 100644 --- a/database/contexts/rrdcontext.h +++ b/database/contexts/rrdcontext.h @@ -432,6 +432,7 @@ struct sql_alert_transition_data { const char *units; const char *exec; const char *info; + const char *summary; const char *classification; const char *type; const char *component; @@ -472,6 +473,7 @@ struct sql_alert_config_data { const char *classification; const char *component; const char *type; + const char *summary; struct { struct { @@ -531,6 +533,7 @@ struct sql_alert_instance_v2_entry { RRDCALC_STATUS status; RRDCALC_FLAGS flags; STRING *info; + STRING *summary; NETDATA_DOUBLE value; time_t last_updated; time_t last_status_change; diff --git a/database/sqlite/sqlite_aclk_alert.c b/database/sqlite/sqlite_aclk_alert.c index 9960a1bf79..5b74986432 100644 --- a/database/sqlite/sqlite_aclk_alert.c +++ b/database/sqlite/sqlite_aclk_alert.c @@ -275,7 +275,7 @@ void aclk_push_alert_event(struct aclk_sync_host_config *wc) " hld.duration, hld.non_clear_duration, hld.flags, hld.exec_run_timestamp, hld.delay_up_to_timestamp, hl.name, " " hl.chart, hl.family, hl.exec, hl.recipient, ha.source, hl.units, hld.info, hld.exec_code, hld.new_status, " " hld.old_status, hld.delay, hld.new_value, hld.old_value, hld.last_repeat, hl.chart_context, hld.transition_id, " - "hld.alarm_event_id, hl.chart_name " + " hld.alarm_event_id, hl.chart_name, hld.summary " " from health_log hl, aclk_alert_%s aa, alert_hash ha, health_log_detail hld " " where hld.unique_id = aa.alert_unique_id and hl.config_hash_id = ha.hash_id and aa.date_submitted is null " " and hl.host_id = @host_id and hl.health_log_id = hld.health_log_id " @@ -388,6 +388,7 @@ void aclk_push_alert_event(struct aclk_sync_host_config *wc) alarm_log.transition_id = sqlite3_uuid_unparse_strdupz(res, 27); alarm_log.event_id = (time_t) sqlite3_column_int64(res, 28); alarm_log.chart_name = sqlite3_text_strdupz_empty(res, 29); + alarm_log.summary = sqlite3_text_strdupz_empty(res, 30); aclk_send_alarm_log_entry(&alarm_log); @@ -535,7 +536,7 @@ void aclk_send_alarm_configuration(char *config_hash) "SELECT alarm, template, on_key, class, type, component, os, hosts, plugin," \ "module, charts, families, lookup, every, units, green, red, calc, warn, crit, to_key, exec, delay, repeat, info," \ "options, host_labels, p_db_lookup_dimensions, p_db_lookup_method, p_db_lookup_options, p_db_lookup_after," \ - "p_db_lookup_before, p_update_every, chart_labels FROM alert_hash WHERE hash_id = @hash_id;" + "p_db_lookup_before, p_update_every, chart_labels, summary FROM alert_hash WHERE hash_id = @hash_id;" int aclk_push_alert_config_event(char *node_id __maybe_unused, char *config_hash __maybe_unused) { @@ -637,6 +638,7 @@ int aclk_push_alert_config_event(char *node_id __maybe_unused, char *config_hash alarm_config.p_update_every = sqlite3_column_int(res, 32); alarm_config.chart_labels = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, 33); + alarm_config.summary = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, 34); p_alarm_config.cfg_hash = strdupz((char *) config_hash); p_alarm_config.cfg = alarm_config; @@ -846,6 +848,8 @@ void health_alarm_entry2proto_nolock(struct alarm_log_entry *alarm_log, ALARM_EN alarm_log->transition_id = strdupz((char *)transition_id); alarm_log->event_id = (uint64_t) ae->alarm_event_id; + alarm_log->summary = strdupz(ae_summary(ae)); + freez(edit_command); } #endif diff --git a/database/sqlite/sqlite_health.c b/database/sqlite/sqlite_health.c index c842103835..38a1f5dd97 100644 --- a/database/sqlite/sqlite_health.c +++ b/database/sqlite/sqlite_health.c @@ -1882,7 +1882,7 @@ done: "SELECT h.host_id, h.alarm_id, h.config_hash_id, h.name, h.chart, h.chart_name, h.family, h.recipient, h.units, h.exec, " \ "h.chart_context, d.when_key, d.duration, d.non_clear_duration, d.flags, d.delay_up_to_timestamp, " \ "d.info, d.exec_code, d.new_status, d.old_status, d.delay, d.new_value, d.old_value, d.last_repeat, " \ - "d.transition_id, d.global_id, ah.class, ah.type, ah.component, d.exec_run_timestamp" + "d.transition_id, d.global_id, ah.class, ah.type, ah.component, d.exec_run_timestamp, d.summary" #define SQL_SEARCH_ALERT_TRANSITION_COMMON_WHERE "h.config_hash_id = ah.hash_id AND h.health_log_id = d.health_log_id" @@ -2054,6 +2054,7 @@ run_query:; atd.type = (const char *) sqlite3_column_text(res, 27); atd.component = (const char *) sqlite3_column_text(res, 28); atd.exec_run_timestamp = sqlite3_column_int64(res, 29); + atd.summary = (const char *) sqlite3_column_text(res, 30); cb(&atd, data); } @@ -2079,7 +2080,7 @@ done_only_drop: "SELECT ah.hash_id, alarm, template, on_key, class, component, type, os, hosts, lookup, every, " \ " units, calc, families, plugin, module, charts, green, red, warn, crit, " \ " exec, to_key, info, delay, options, repeat, host_labels, p_db_lookup_dimensions, p_db_lookup_method, " \ - " p_db_lookup_options, p_db_lookup_after, p_db_lookup_before, p_update_every, source, chart_labels " \ + " p_db_lookup_options, p_db_lookup_after, p_db_lookup_before, p_update_every, source, chart_labels, summary " \ " FROM alert_hash ah, c_%p t where ah.hash_id = t.hash_id" int sql_get_alert_configuration( @@ -2188,6 +2189,7 @@ int sql_get_alert_configuration( acd.value.update_every = (int32_t) sqlite3_column_int(res, param++); acd.source = (const char *) sqlite3_column_text(res, param++); acd.selectors.chart_labels = (const char *) sqlite3_column_text(res, param++); + acd.summary = (const char *) sqlite3_column_text(res, param++); cb(&acd, data); added++; |