summaryrefslogtreecommitdiffstats
path: root/health
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2023-02-15 21:16:29 +0200
committerGitHub <noreply@github.com>2023-02-15 21:16:29 +0200
commitd2daa19bf53c9a8cb781c8e50a86b9961b0503a9 (patch)
tree8d8b744138c28e010a24456aee55447d31a719bd /health
parent37a918ae2bc996fc881ab60042ae5a8f434f4c52 (diff)
JSON internal API, IEEE754 base64/hex streaming, weights endpoint optimization (#14493)
* first work on standardizing json formatting * renamed old grouping to time_grouping and added group_by * add dummy functions to enable compilation * buffer json api work * jsonwrap opening with buffer_json_X() functions * cleanup * storage for quotes * optimize buffer printing for both numbers and strings * removed ; from define * contexts json generation using the new json functions * fix buffer overflow at unit test * weights endpoint using new json api * fixes to weights endpoint * check buffer overflow on all buffer functions * do synchronous queries for weights * buffer_flush() now resets json state too * content type typedef * print double values that are above the max 64-bit value * str2ndd() can now parse values above UINT64_MAX * faster number parsing by avoiding double calculations as much as possible * faster number parsing * faster hex parsing * accurate printing and parsing of double values, even for very large numbers that cannot fit in 64bit integers * full printing and parsing without using library functions - and related unit tests * added IEEE754 streaming capability to enable streaming of double values in hex * streaming and replication to transfer all values in hex * use our own str2ndd for set2 * remove subnormal check from ieee * base64 encoding for numbers, instead of hex * when increasing double precision, also make sure the fractional number printed is aligned to the wanted precision * str2ndd_encoded() parses all encoding formats, including integers * prevent uninitialized use * /api/v1/info using the new json API * Fix error when compiling with --disable-ml * Remove redundant 'buffer_unittest' declaration * Fix formatting * Fix formatting * Fix formatting * fix buffer unit test * apps.plugin using the new JSON API * make sure the metrics registry does not accept negative timestamps * do not allow pages with negative timestamps to be loaded from db files; do not accept pages with negative timestamps in the cache * Fix more formatting --------- Co-authored-by: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com>
Diffstat (limited to 'health')
-rw-r--r--health/health_config.c8
-rw-r--r--health/health_json.c22
2 files changed, 15 insertions, 15 deletions
diff --git a/health/health_config.c b/health/health_config.c
index 1d2b2da297..0248ba0e46 100644
--- a/health/health_config.c
+++ b/health/health_config.c
@@ -260,7 +260,7 @@ static SIMPLE_PATTERN *health_pattern_from_foreach(const char *s) {
static inline int health_parse_db_lookup(
size_t line, const char *filename, char *string,
- RRDR_GROUPING *group_method, int *after, int *before, int *every,
+ RRDR_TIME_GROUPING *group_method, int *after, int *before, int *every,
RRDCALC_OPTIONS *options, STRING **dimensions, STRING **foreachdim
) {
debug(D_HEALTH, "Health configuration parsing database lookup %zu@%s: %s", line, filename, string);
@@ -286,7 +286,7 @@ static inline int health_parse_db_lookup(
return 0;
}
- if((*group_method = web_client_api_request_v1_data_group(key, RRDR_GROUPING_UNDEFINED)) == RRDR_GROUPING_UNDEFINED) {
+ if((*group_method = time_grouping_parse(key, RRDR_GROUPING_UNDEFINED)) == RRDR_GROUPING_UNDEFINED) {
error("Health configuration at line %zu of file '%s': invalid group method '%s'",
line, filename, key);
return 0;
@@ -773,7 +773,7 @@ static int health_readfile(const char *filename, void *data) {
if (rc->dimensions)
alert_cfg->p_db_lookup_dimensions = string_dup(rc->dimensions);
if (rc->group)
- alert_cfg->p_db_lookup_method = string_strdupz(group_method2string(rc->group));
+ alert_cfg->p_db_lookup_method = string_strdupz(time_grouping_method2string(rc->group));
alert_cfg->p_db_lookup_options = rc->options;
alert_cfg->p_db_lookup_after = rc->after;
alert_cfg->p_db_lookup_before = rc->before;
@@ -1037,7 +1037,7 @@ static int health_readfile(const char *filename, void *data) {
alert_cfg->p_db_lookup_dimensions = string_dup(rt->dimensions);
if (rt->group)
- alert_cfg->p_db_lookup_method = string_strdupz(group_method2string(rt->group));
+ alert_cfg->p_db_lookup_method = string_strdupz(time_grouping_method2string(rt->group));
alert_cfg->p_db_lookup_options = rt->options;
alert_cfg->p_db_lookup_after = rt->after;
diff --git a/health/health_json.c b/health/health_json.c
index 8cabaa0bf1..5708a3b769 100644
--- a/health/health_json.c
+++ b/health/health_json.c
@@ -103,11 +103,11 @@ void health_alarm_entry2json_nolock(BUFFER *wb, ALARM_ENTRY *ae, RRDHOST *host)
}
buffer_strcat(wb, "\t\t\"value\":");
- buffer_rrd_value(wb, ae->new_value);
+ buffer_print_netdata_double(wb, ae->new_value);
buffer_strcat(wb, ",\n");
buffer_strcat(wb, "\t\t\"old_value\":");
- buffer_rrd_value(wb, ae->old_value);
+ buffer_print_netdata_double(wb, ae->old_value);
buffer_strcat(wb, "\n");
buffer_strcat(wb, "\t}");
@@ -152,7 +152,7 @@ static inline void health_rrdcalc_values2json_nolock(RRDHOST *host, BUFFER *wb,
, (unsigned long)rc->id);
buffer_strcat(wb, "\t\t\t\"value\":");
- buffer_rrd_value(wb, rc->value);
+ buffer_print_netdata_double(wb, rc->value);
buffer_strcat(wb, ",\n");
buffer_strcat(wb, "\t\t\t\"last_updated\":");
@@ -257,11 +257,11 @@ static inline void health_rrdcalc2json_nolock(RRDHOST *host, BUFFER *wb, RRDCALC
"\t\t\t\"lookup_after\": %d,\n"
"\t\t\t\"lookup_before\": %d,\n"
"\t\t\t\"lookup_options\": \"",
- (unsigned long) rc->db_after,
- (unsigned long) rc->db_before,
- group_method2string(rc->group),
- rc->after,
- rc->before
+ (unsigned long) rc->db_after,
+ (unsigned long) rc->db_before,
+ time_grouping_method2string(rc->group),
+ rc->after,
+ rc->before
);
buffer_data_options2string(wb, rc->options);
buffer_strcat(wb, "\",\n");
@@ -283,15 +283,15 @@ static inline void health_rrdcalc2json_nolock(RRDHOST *host, BUFFER *wb, RRDCALC
}
buffer_strcat(wb, "\t\t\t\"green\":");
- buffer_rrd_value(wb, rc->green);
+ buffer_print_netdata_double(wb, rc->green);
buffer_strcat(wb, ",\n");
buffer_strcat(wb, "\t\t\t\"red\":");
- buffer_rrd_value(wb, rc->red);
+ buffer_print_netdata_double(wb, rc->red);
buffer_strcat(wb, ",\n");
buffer_strcat(wb, "\t\t\t\"value\":");
- buffer_rrd_value(wb, rc->value);
+ buffer_print_netdata_double(wb, rc->value);
buffer_strcat(wb, "\n");
buffer_strcat(wb, "\t\t}");