diff options
author | Valentin Rakush <52716954+alpes214@users.noreply.github.com> | 2019-08-20 12:11:43 +0300 |
---|---|---|
committer | Chris Akritidis <43294513+cakrit@users.noreply.github.com> | 2019-08-20 11:11:43 +0200 |
commit | 92642269f19f585b04d439a3bbe4e60d33918974 (patch) | |
tree | a507dfe903ebacafb4e485a2ee6edcb54867448a /web/api/formatters/json_wrapper.c | |
parent | d52c20ec4c632459d90797725214be8ffeb66251 (diff) |
Add alarm variables to the response of chart and data (#6615)
##### Summary
Implements feature #6054
Now requests like
http://localhost:19999/api/v1/chart?chart=example.random
http://localhost:19999/api/v1/data?chart=example.random&options=jsonwrap&options=showcustomvars
- return chart variables in their responses. Chart variables include only those with options set to RRDVAR_OPTION_CUSTOM_CHART_VAR
- for /api/v1/data requests chart variables are returned when parameter options=jsonwrap and options=showcustomvars
##### Component Name
[/database](https://github.com/netdata/netdata/tree/master/database/)
[/web/api/formatters](https://github.com/netdata/netdata/tree/master/web/api/formatters)
Diffstat (limited to 'web/api/formatters/json_wrapper.c')
-rw-r--r-- | web/api/formatters/json_wrapper.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/web/api/formatters/json_wrapper.c b/web/api/formatters/json_wrapper.c index 4911d2f0ea..5ef2caf101 100644 --- a/web/api/formatters/json_wrapper.c +++ b/web/api/formatters/json_wrapper.c @@ -182,11 +182,14 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS rrdr_buffer_print_format(wb, format); - buffer_sprintf(wb, "%s,\n" - " %sresult%s: " - , sq - , kq, kq - ); + if((options & RRDR_OPTION_CUSTOM_VARS) && (options & RRDR_OPTION_JSON_WRAP)) { + buffer_sprintf(wb, "%s,\n %schart_variables%s: ", sq, kq, kq); + health_api_v1_chart_custom_variables2json(r->st, wb); + } + else + buffer_sprintf(wb, "%s", sq); + + buffer_sprintf(wb, ",\n %sresult%s: ", kq, kq); if(string_value) buffer_strcat(wb, sq); //info("JSONWRAPPER(): %s: END", r->st->id); |