summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2023-05-31 16:10:35 +0300
committerGitHub <noreply@github.com>2023-05-31 16:10:35 +0300
commita5f87a56a7441d4d39953c7c77c467aaf20a0824 (patch)
tree2ccc4eb38bf833c92ab22b86fde7e72cf404fd8b /web
parent263a89cce7c42037d497f9c9b6acee685d1cf44f (diff)
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.
Diffstat (limited to 'web')
-rw-r--r--web/api/formatters/json/json.c17
-rw-r--r--web/api/formatters/rrd2json.h2
-rw-r--r--web/api/netdata-swagger.yaml11
-rw-r--r--web/api/queries/query.c17
4 files changed, 14 insertions, 33 deletions
diff --git a/web/api/formatters/json/json.c b/web/api/formatters/json/json.c
index d996b2ea20..d5b8c7570e 100644
--- a/web/api/formatters/json/json.c
+++ b/web/api/formatters/json/json.c
@@ -270,12 +270,8 @@ void rrdr2json_v2(RRDR *r, BUFFER *wb) {
buffer_json_member_add_uint64(wb, "value", 0);
buffer_json_member_add_uint64(wb, "arp", 1);
buffer_json_member_add_uint64(wb, "pa", 2);
- if(expose_gbc) {
- if(r->vh)
- buffer_json_member_add_uint64(wb, "hidden", 3);
- else
- buffer_json_member_add_uint64(wb, "count", 3);
- }
+ if(expose_gbc)
+ buffer_json_member_add_uint64(wb, "count", 3);
buffer_json_object_close(wb);
buffer_json_member_add_array(wb, "data");
@@ -290,7 +286,6 @@ void rrdr2json_v2(RRDR *r, BUFFER *wb) {
// for each line in the array
for (i = start; i != end; i += step) {
NETDATA_DOUBLE *cn = &r->v[ i * r->d ];
- NETDATA_DOUBLE *ch = (r->vh) ? &r->vh[ i * r->d ] : NULL;
RRDR_VALUE_FLAGS *co = &r->o[ i * r->d ];
NETDATA_DOUBLE *ar = &r->ar[ i * r->d ];
uint32_t *gbc = &r->gbc [ i * r->d ];
@@ -330,12 +325,8 @@ void rrdr2json_v2(RRDR *r, BUFFER *wb) {
buffer_json_add_array_item_uint64(wb, o);
// add the count
- if(expose_gbc) {
- if(ch)
- buffer_json_add_array_item_double(wb, ch[d]);
- else
- buffer_json_add_array_item_uint64(wb, gbc[d]);
- }
+ if(expose_gbc)
+ buffer_json_add_array_item_uint64(wb, gbc[d]);
buffer_json_array_close(wb); // point
}
diff --git a/web/api/formatters/rrd2json.h b/web/api/formatters/rrd2json.h
index ca3a41aae2..def26c754d 100644
--- a/web/api/formatters/rrd2json.h
+++ b/web/api/formatters/rrd2json.h
@@ -87,7 +87,7 @@ int rrdset2value_api_v1(
);
static inline bool rrdr_dimension_should_be_exposed(RRDR_DIMENSION_FLAGS rrdr_dim_flags, RRDR_OPTIONS options) {
- if(unlikely((options & RRDR_OPTION_RETURN_RAW) && (rrdr_dim_flags & RRDR_DIMENSION_QUERIED)))
+ if(unlikely(options & RRDR_OPTION_RETURN_RAW))
return true;
if(unlikely(rrdr_dim_flags & RRDR_DIMENSION_HIDDEN)) return false;
diff --git a/web/api/netdata-swagger.yaml b/web/api/netdata-swagger.yaml
index b050f34073..c25f0b7194 100644
--- a/web/api/netdata-swagger.yaml
+++ b/web/api/netdata-swagger.yaml
@@ -241,7 +241,6 @@ paths:
A comma separated list of the groupings required.
All possible values can be combined together, except `selected`. If `selected` is given in the list, all others are ignored.
The order they are placed in the list is currently ignored.
- This parameter is also accepted as `group_by[0]` and `group_by[1]` when multiple grouping passes are required.
required: false
schema:
type: array
@@ -262,7 +261,6 @@ paths:
in: query
description: |
A comma separated list of the label keys to group by their values. The order of the labels in the list is respected.
- This parameter is also accepted as `group_by_label[0]` and `group_by_label[1]` when multiple grouping passes are required.
required: false
schema:
type: string
@@ -273,7 +271,6 @@ paths:
description: |
The aggregation function to apply when grouping metrics together.
When option `raw` is given, `average` and `avg` behave like `sum` and the caller is expected to calculate the average.
- This parameter is also accepted as `aggregation[0]` and `aggregation[1]` when multiple grouping passes are required.
required: false
schema:
type: string
@@ -283,7 +280,6 @@ paths:
- avg
- average
- sum
- - percentage
default: average
- $ref: '#/components/parameters/scopeNodes'
- $ref: '#/components/parameters/scopeContexts'
@@ -2745,13 +2741,8 @@ components:
type: integer
count:
description: |
- The number of metrics aggregated into this point.
- This exists only when the option `raw` is given to the query and the final aggregation point is NOT `percentage`.
+ The number of metrics aggregated into this point. This exists only when the option `raw` is given to the query.
type: integer
- hidden:
- description: |
- The sum of the non-selected dimensions aggregated for this group item point.
- This exists only when the option `raw` is given to the query and the final aggregation method is `percentage`.
data:
type: array
items:
diff --git a/web/api/queries/query.c b/web/api/queries/query.c
index 93f94453c5..fe02826222 100644
--- a/web/api/queries/query.c
+++ b/web/api/queries/query.c
@@ -2992,7 +2992,7 @@ static RRDR *rrd2rrdr_group_by_initialize(ONEWAYALLOC *owa, QUERY_TARGET *qt) {
// initialize partial trimming
r->partial_data_trimming.max_update_every = update_every_max;
r->partial_data_trimming.expected_after =
- (!query_target_aggregatable(qt) &&
+ (!(qt->window.options & RRDR_OPTION_RETURN_RAW) &&
qt->window.before >= qt->window.now - update_every_max) ?
qt->window.before - update_every_max :
qt->window.before;
@@ -3168,7 +3168,7 @@ static void rrdr2rrdr_group_by_partial_trimming(RRDR *r) {
}
static void rrdr2rrdr_group_by_calculate_percentage_of_group(RRDR *r) {
- if(!r->vh || query_target_aggregatable(r->internal.qt))
+ if(!r->vh)
return;
for(size_t i = 0; i < r->n ;i++) {
@@ -3191,10 +3191,7 @@ static void rrdr2rrdr_group_by_calculate_percentage_of_group(RRDR *r) {
}
}
-static void rrd2rrdr_convert_values_to_percentage_of_total(RRDR *r) {
- if(!(r->internal.qt->window.options & RRDR_OPTION_PERCENTAGE) || query_target_aggregatable(r->internal.qt))
- return;
-
+static void rrd2rrdr_convert_to_percentage(RRDR *r) {
size_t global_min_max_values = 0;
NETDATA_DOUBLE global_min = NAN, global_max = NAN;
@@ -3292,7 +3289,8 @@ static RRDR *rrd2rrdr_group_by_finalize(RRDR *r_tmp) {
if(!r_tmp->group_by.r) {
// v1 query
- rrd2rrdr_convert_values_to_percentage_of_total(r_tmp);
+ if(options & RRDR_OPTION_PERCENTAGE)
+ rrd2rrdr_convert_to_percentage(r_tmp);
return r_tmp;
}
// v2 query
@@ -3332,7 +3330,7 @@ static RRDR *rrd2rrdr_group_by_finalize(RRDR *r_tmp) {
if(qt->request.group_by[g].group_by != RRDR_GROUP_BY_NONE)
aggregation = qt->request.group_by[g].aggregation;
- if(!query_target_aggregatable(qt) && r->partial_data_trimming.expected_after < qt->window.before)
+ if(!(options & RRDR_OPTION_RETURN_RAW) && r->partial_data_trimming.expected_after < qt->window.before)
rrdr2rrdr_group_by_partial_trimming(r);
// 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) {
qt->window.options &= ~RRDR_OPTION_NONZERO;
}
- rrd2rrdr_convert_values_to_percentage_of_total(r);
+ if(options & RRDR_OPTION_PERCENTAGE && !(options & RRDR_OPTION_RETURN_RAW))
+ rrd2rrdr_convert_to_percentage(r);
// update query instance counts in query host and query context
{