diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2023-03-21 21:53:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-21 21:53:47 +0200 |
commit | 5eed0545d46c3d227b87a23b0d0362a4f63e1bf0 (patch) | |
tree | f1d539574341a513d688277f3854ac055e1940ae /aclk | |
parent | 757c01aacfbe8cae892935a262f180c52355b874 (diff) |
/api/v2/X part 5 (#14718)
* query timestamps are now pre-determined and alignment on timestamps is guarranteed
* turn internal_fatal() to internal_error() to investigate the issue
* handle query when no data exist in the db
* check for non NULL dict when running dictionary garbage collect
* support API v2 requests via ACLK
* add nodes detailed information to /api/v2/nodes
* fixed keys and added dummy nodes for completeness
* added nodes_hard_hash, alerts_hard_hash, alerts_soft_hash; started building a nodes status object to reflect the current status of a node
* make sure replication does not double count charts that are already being replicated
* expose min and max in sts structures
* added view_minimum_value and view_maximum_value; percentage calculation is now an additional pass on the data, removed from formatters; absolute value calculation is now done at the query level, removed from formatters
* respect trimming in percentage calculation; updated swagger
* api/v2/weights preparative work to support multi-node queries - still single node though
* multi-node /api/v2/weights endpoint, supporting all the filtering parameters of /api/v2/data
* when passing the raw option, the query exposes the hidden dimensions
* fix compilation issues on older systems
* the query engine now calculates per dimension min, max, sum, count, anomaly count
* use the macro to calculate storage point anomaly rate
* weights endpoint exposing version hashes
* weights method=value shows min, max, average, sum, count, anomaly count, anomaly rate
* query: expose RESET flag; do not add the same point multiple times to the aggregated point
* weights: more compact output
* weights requests can be interrupted
* all /api/v2 requests can be interrupted and timeout
* allow relative timestamps in weights
* fix macos compilation warnings
* Revert "fix macos compilation warnings"
This reverts commit 8a1d24e41e9b58de566ac59f0c4b1c465bcc0592.
* /api/v2/data group-by now works on dimension names, not ids
* /api/v2/weights does not query metrics without retention and new output format
* /api/v2/weights value and anomaly queries do context queries when contexts are filtered; query timeout is now always in ms
Diffstat (limited to 'aclk')
-rw-r--r-- | aclk/aclk_query.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/aclk/aclk_query.c b/aclk/aclk_query.c index 965cb979f8..6ad2c43b70 100644 --- a/aclk/aclk_query.c +++ b/aclk/aclk_query.c @@ -11,12 +11,17 @@ pthread_mutex_t query_lock_wait = PTHREAD_MUTEX_INITIALIZER; #define QUERY_THREAD_LOCK pthread_mutex_lock(&query_lock_wait) #define QUERY_THREAD_UNLOCK pthread_mutex_unlock(&query_lock_wait) -static usec_t aclk_web_api_v1_request(RRDHOST *host, struct web_client *w, char *url) +static usec_t aclk_web_api_request(RRDHOST *host, struct web_client *w, char *url, const size_t api_version) { usec_t t; t = now_monotonic_high_precision_usec(); - w->response.code = web_client_api_request_v1(host, w, url); + + if(api_version == 2) + w->response.code = web_client_api_request_v2(host, w, url); + else + w->response.code = web_client_api_request_v1(host, w, url); + t = now_monotonic_high_precision_usec() - t; if (aclk_stats_enabled) { @@ -119,6 +124,16 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query) } } + size_t api_version = 1; + { + char *s = strstr(query->data.http_api_v2.query, "/api/v"); + if(s && s[6]) { + api_version = str2u(&s[6]); + if(api_version != 1 && api_version != 2) + api_version = 1; + } + } + char *mysep = strchr(query->data.http_api_v2.query, '?'); if (mysep) { url_decode_r(w->decoded_query_string, mysep, NETDATA_WEB_REQUEST_URL_SIZE + 1); @@ -136,7 +151,7 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query) } // execute the query - t = aclk_web_api_v1_request(query_host, w, mysep ? mysep + 1 : "noop"); + t = aclk_web_api_request(query_host, w, mysep ? mysep + 1 : "noop", api_version); size = (w->mode == WEB_CLIENT_MODE_FILECOPY) ? w->response.rlen : w->response.data->len; sent = size; |