diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-14 19:20:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-14 19:20:33 +0000 |
commit | 6cf8f2d5174a53f582e61d715edbb88d6e3367cc (patch) | |
tree | 78cec0fd8d09c4a6a052461d42f4b2be3af6d396 /database/contexts/rrdcontext.h | |
parent | Adding upstream version 1.39.1. (diff) | |
download | netdata-6cf8f2d5174a53f582e61d715edbb88d6e3367cc.tar.xz netdata-6cf8f2d5174a53f582e61d715edbb88d6e3367cc.zip |
Adding upstream version 1.40.0.upstream/1.40.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | database/contexts/rrdcontext.h | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/database/contexts/rrdcontext.h b/database/contexts/rrdcontext.h index 5328483d6..0f0f90d32 100644 --- a/database/contexts/rrdcontext.h +++ b/database/contexts/rrdcontext.h @@ -524,10 +524,41 @@ bool rrdcontext_retention_match(RRDCONTEXT_ACQUIRED *rca, time_t after, time_t b #define query_target_aggregatable(qt) ((qt)->window.options & RRDR_OPTION_RETURN_RAW) -static inline bool query_target_has_percentage_of_instance(QUERY_TARGET *qt) { - for(size_t g = 0; g < MAX_QUERY_GROUP_BY_PASSES ;g++) +static inline bool query_has_group_by_aggregation_percentage(QUERY_TARGET *qt) { + + // backwards compatibility + // If the request was made with group_by = "percentage-of-instance" + // we need to send back "raw" output with "count" + // otherwise, we need to send back "raw" output with "hidden" + + bool last_is_percentage = false; + + for(int g = 0; g < MAX_QUERY_GROUP_BY_PASSES ;g++) { + if(qt->request.group_by[g].group_by == RRDR_GROUP_BY_NONE) + break; + if(qt->request.group_by[g].group_by & RRDR_GROUP_BY_PERCENTAGE_OF_INSTANCE) + // backwards compatibility + return false; + + if(qt->request.group_by[g].aggregation == RRDR_GROUP_BY_FUNCTION_PERCENTAGE) + last_is_percentage = true; + + else + last_is_percentage = false; + } + + return last_is_percentage; +} + +static inline bool query_target_has_percentage_of_group(QUERY_TARGET *qt) { + for(size_t g = 0; g < MAX_QUERY_GROUP_BY_PASSES ;g++) { + if (qt->request.group_by[g].group_by & RRDR_GROUP_BY_PERCENTAGE_OF_INSTANCE) + return true; + + if (qt->request.group_by[g].aggregation == RRDR_GROUP_BY_FUNCTION_PERCENTAGE) return true; + } return false; } @@ -536,7 +567,7 @@ static inline bool query_target_needs_all_dimensions(QUERY_TARGET *qt) { if(qt->request.options & RRDR_OPTION_PERCENTAGE) return true; - return query_target_has_percentage_of_instance(qt); + return query_target_has_percentage_of_group(qt); } static inline bool query_target_has_percentage_units(QUERY_TARGET *qt) { @@ -546,7 +577,7 @@ static inline bool query_target_has_percentage_units(QUERY_TARGET *qt) { if((qt->request.options & RRDR_OPTION_PERCENTAGE) && !(qt->window.options & RRDR_OPTION_RETURN_RAW)) return true; - return query_target_has_percentage_of_instance(qt); + return query_target_has_percentage_of_group(qt); } #endif // NETDATA_RRDCONTEXT_H |