From ef2d91de3e7e28d1adea9de52a2d6298f2dc70c9 Mon Sep 17 00:00:00 2001 From: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> Date: Wed, 5 Jun 2024 22:43:28 +0300 Subject: [PATCH] Add alert meta info (node index) (#17818) Add an ni array (index to nodes that the alert applies) --- src/database/contexts/api_v2.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/database/contexts/api_v2.c b/src/database/contexts/api_v2.c index a8e09bb6476ed4..e4631d3f00effa 100644 --- a/src/database/contexts/api_v2.c +++ b/src/database/contexts/api_v2.c @@ -1580,6 +1580,16 @@ static void contexts_v2_alerts_to_json(BUFFER *wb, struct rrdcontext_to_json_v2_ buffer_json_add_array_item_object(wb); { buffer_json_member_add_uint64(wb, "ati", t->ati); + + buffer_json_member_add_array(wb, "ni"); + void *host_guid; + dfe_start_read(t->nodes, host_guid) { + struct contexts_v2_node *cn = dictionary_get(ctl->nodes.dict,host_guid_dfe.name); + buffer_json_add_array_item_int64(wb, (int64_t) cn->ni); + } + dfe_done(host_guid); + buffer_json_array_close(wb); + buffer_json_member_add_string(wb, "nm", string2str(t->name)); buffer_json_member_add_string(wb, "sum", string2str(t->summary));