summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Mashchenko <ilya@netdata.cloud>2023-11-15 12:00:19 +0200
committerGitHub <noreply@github.com>2023-11-15 12:00:19 +0200
commit183a7fb84f85885a3d91f8e28d4e9780f964f659 (patch)
tree5d020354835785d5c974e3d71f8ed334dfc9c5df
parent085aaaa6cff61de6836994e62979bfe6fdedc9e9 (diff)
/api/v1/charts: bring back chart id to `title` (#16416)
fix /api/v1/charts add chart name to title
-rw-r--r--web/api/formatters/rrdset2json.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/web/api/formatters/rrdset2json.c b/web/api/formatters/rrdset2json.c
index ca56ca75b6..9ada353365 100644
--- a/web/api/formatters/rrdset2json.c
+++ b/web/api/formatters/rrdset2json.c
@@ -21,21 +21,22 @@ void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memor
{
time_t first_entry_t = rrdset_first_entry_s(st);
time_t last_entry_t = rrdset_last_entry_s(st);
+ char buf[RRD_ID_LENGTH_MAX + 16];
buffer_json_member_add_string(wb, "id", rrdset_id(st));
buffer_json_member_add_string(wb, "name", rrdset_name(st));
buffer_json_member_add_string(wb, "type", rrdset_parts_type(st));
buffer_json_member_add_string(wb, "family", rrdset_family(st));
buffer_json_member_add_string(wb, "context", rrdset_context(st));
- buffer_json_member_add_string(wb, "title", rrdset_title(st));
+ snprintfz(buf, RRD_ID_LENGTH_MAX + 15, "%s (%s)", rrdset_title(st), rrdset_name(st));
+ buffer_json_member_add_string(wb, "title", buf);
buffer_json_member_add_int64(wb, "priority", st->priority);
buffer_json_member_add_string(wb, "plugin", rrdset_plugin_name(st));
buffer_json_member_add_string(wb, "module", rrdset_module_name(st));
buffer_json_member_add_string(wb, "units", rrdset_units(st));
- char data_url[RRD_ID_LENGTH_MAX + 16];
- snprintfz(data_url, RRD_ID_LENGTH_MAX + 15, "/api/v1/data?chart=%s", rrdset_name(st));
- buffer_json_member_add_string(wb, "data_url", data_url);
+ snprintfz(buf, RRD_ID_LENGTH_MAX + 15, "/api/v1/data?chart=%s", rrdset_name(st));
+ buffer_json_member_add_string(wb, "data_url", buf);
buffer_json_member_add_string(wb, "chart_type", rrdset_type_name(st->chart_type));
buffer_json_member_add_int64(wb, "duration", (int64_t)(last_entry_t - first_entry_t + st->update_every));