diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-13 17:16:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-13 17:16:02 +0000 |
commit | 396c327fe40b1db11fc204d7ae7ace84503de681 (patch) | |
tree | 6718eb5d5dcf3c6e3c93e32ac6ac9a857f6ca56e /web | |
parent | Releasing debian version 1.38.0-1. (diff) | |
download | netdata-396c327fe40b1db11fc204d7ae7ace84503de681.tar.xz netdata-396c327fe40b1db11fc204d7ae7ace84503de681.zip |
Merging upstream version 1.38.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web')
-rw-r--r-- | web/api/formatters/csv/csv.c | 5 | ||||
-rw-r--r-- | web/api/formatters/json/json.c | 6 | ||||
-rw-r--r-- | web/api/formatters/json_wrapper.c | 14 | ||||
-rw-r--r-- | web/api/formatters/value/value.c | 2 | ||||
-rw-r--r-- | web/api/queries/query.c | 28 | ||||
-rw-r--r-- | web/api/queries/rrdr.h | 2 | ||||
-rw-r--r-- | web/api/queries/weights.c | 3 |
7 files changed, 44 insertions, 16 deletions
diff --git a/web/api/formatters/csv/csv.c b/web/api/formatters/csv/csv.c index 603a1716..18009f14 100644 --- a/web/api/formatters/csv/csv.c +++ b/web/api/formatters/csv/csv.c @@ -12,6 +12,7 @@ void rrdr2csv(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS options, const // print the csv header for(c = 0, i = 0; c < used ; c++) { if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; if(unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue; if(!i) { @@ -32,6 +33,7 @@ void rrdr2csv(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS options, const // print the --- line after header for(c = 0, i = 0; c < used ;c++) { if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; if(unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue; if(!i) { @@ -89,6 +91,8 @@ void rrdr2csv(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS options, const if(unlikely(options & RRDR_OPTION_PERCENTAGE)) { total = 0; for(c = 0; c < used ;c++) { + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; + NETDATA_DOUBLE n = cn[c]; if(likely((options & RRDR_OPTION_ABSOLUTE) && n < 0)) @@ -104,6 +108,7 @@ void rrdr2csv(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS options, const // for each dimension for(c = 0; c < used ;c++) { if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; if(unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue; buffer_strcat(wb, separator); diff --git a/web/api/formatters/json/json.c b/web/api/formatters/json/json.c index 608150cb..3cad3e91 100644 --- a/web/api/formatters/json/json.c +++ b/web/api/formatters/json/json.c @@ -111,6 +111,7 @@ void rrdr2json(RRDR *r, BUFFER *wb, RRDR_OPTIONS options, int datatable) { // print the header lines for(c = 0, i = 0; c < used ; c++) { if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; if(unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue; buffer_fast_strcat(wb, pre_label, pre_label_len); @@ -180,7 +181,7 @@ void rrdr2json(RRDR *r, BUFFER *wb, RRDR_OPTIONS options, int datatable) { // google supports one annotation per row int annotation_found = 0; for(c = 0; c < used ; c++) { - if(unlikely(!(r->od[c] & RRDR_DIMENSION_SELECTED))) continue; + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; if(unlikely(co[c] & RRDR_VALUE_RESET)) { buffer_fast_strcat(wb, overflow_annotation, overflow_annotation_len); @@ -215,6 +216,8 @@ void rrdr2json(RRDR *r, BUFFER *wb, RRDR_OPTIONS options, int datatable) { if(unlikely(options & RRDR_OPTION_PERCENTAGE)) { total = 0; for(c = 0; c < used ;c++) { + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; + NETDATA_DOUBLE n; if(unlikely(options & RRDR_OPTION_INTERNAL_AR)) n = ar[c]; @@ -234,6 +237,7 @@ void rrdr2json(RRDR *r, BUFFER *wb, RRDR_OPTIONS options, int datatable) { // for each dimension for(c = 0; c < used ;c++) { if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; if(unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue; NETDATA_DOUBLE n; diff --git a/web/api/formatters/json_wrapper.c b/web/api/formatters/json_wrapper.c index beb74912..aa663495 100644 --- a/web/api/formatters/json_wrapper.c +++ b/web/api/formatters/json_wrapper.c @@ -131,6 +131,7 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS for(c = 0, i = 0; c < query_used ; c++) { if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; if(unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue; if(i) buffer_strcat(wb, ", "); @@ -155,6 +156,7 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS for(c = 0, i = 0; c < query_used ; c++) { if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; if(unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue; if(i) buffer_strcat(wb, ", "); @@ -260,9 +262,8 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS for (c = 0, i = 0; c < query_used; c++) { QUERY_METRIC *qm = &qt->query.array[c]; - if (unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) - continue; - + if (unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if (unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; if (unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue; @@ -295,8 +296,8 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS for (c = 0, i = 0; c < query_used; c++) { QUERY_METRIC *qm = &qt->query.array[c]; - if (unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) - continue; + if (unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if (unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; if (unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue; @@ -351,6 +352,8 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS if(unlikely(options & RRDR_OPTION_PERCENTAGE)) { total = 0; for(c = 0; c < query_used ;c++) { + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; + NETDATA_DOUBLE *cn = &r->v[ (rrdr_rows(r) - 1) * r->d ]; NETDATA_DOUBLE n = cn[c]; @@ -365,6 +368,7 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS for(c = 0, i = 0; c < query_used ;c++) { if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; if(unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue; if(i) buffer_strcat(wb, ", "); diff --git a/web/api/formatters/value/value.c b/web/api/formatters/value/value.c index 915d58ac..fd918805 100644 --- a/web/api/formatters/value/value.c +++ b/web/api/formatters/value/value.c @@ -22,6 +22,7 @@ inline NETDATA_DOUBLE rrdr2value(RRDR *r, long i, RRDR_OPTIONS options, int *all if(unlikely(options & RRDR_OPTION_PERCENTAGE)) { total = 0; for (c = 0; c < used; c++) { + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; NETDATA_DOUBLE n = cn[c]; if(likely((options & RRDR_OPTION_ABSOLUTE) && n < 0)) @@ -37,6 +38,7 @@ inline NETDATA_DOUBLE rrdr2value(RRDR *r, long i, RRDR_OPTIONS options, int *all // for each dimension for (c = 0; c < used; c++) { if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if(unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; if(unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue; NETDATA_DOUBLE n = cn[c]; diff --git a/web/api/queries/query.c b/web/api/queries/query.c index 1f10c513..df7e0979 100644 --- a/web/api/queries/query.c +++ b/web/api/queries/query.c @@ -2273,9 +2273,11 @@ RRDR *rrd2rrdr(ONEWAYALLOC *owa, QUERY_TARGET *qt) { r->internal.grouping_reset(r); if(ops[c]) { - r->od[c] |= RRDR_DIMENSION_SELECTED; + r->od[c] |= RRDR_DIMENSION_QUERIED; rrd2rrdr_query_execute(r, c, ops[c]); } + else + continue; global_statistics_rrdr_query_completed( 1, @@ -2385,15 +2387,23 @@ RRDR *rrd2rrdr(ONEWAYALLOC *owa, QUERY_TARGET *qt) { // free all resources used by the grouping method r->internal.grouping_free(r); - // when all the dimensions are zero, we should return all of them - if(unlikely((qt->window.options & RRDR_OPTION_NONZERO) && !dimensions_nonzero && !(r->result_options & RRDR_RESULT_OPTION_CANCEL))) { - // all the dimensions are zero - // mark them as NONZERO to send them all - for(size_t c = 0, max = qt->query.used; c < max ; c++) { - if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; - r->od[c] |= RRDR_DIMENSION_NONZERO; + if(likely(dimensions_used)) { + // when all the dimensions are zero, we should return all of them + if (unlikely((qt->window.options & RRDR_OPTION_NONZERO) && !dimensions_nonzero && + !(r->result_options & RRDR_RESULT_OPTION_CANCEL))) { + // all the dimensions are zero + // mark them as NONZERO to send them all + for (size_t c = 0, max = qt->query.used; c < max; c++) { + if (unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if (unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; + r->od[c] |= RRDR_DIMENSION_NONZERO; + } } + + return r; } - return r; + // we couldn't query any dimension + rrdr_free(owa, r); + return NULL; } diff --git a/web/api/queries/rrdr.h b/web/api/queries/rrdr.h index e31a9809..2d982b13 100644 --- a/web/api/queries/rrdr.h +++ b/web/api/queries/rrdr.h @@ -58,7 +58,7 @@ typedef enum rrdr_dimension_flag { RRDR_DIMENSION_DEFAULT = 0x00, RRDR_DIMENSION_HIDDEN = 0x04, // the dimension is hidden (not to be presented to callers) RRDR_DIMENSION_NONZERO = 0x08, // the dimension is non zero (contains non-zero values) - RRDR_DIMENSION_SELECTED = 0x10, // the dimension is selected for evaluation in this RRDR + RRDR_DIMENSION_QUERIED = 0x10, // the dimension is selected for evaluation in this RRDR } RRDR_DIMENSION_FLAGS; // RRDR result options diff --git a/web/api/queries/weights.c b/web/api/queries/weights.c index dc98aeed..485aaca2 100644 --- a/web/api/queries/weights.c +++ b/web/api/queries/weights.c @@ -541,6 +541,9 @@ NETDATA_DOUBLE *rrd2rrdr_ks2( if(unlikely(r->od[0] & RRDR_DIMENSION_HIDDEN)) goto cleanup; + if(unlikely(!(r->od[0] & RRDR_DIMENSION_QUERIED))) + goto cleanup; + if(unlikely(!(r->od[0] & RRDR_DIMENSION_NONZERO))) goto cleanup; |