summaryrefslogtreecommitdiffstats
path: root/web/api/queries
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-20 04:50:01 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-20 04:50:01 +0000
commitcd4377fab21e0f500bef7f06543fa848a039c1e0 (patch)
treeba00a55e430c052d6bed0b61c0f8bbe8ebedd313 /web/api/queries
parentReleasing debian version 1.40.1-1. (diff)
downloadnetdata-cd4377fab21e0f500bef7f06543fa848a039c1e0.tar.xz
netdata-cd4377fab21e0f500bef7f06543fa848a039c1e0.zip
Merging upstream version 1.41.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/api/queries')
-rw-r--r--web/api/queries/query.c23
-rw-r--r--web/api/queries/rrdr.h20
-rw-r--r--web/api/queries/weights.c16
3 files changed, 36 insertions, 23 deletions
diff --git a/web/api/queries/query.c b/web/api/queries/query.c
index a0347f6fe..74a925bc3 100644
--- a/web/api/queries/query.c
+++ b/web/api/queries/query.c
@@ -1627,7 +1627,7 @@ static void rrd2rrdr_query_execute(RRDR *r, size_t dim_id_in_rrdr, QUERY_ENGINE_
new_point.sp.start_time_s = last1_point.sp.end_time_s;
new_point.sp.end_time_s = now_end_time;
//
-// if(debug_this) info("QUERY: is finished() returned true");
+// if(debug_this) netdata_log_info("QUERY: is finished() returned true");
//
break;
}
@@ -1687,7 +1687,7 @@ static void rrd2rrdr_query_execute(RRDR *r, size_t dim_id_in_rrdr, QUERY_ENGINE_
query_point_set_id(new_point, ops->db_total_points_read);
// if(debug_this)
-// info("QUERY: got point %zu, from time %ld to %ld // now from %ld to %ld // query from %ld to %ld",
+// netdata_log_info("QUERY: got point %zu, from time %ld to %ld // now from %ld to %ld // query from %ld to %ld",
// new_point.id, new_point.start_time, new_point.end_time, now_start_time, now_end_time, after_wanted, before_wanted);
//
// get the right value from the point we got
@@ -1952,7 +1952,7 @@ void rrdr_fill_tier_gap_from_smaller_tiers(RRDDIM *rd, size_t tier, time_t now_s
if(unlikely(!t)) return;
time_t latest_time_s = storage_engine_latest_time_s(t->backend, t->db_metric_handle);
- time_t granularity = (time_t)t->tier_grouping * (time_t)rd->update_every;
+ time_t granularity = (time_t)t->tier_grouping * (time_t)rd->rrdset->update_every;
time_t time_diff = now_s - latest_time_s;
// if the user wants only NEW backfilling, and we don't have any data
@@ -2158,7 +2158,7 @@ bool rrdr_relative_window_to_absolute(time_t *after, time_t *before, time_t *now
#define query_debug_log_init() BUFFER *debug_log = buffer_create(1000)
#define query_debug_log(args...) buffer_sprintf(debug_log, ##args)
#define query_debug_log_fin() { \
- info("QUERY: '%s', after:%ld, before:%ld, duration:%ld, points:%zu, res:%ld - wanted => after:%ld, before:%ld, points:%zu, group:%zu, granularity:%ld, resgroup:%ld, resdiv:" NETDATA_DOUBLE_FORMAT_AUTO " %s", qt->id, after_requested, before_requested, before_requested - after_requested, points_requested, resampling_time_requested, after_wanted, before_wanted, points_wanted, group, query_granularity, resampling_group, resampling_divisor, buffer_tostring(debug_log)); \
+ netdata_log_info("QUERY: '%s', after:%ld, before:%ld, duration:%ld, points:%zu, res:%ld - wanted => after:%ld, before:%ld, points:%zu, group:%zu, granularity:%ld, resgroup:%ld, resdiv:" NETDATA_DOUBLE_FORMAT_AUTO " %s", qt->id, after_requested, before_requested, before_requested - after_requested, points_requested, resampling_time_requested, after_wanted, before_wanted, points_wanted, group, query_granularity, resampling_group, resampling_divisor, buffer_tostring(debug_log)); \
buffer_free(debug_log); \
debug_log = NULL; \
}
@@ -2516,13 +2516,6 @@ void rrdr_json_group_by_labels(BUFFER *wb, const char *key, RRDR *r, RRDR_OPTION
buffer_json_object_close(wb); // key
}
-static int group_by_label_is_space(char c) {
- if(c == ',' || c == '|')
- return 1;
-
- return 0;
-}
-
static void rrd2rrdr_set_timestamps(RRDR *r) {
QUERY_TARGET *qt = r->internal.qt;
@@ -2755,9 +2748,9 @@ static RRDR *rrd2rrdr_group_by_initialize(ONEWAYALLOC *owa, 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_LABEL &&
qt->request.group_by[g].group_by_label && *qt->request.group_by[g].group_by_label)
- qt->group_by[g].used = quoted_strings_splitter(
+ qt->group_by[g].used = quoted_strings_splitter_query_group_by_label(
qt->request.group_by[g].group_by_label, qt->group_by[g].label_keys,
- GROUP_BY_MAX_LABEL_KEYS, group_by_label_is_space);
+ GROUP_BY_MAX_LABEL_KEYS);
if (!qt->group_by[g].used)
qt->request.group_by[g].group_by &= ~RRDR_GROUP_BY_LABEL;
@@ -3692,12 +3685,12 @@ RRDR *rrd2rrdr(ONEWAYALLOC *owa, QUERY_TARGET *qt) {
bool cancel = false;
if (qt->request.interrupt_callback && qt->request.interrupt_callback(qt->request.interrupt_callback_data)) {
cancel = true;
- log_access("QUERY INTERRUPTED");
+ netdata_log_access("QUERY INTERRUPTED");
}
if (qt->request.timeout_ms && ((NETDATA_DOUBLE)(now_ut - qt->timings.received_ut) / 1000.0) > (NETDATA_DOUBLE)qt->request.timeout_ms) {
cancel = true;
- log_access("QUERY CANCELED RUNTIME EXCEEDED %0.2f ms (LIMIT %lld ms)",
+ netdata_log_access("QUERY CANCELED RUNTIME EXCEEDED %0.2f ms (LIMIT %lld ms)",
(NETDATA_DOUBLE)(now_ut - qt->timings.received_ut) / 1000.0, (long long)qt->request.timeout_ms);
}
diff --git a/web/api/queries/rrdr.h b/web/api/queries/rrdr.h
index c57be67f5..c4a1f83f2 100644
--- a/web/api/queries/rrdr.h
+++ b/web/api/queries/rrdr.h
@@ -51,6 +51,26 @@ typedef enum rrdr_options {
RRDR_OPTION_INTERNAL_AR = (1 << 31), // internal use only, to let the formatters know we want to render the anomaly rate
} RRDR_OPTIONS;
+typedef enum context_v2_options {
+ CONTEXT_V2_OPTION_MINIFY = (1 << 0), // remove JSON spaces and newlines from JSON output
+ CONTEXT_V2_OPTION_DEBUG = (1 << 1), // show the request
+ CONTEXT_V2_OPTION_ALERTS_WITH_CONFIGURATIONS = (1 << 2), // include alert configurations (used by /api/v2/alert_transitions)
+ CONTEXT_V2_OPTION_ALERTS_WITH_INSTANCES = (1 << 3), // include alert instances (used by /api/v2/alerts)
+ CONTEXT_V2_OPTION_ALERTS_WITH_VALUES = (1 << 4), // include alert latest values (used by /api/v2/alerts)
+ CONTEXT_V2_OPTION_ALERTS_WITH_SUMMARY = (1 << 5), // include alerts summary counters (used by /api/v2/alerts)
+} CONTEXTS_V2_OPTIONS;
+
+typedef enum context_v2_alert_status {
+ CONTEXT_V2_ALERT_UNINITIALIZED = (1 << 5), // include UNINITIALIZED alerts
+ CONTEXT_V2_ALERT_UNDEFINED = (1 << 6), // include UNDEFINED alerts
+ CONTEXT_V2_ALERT_CLEAR = (1 << 7), // include CLEAR alerts
+ CONTEXT_V2_ALERT_RAISED = (1 << 8), // include WARNING & CRITICAL alerts
+ CONTEXT_V2_ALERT_WARNING = (1 << 9), // include WARNING alerts
+ CONTEXT_V2_ALERT_CRITICAL = (1 << 10), // include CRITICAL alerts
+} CONTEXTS_V2_ALERT_STATUS;
+
+#define CONTEXTS_V2_ALERT_STATUSES (CONTEXT_V2_ALERT_UNINITIALIZED|CONTEXT_V2_ALERT_UNDEFINED|CONTEXT_V2_ALERT_CLEAR|CONTEXT_V2_ALERT_RAISED|CONTEXT_V2_ALERT_WARNING|CONTEXT_V2_ALERT_CRITICAL)
+
typedef enum __attribute__ ((__packed__)) rrdr_value_flag {
// IMPORTANT:
diff --git a/web/api/queries/weights.c b/web/api/queries/weights.c
index 0830a969a..8ffd8951a 100644
--- a/web/api/queries/weights.c
+++ b/web/api/queries/weights.c
@@ -874,7 +874,7 @@ static size_t registered_results_to_json_multinode_no_group_by(
continue;
buffer_json_add_array_item_object(wb);
- buffer_json_node_add_v2(wb, dun->host, dun->i, dun->duration_ut);
+ buffer_json_node_add_v2(wb, dun->host, dun->i, dun->duration_ut, true);
buffer_json_object_close(wb);
}
dfe_done(dun);
@@ -936,7 +936,7 @@ static size_t registered_results_to_json_multinode_no_group_by(
buffer_json_object_close(wb); //dictionaries
- buffer_json_agents_array_v2(wb, &qwd->timings, 0);
+ buffer_json_agents_v2(wb, &qwd->timings, 0, false, true);
buffer_json_member_add_uint64(wb, "correlated_dimensions", total_dimensions);
buffer_json_member_add_uint64(wb, "total_dimensions_count", examined_dimensions);
buffer_json_finalize(wb);
@@ -1067,7 +1067,7 @@ static size_t registered_results_to_json_multinode_group_by(
dfe_done(aw);
buffer_json_array_close(wb); // result
- buffer_json_agents_array_v2(wb, &qwd->timings, 0);
+ buffer_json_agents_v2(wb, &qwd->timings, 0, false, true);
buffer_json_member_add_uint64(wb, "correlated_dimensions", total_dimensions);
buffer_json_member_add_uint64(wb, "total_dimensions_count", examined_dimensions);
buffer_json_finalize(wb);
@@ -1244,7 +1244,7 @@ static double kstwo(
return NAN;
if(unlikely(base_size != baseline_points - 1 || high_size != highlight_points - 1)) {
- error("Metric correlations: internal error - calculate_pairs_diff() returns the wrong number of entries");
+ netdata_log_error("Metric correlations: internal error - calculate_pairs_diff() returns the wrong number of entries");
return NAN;
}
@@ -1292,7 +1292,7 @@ NETDATA_DOUBLE *rrd2rrdr_ks2(
stats->db_points_per_tier[tr] += r->internal.qt->db.tiers[tr].points;
if(r->d != 1 || r->internal.qt->query.used != 1) {
- error("WEIGHTS: on query '%s' expected 1 dimension in RRDR but got %zu r->d and %zu qt->query.used",
+ netdata_log_error("WEIGHTS: on query '%s' expected 1 dimension in RRDR but got %zu r->d and %zu qt->query.used",
r->internal.qt->id, r->d, (size_t)r->internal.qt->query.used);
goto cleanup;
}
@@ -1368,11 +1368,11 @@ static void rrdset_metric_correlations_ks2(
// these conditions should never happen, but still let's check
if(unlikely(prob < 0.0)) {
- error("Metric correlations: kstwo() returned a negative number: %f", prob);
+ netdata_log_error("Metric correlations: kstwo() returned a negative number: %f", prob);
prob = -prob;
}
if(unlikely(prob > 1.0)) {
- error("Metric correlations: kstwo() returned a number above 1.0: %f", prob);
+ netdata_log_error("Metric correlations: kstwo() returned a number above 1.0: %f", prob);
prob = 1.0;
}
@@ -1447,7 +1447,7 @@ static void rrdset_metric_correlations_volume(
merge_query_value_to_stats(&highlight_countif, stats, 1);
if(!netdata_double_isnumber(highlight_countif.value)) {
- info("WEIGHTS: highlighted countif query failed, but highlighted average worked - strange...");
+ netdata_log_info("WEIGHTS: highlighted countif query failed, but highlighted average worked - strange...");
return;
}