summaryrefslogtreecommitdiffstats
path: root/web/api/formatters
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-04-14 18:12:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-04-14 18:12:14 +0000
commitbb50acdcb8073654ea667b8c0272e335bd43f844 (patch)
tree1e00c8a29871426f8182658928dcb62e42d57ce8 /web/api/formatters
parentReleasing debian version 1.33.1-1. (diff)
downloadnetdata-bb50acdcb8073654ea667b8c0272e335bd43f844.tar.xz
netdata-bb50acdcb8073654ea667b8c0272e335bd43f844.zip
Merging upstream version 1.34.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/api/formatters')
-rw-r--r--web/api/formatters/README.md2
-rw-r--r--web/api/formatters/csv/README.md2
-rw-r--r--web/api/formatters/json/README.md2
-rw-r--r--web/api/formatters/rrd2json.c33
-rw-r--r--web/api/formatters/rrd2json.h3
-rw-r--r--web/api/formatters/ssv/README.md2
-rw-r--r--web/api/formatters/ssv/ssv.c4
-rw-r--r--web/api/formatters/ssv/ssv.h2
-rw-r--r--web/api/formatters/value/README.md2
-rw-r--r--web/api/formatters/value/value.c6
-rw-r--r--web/api/formatters/value/value.h2
11 files changed, 37 insertions, 23 deletions
diff --git a/web/api/formatters/README.md b/web/api/formatters/README.md
index 1fd2b3029..3e67ac6ee 100644
--- a/web/api/formatters/README.md
+++ b/web/api/formatters/README.md
@@ -75,4 +75,4 @@ For example, to download a CSV file with CPU utilization of the last hour,
This is done by appending `&tqx=outFileName:FILENAME` to any data query.
The output will be in the format given with `&format=`.
-[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fweb%2Fapi%2Fformatters%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)
+
diff --git a/web/api/formatters/csv/README.md b/web/api/formatters/csv/README.md
index 2a859e249..df7c11efa 100644
--- a/web/api/formatters/csv/README.md
+++ b/web/api/formatters/csv/README.md
@@ -141,4 +141,4 @@ And this is how it looks when formatted:
| 2018-10-27 03:44:00 | 7026.9852167 |
| 2018-10-27 03:43:00 | 205.9904794 |
-[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fweb%2Fapi%2Fformatters%2Fcsv%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)
+
diff --git a/web/api/formatters/json/README.md b/web/api/formatters/json/README.md
index 685a3f2df..a0f8108e7 100644
--- a/web/api/formatters/json/README.md
+++ b/web/api/formatters/json/README.md
@@ -153,4 +153,4 @@ google.visualization.Query.setResponse({version:'0.6',reqId:'0',status:'ok',sig:
}});
```
-[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fweb%2Fapi%2Fformatters%2Fjson%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)
+
diff --git a/web/api/formatters/rrd2json.c b/web/api/formatters/rrd2json.c
index 29bb4beb5..1a8b07c7c 100644
--- a/web/api/formatters/rrd2json.c
+++ b/web/api/formatters/rrd2json.c
@@ -167,9 +167,10 @@ int rrdset2value_api_v1(
, time_t *db_after
, time_t *db_before
, int *value_is_null
+ , int timeout
) {
- RRDR *r = rrd2rrdr(st, points, after, before, group_method, group_time, options, dimensions, NULL);
+ RRDR *r = rrd2rrdr(st, points, after, before, group_method, group_time, options, dimensions, NULL, timeout);
if(!r) {
if(value_is_null) *value_is_null = 1;
@@ -197,7 +198,7 @@ int rrdset2value_api_v1(
if(db_before) *db_before = r->before;
long i = (!(options & RRDR_OPTION_REVERSED))?rrdr_rows(r) - 1:0;
- *n = rrdr2value(r, i, options, value_is_null);
+ *n = rrdr2value(r, i, options, value_is_null, NULL);
rrdr_free(r);
return HTTP_RESP_OK;
@@ -217,17 +218,27 @@ int rrdset2anything_api_v1(
, time_t *latest_timestamp
, struct context_param *context_param_list
, char *chart_label_key
-) {
-
+ , int max_anomaly_rates
+ , int timeout
+)
+{
if (context_param_list && !(context_param_list->flags & CONTEXT_FLAGS_ARCHIVE))
st->last_accessed_time = now_realtime_sec();
- RRDR *r = rrd2rrdr(st, points, after, before, group_method, group_time, options, dimensions?buffer_tostring(dimensions):NULL, context_param_list);
+ RRDR *r = rrd2rrdr(st, points, after, before, group_method, group_time, options, dimensions?buffer_tostring(dimensions):NULL, context_param_list, timeout);
if(!r) {
buffer_strcat(wb, "Cannot generate output with these parameters on this chart.");
return HTTP_RESP_INTERNAL_SERVER_ERROR;
}
+ if (r->result_options & RRDR_RESULT_OPTION_CANCEL) {
+ rrdr_free(r);
+ return HTTP_RESP_BACKEND_FETCH_FAILED;
+ }
+
+ if (st && st->state && st->state->is_ar_chart)
+ ml_process_rrdr(r, max_anomaly_rates);
+
RRDDIM *temp_rd = context_param_list ? context_param_list->rd : NULL;
if(r->result_options & RRDR_RESULT_OPTION_RELATIVE)
@@ -243,12 +254,12 @@ int rrdset2anything_api_v1(
if(options & RRDR_OPTION_JSON_WRAP) {
wb->contenttype = CT_APPLICATION_JSON;
rrdr_json_wrapper_begin(r, wb, format, options, 1, context_param_list, chart_label_key);
- rrdr2ssv(r, wb, options, "", " ", "");
+ rrdr2ssv(r, wb, options, "", " ", "", temp_rd);
rrdr_json_wrapper_end(r, wb, format, options, 1);
}
else {
wb->contenttype = CT_TEXT_PLAIN;
- rrdr2ssv(r, wb, options, "", " ", "");
+ rrdr2ssv(r, wb, options, "", " ", "", temp_rd);
}
break;
@@ -256,12 +267,12 @@ int rrdset2anything_api_v1(
if(options & RRDR_OPTION_JSON_WRAP) {
wb->contenttype = CT_APPLICATION_JSON;
rrdr_json_wrapper_begin(r, wb, format, options, 1, context_param_list, chart_label_key);
- rrdr2ssv(r, wb, options, "", ",", "");
+ rrdr2ssv(r, wb, options, "", ",", "", temp_rd);
rrdr_json_wrapper_end(r, wb, format, options, 1);
}
else {
wb->contenttype = CT_TEXT_PLAIN;
- rrdr2ssv(r, wb, options, "", ",", "");
+ rrdr2ssv(r, wb, options, "", ",", "", temp_rd);
}
break;
@@ -269,12 +280,12 @@ int rrdset2anything_api_v1(
if(options & RRDR_OPTION_JSON_WRAP) {
wb->contenttype = CT_APPLICATION_JSON;
rrdr_json_wrapper_begin(r, wb, format, options, 0, context_param_list, chart_label_key);
- rrdr2ssv(r, wb, options, "[", ",", "]");
+ rrdr2ssv(r, wb, options, "[", ",", "]", temp_rd);
rrdr_json_wrapper_end(r, wb, format, options, 0);
}
else {
wb->contenttype = CT_APPLICATION_JSON;
- rrdr2ssv(r, wb, options, "[", ",", "]");
+ rrdr2ssv(r, wb, options, "[", ",", "]", temp_rd);
}
break;
diff --git a/web/api/formatters/rrd2json.h b/web/api/formatters/rrd2json.h
index 3dc598973..af809c54f 100644
--- a/web/api/formatters/rrd2json.h
+++ b/web/api/formatters/rrd2json.h
@@ -67,6 +67,8 @@ extern int rrdset2anything_api_v1(
, time_t *latest_timestamp
, struct context_param *context_param_list
, char *chart_label_key
+ , int max_anomaly_rates
+ , int timeout
);
extern int rrdset2value_api_v1(
@@ -83,6 +85,7 @@ extern int rrdset2value_api_v1(
, time_t *db_after
, time_t *db_before
, int *value_is_null
+ , int timeout
);
extern void build_context_param_list(struct context_param **param_list, RRDSET *st);
diff --git a/web/api/formatters/ssv/README.md b/web/api/formatters/ssv/README.md
index d439949a5..d9e193d66 100644
--- a/web/api/formatters/ssv/README.md
+++ b/web/api/formatters/ssv/README.md
@@ -56,4 +56,4 @@ in a JSON array:
[278,258,268,239,259,260,243,266,278,318,264,258]
```
-[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fweb%2Fapi%2Fformatters%2Fssv%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)
+
diff --git a/web/api/formatters/ssv/ssv.c b/web/api/formatters/ssv/ssv.c
index eeba0283d..8d3ddbfdf 100644
--- a/web/api/formatters/ssv/ssv.c
+++ b/web/api/formatters/ssv/ssv.c
@@ -2,7 +2,7 @@
#include "ssv.h"
-void rrdr2ssv(RRDR *r, BUFFER *wb, RRDR_OPTIONS options, const char *prefix, const char *separator, const char *suffix) {
+void rrdr2ssv(RRDR *r, BUFFER *wb, RRDR_OPTIONS options, const char *prefix, const char *separator, const char *suffix, RRDDIM *temp_rd) {
//info("RRD2SSV(): %s: BEGIN", r->st->id);
long i;
@@ -17,7 +17,7 @@ void rrdr2ssv(RRDR *r, BUFFER *wb, RRDR_OPTIONS options, const char *prefix, con
// for each line in the array
for(i = start; i != end ;i += step) {
int all_values_are_null = 0;
- calculated_number v = rrdr2value(r, i, options, &all_values_are_null);
+ calculated_number v = rrdr2value(r, i, options, &all_values_are_null, temp_rd);
if(likely(i != start)) {
if(r->min > v) r->min = v;
diff --git a/web/api/formatters/ssv/ssv.h b/web/api/formatters/ssv/ssv.h
index 6963dcf6e..66716b9c9 100644
--- a/web/api/formatters/ssv/ssv.h
+++ b/web/api/formatters/ssv/ssv.h
@@ -5,6 +5,6 @@
#include "../rrd2json.h"
-extern void rrdr2ssv(RRDR *r, BUFFER *wb, RRDR_OPTIONS options, const char *prefix, const char *separator, const char *suffix);
+extern void rrdr2ssv(RRDR *r, BUFFER *wb, RRDR_OPTIONS options, const char *prefix, const char *separator, const char *suffix, RRDDIM *temp_rd);
#endif //NETDATA_API_FORMATTER_SSV_H
diff --git a/web/api/formatters/value/README.md b/web/api/formatters/value/README.md
index 21c937080..a51e32de7 100644
--- a/web/api/formatters/value/README.md
+++ b/web/api/formatters/value/README.md
@@ -21,4 +21,4 @@ The Value formatter is not exposed by the API by itself.
Instead it is used by the [`ssv`](/web/api/formatters/ssv/README.md) formatter
and [health monitoring queries](/health/README.md).
-[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fweb%2Fapi%2Fformatters%2Fvalue%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)
+
diff --git a/web/api/formatters/value/value.c b/web/api/formatters/value/value.c
index a69af6165..9ac91f509 100644
--- a/web/api/formatters/value/value.c
+++ b/web/api/formatters/value/value.c
@@ -3,7 +3,7 @@
#include "value.h"
-inline calculated_number rrdr2value(RRDR *r, long i, RRDR_OPTIONS options, int *all_values_are_null) {
+inline calculated_number rrdr2value(RRDR *r, long i, RRDR_OPTIONS options, int *all_values_are_null, RRDDIM *temp_rd) {
if (r->st_needs_lock)
rrdset_check_rdlock(r->st);
@@ -20,7 +20,7 @@ inline calculated_number rrdr2value(RRDR *r, long i, RRDR_OPTIONS options, int *
int set_min_max = 0;
if(unlikely(options & RRDR_OPTION_PERCENTAGE)) {
total = 0;
- for(c = 0, d = r->st->dimensions; d && c < r->d ;c++, d = d->next) {
+ for (c = 0, d = temp_rd ? temp_rd : r->st->dimensions; d && c < r->d; c++, d = d->next) {
calculated_number n = cn[c];
if(likely((options & RRDR_OPTION_ABSOLUTE) && n < 0))
@@ -34,7 +34,7 @@ inline calculated_number rrdr2value(RRDR *r, long i, RRDR_OPTIONS options, int *
}
// for each dimension
- for(c = 0, d = r->st->dimensions; d && c < r->d ;c++, d = d->next) {
+ for (c = 0, d = temp_rd ? temp_rd : r->st->dimensions; d && c < r->d; c++, d = d->next) {
if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue;
if(unlikely((options & RRDR_OPTION_NONZERO) && !(r->od[c] & RRDR_DIMENSION_NONZERO))) continue;
diff --git a/web/api/formatters/value/value.h b/web/api/formatters/value/value.h
index d9e981f88..2d6bd1242 100644
--- a/web/api/formatters/value/value.h
+++ b/web/api/formatters/value/value.h
@@ -5,6 +5,6 @@
#include "../rrd2json.h"
-extern calculated_number rrdr2value(RRDR *r, long i, RRDR_OPTIONS options, int *all_values_are_null);
+extern calculated_number rrdr2value(RRDR *r, long i, RRDR_OPTIONS options, int *all_values_are_null, RRDDIM *temp_rd);
#endif //NETDATA_API_FORMATTER_VALUE_H