@cryptotaxi247 / netdata-1 / commits / a5f87a56a

Revert "percentage of group is now aggregatable at cloud across multiple nodes" (#15122)

Revert "percentage of group is now aggregatable at cloud across multiple nodes (#15109)" This reverts commit 44b6c223b3e13774df45a96dd48588aa8a66ba42.

Costa Tsaousis committed May 31, 2023 at 16:10 UTC a5f87a56a7441d4d39953c7c77c467aaf20a0824
4 files changed +14 -33
web/api/formatters/json/json.c
+4 -13
@@ -270,12 +270,8 @@ void rrdr2json_v2(RRDR *r, BUFFER *wb) {
270 buffer_json_member_add_uint64(wb, "value", 0);
271 buffer_json_member_add_uint64(wb, "arp", 1);
272 buffer_json_member_add_uint64(wb, "pa", 2);
273 - if(expose_gbc) {
274 - if(r->vh)
275 - buffer_json_member_add_uint64(wb, "hidden", 3);
276 - else
277 - buffer_json_member_add_uint64(wb, "count", 3);
278 - }
273 + if(expose_gbc)
274 + buffer_json_member_add_uint64(wb, "count", 3);
275 buffer_json_object_close(wb);
276
277 buffer_json_member_add_array(wb, "data");
@@ -290,7 +286,6 @@ void rrdr2json_v2(RRDR *r, BUFFER *wb) {
286 // for each line in the array
287 for (i = start; i != end; i += step) {
288 NETDATA_DOUBLE *cn = &r->v[ i * r->d ];
293 - NETDATA_DOUBLE *ch = (r->vh) ? &r->vh[ i * r->d ] : NULL;
289 RRDR_VALUE_FLAGS *co = &r->o[ i * r->d ];
290 NETDATA_DOUBLE *ar = &r->ar[ i * r->d ];
291 uint32_t *gbc = &r->gbc [ i * r->d ];
@@ -330,12 +325,8 @@ void rrdr2json_v2(RRDR *r, BUFFER *wb) {
325 buffer_json_add_array_item_uint64(wb, o);
326
327 // add the count
333 - if(expose_gbc) {
334 - if(ch)
335 - buffer_json_add_array_item_double(wb, ch[d]);
336 - else
337 - buffer_json_add_array_item_uint64(wb, gbc[d]);
338 - }
328 + if(expose_gbc)
329 + buffer_json_add_array_item_uint64(wb, gbc[d]);
330
331 buffer_json_array_close(wb); // point
332 }
web/api/formatters/rrd2json.h
+1 -1
@@ -87,7 +87,7 @@ int rrdset2value_api_v1(
87 );
88
89 static inline bool rrdr_dimension_should_be_exposed(RRDR_DIMENSION_FLAGS rrdr_dim_flags, RRDR_OPTIONS options) {
90 - if(unlikely((options & RRDR_OPTION_RETURN_RAW) && (rrdr_dim_flags & RRDR_DIMENSION_QUERIED)))
90 + if(unlikely(options & RRDR_OPTION_RETURN_RAW))
91 return true;
92
93 if(unlikely(rrdr_dim_flags & RRDR_DIMENSION_HIDDEN)) return false;
web/api/netdata-swagger.yaml
+1 -10
@@ -241,7 +241,6 @@ paths:
241 A comma separated list of the groupings required.
242 All possible values can be combined together, except `selected`. If `selected` is given in the list, all others are ignored.
243 The order they are placed in the list is currently ignored.
244 - This parameter is also accepted as `group_by[0]` and `group_by[1]` when multiple grouping passes are required.
244 required: false
245 schema:
246 type: array
@@ -262,7 +261,6 @@ paths:
261 in: query
262 description: |
263 A comma separated list of the label keys to group by their values. The order of the labels in the list is respected.
265 - This parameter is also accepted as `group_by_label[0]` and `group_by_label[1]` when multiple grouping passes are required.
264 required: false
265 schema:
266 type: string
@@ -273,7 +271,6 @@ paths:
271 description: |
272 The aggregation function to apply when grouping metrics together.
273 When option `raw` is given, `average` and `avg` behave like `sum` and the caller is expected to calculate the average.
276 - This parameter is also accepted as `aggregation[0]` and `aggregation[1]` when multiple grouping passes are required.
274 required: false
275 schema:
276 type: string
@@ -283,7 +280,6 @@ paths:
280 - avg
281 - average
282 - sum
286 - - percentage
283 default: average
284 - $ref: '#/components/parameters/scopeNodes'
285 - $ref: '#/components/parameters/scopeContexts'
@@ -2745,13 +2741,8 @@ components:
2741 type: integer
2742 count:
2743 description: |
2748 - The number of metrics aggregated into this point.
2749 - This exists only when the option `raw` is given to the query and the final aggregation point is NOT `percentage`.
2744 + The number of metrics aggregated into this point. This exists only when the option `raw` is given to the query.
2745 type: integer
2751 - hidden:
2752 - description: |
2753 - The sum of the non-selected dimensions aggregated for this group item point.
2754 - This exists only when the option `raw` is given to the query and the final aggregation method is `percentage`.
2746 data:
2747 type: array
2748 items:
web/api/queries/query.c
+8 -9
@@ -2992,7 +2992,7 @@ static RRDR *rrd2rrdr_group_by_initialize(ONEWAYALLOC *owa, QUERY_TARGET *qt) {
2992 // initialize partial trimming
2993 r->partial_data_trimming.max_update_every = update_every_max;
2994 r->partial_data_trimming.expected_after =
2995 - (!query_target_aggregatable(qt) &&
2995 + (!(qt->window.options & RRDR_OPTION_RETURN_RAW) &&
2996 qt->window.before >= qt->window.now - update_every_max) ?
2997 qt->window.before - update_every_max :
2998 qt->window.before;
@@ -3168,7 +3168,7 @@ static void rrdr2rrdr_group_by_partial_trimming(RRDR *r) {
3168 }
3169
3170 static void rrdr2rrdr_group_by_calculate_percentage_of_group(RRDR *r) {
3171 - if(!r->vh || query_target_aggregatable(r->internal.qt))
3171 + if(!r->vh)
3172 return;
3173
3174 for(size_t i = 0; i < r->n ;i++) {
@@ -3191,10 +3191,7 @@ static void rrdr2rrdr_group_by_calculate_percentage_of_group(RRDR *r) {
3191 }
3192 }
3193
3194 -static void rrd2rrdr_convert_values_to_percentage_of_total(RRDR *r) {
3195 - if(!(r->internal.qt->window.options & RRDR_OPTION_PERCENTAGE) || query_target_aggregatable(r->internal.qt))
3196 - return;
3197 -
3194 +static void rrd2rrdr_convert_to_percentage(RRDR *r) {
3195 size_t global_min_max_values = 0;
3196 NETDATA_DOUBLE global_min = NAN, global_max = NAN;
3197
@@ -3292,7 +3289,8 @@ static RRDR *rrd2rrdr_group_by_finalize(RRDR *r_tmp) {
3289
3290 if(!r_tmp->group_by.r) {
3291 // v1 query
3295 - rrd2rrdr_convert_values_to_percentage_of_total(r_tmp);
3292 + if(options & RRDR_OPTION_PERCENTAGE)
3293 + rrd2rrdr_convert_to_percentage(r_tmp);
3294 return r_tmp;
3295 }
3296 // v2 query
@@ -3332,7 +3330,7 @@ static RRDR *rrd2rrdr_group_by_finalize(RRDR *r_tmp) {
3330 if(qt->request.group_by[g].group_by != RRDR_GROUP_BY_NONE)
3331 aggregation = qt->request.group_by[g].aggregation;
3332
3335 - if(!query_target_aggregatable(qt) && r->partial_data_trimming.expected_after < qt->window.before)
3333 + if(!(options & RRDR_OPTION_RETURN_RAW) && r->partial_data_trimming.expected_after < qt->window.before)
3334 rrdr2rrdr_group_by_partial_trimming(r);
3335
3336 // apply averaging, remove RRDR_VALUE_EMPTY, find the non-zero dimensions, min and max
@@ -3424,7 +3422,8 @@ static RRDR *rrd2rrdr_group_by_finalize(RRDR *r_tmp) {
3422 qt->window.options &= ~RRDR_OPTION_NONZERO;
3423 }
3424
3427 - rrd2rrdr_convert_values_to_percentage_of_total(r);
3425 + if(options & RRDR_OPTION_PERCENTAGE && !(options & RRDR_OPTION_RETURN_RAW))
3426 + rrd2rrdr_convert_to_percentage(r);
3427
3428 // update query instance counts in query host and query context
3429 {