diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-07-20 04:50:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-07-20 04:50:01 +0000 |
commit | cd4377fab21e0f500bef7f06543fa848a039c1e0 (patch) | |
tree | ba00a55e430c052d6bed0b61c0f8bbe8ebedd313 /exporting | |
parent | Releasing debian version 1.40.1-1. (diff) | |
download | netdata-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 'exporting')
-rw-r--r-- | exporting/README.md | 2 | ||||
-rw-r--r-- | exporting/aws_kinesis/aws_kinesis.c | 39 | ||||
-rw-r--r-- | exporting/check_filters.c | 10 | ||||
-rw-r--r-- | exporting/clean_connectors.c | 4 | ||||
-rw-r--r-- | exporting/exporting_engine.c | 12 | ||||
-rw-r--r-- | exporting/exporting_engine.h | 2 | ||||
-rw-r--r-- | exporting/graphite/graphite.c | 6 | ||||
-rw-r--r-- | exporting/init_connectors.c | 12 | ||||
-rw-r--r-- | exporting/json/json.c | 6 | ||||
-rw-r--r-- | exporting/mongodb/mongodb.c | 30 | ||||
-rw-r--r-- | exporting/opentsdb/opentsdb.c | 12 | ||||
-rw-r--r-- | exporting/process_data.c | 24 | ||||
-rw-r--r-- | exporting/prometheus/prometheus.c | 39 | ||||
-rw-r--r-- | exporting/prometheus/remote_write/remote_write.c | 24 | ||||
-rw-r--r-- | exporting/pubsub/pubsub.c | 18 | ||||
-rw-r--r-- | exporting/read_config.c | 30 | ||||
-rw-r--r-- | exporting/send_data.c | 25 | ||||
-rw-r--r-- | exporting/tests/exporting_fixtures.c | 2 |
18 files changed, 151 insertions, 146 deletions
diff --git a/exporting/README.md b/exporting/README.md index 013f86f32..0bab365d5 100644 --- a/exporting/README.md +++ b/exporting/README.md @@ -126,7 +126,7 @@ You can configure each connector individually using the available [options](#opt [prometheus:exporter] send names instead of ids = yes send configured labels = yes - end automatic labels = no + send automatic labels = no send charts matching = * send hosts matching = localhost * prefix = netdata diff --git a/exporting/aws_kinesis/aws_kinesis.c b/exporting/aws_kinesis/aws_kinesis.c index c7d7a9d34..d52c676ac 100644 --- a/exporting/aws_kinesis/aws_kinesis.c +++ b/exporting/aws_kinesis/aws_kinesis.c @@ -7,7 +7,7 @@ */ void aws_kinesis_cleanup(struct instance *instance) { - info("EXPORTING: cleaning up instance %s ...", instance->config.name); + netdata_log_info("EXPORTING: cleaning up instance %s ...", instance->config.name); kinesis_shutdown(instance->connector_specific_data); freez(instance->connector_specific_data); @@ -21,7 +21,7 @@ void aws_kinesis_cleanup(struct instance *instance) freez(connector_specific_config); } - info("EXPORTING: instance %s exited", instance->config.name); + netdata_log_info("EXPORTING: instance %s exited", instance->config.name); instance->exited = 1; } @@ -54,7 +54,8 @@ int init_aws_kinesis_instance(struct instance *instance) instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters); if (!instance->buffer) { - error("EXPORTING: cannot create buffer for AWS Kinesis exporting connector instance %s", instance->config.name); + netdata_log_error("EXPORTING: cannot create buffer for AWS Kinesis exporting connector instance %s", + instance->config.name); return 1; } if (uv_mutex_init(&instance->mutex)) @@ -72,7 +73,7 @@ int init_aws_kinesis_instance(struct instance *instance) instance->connector_specific_data = (void *)connector_specific_data; if (!strcmp(connector_specific_config->stream_name, "")) { - error("stream name is a mandatory Kinesis parameter but it is not configured"); + netdata_log_error("stream name is a mandatory Kinesis parameter but it is not configured"); return 1; } @@ -151,17 +152,16 @@ void aws_kinesis_connector_worker(void *instance_p) } char error_message[ERROR_LINE_MAX + 1] = ""; - debug( - D_EXPORTING, - "EXPORTING: kinesis_put_record(): dest = %s, id = %s, key = %s, stream = %s, partition_key = %s, \ - buffer = %zu, record = %zu", - instance->config.destination, - connector_specific_config->auth_key_id, - connector_specific_config->secure_key, - connector_specific_config->stream_name, - partition_key, - buffer_len, - record_len); + netdata_log_debug(D_EXPORTING, + "EXPORTING: kinesis_put_record(): dest = %s, id = %s, key = %s, stream = %s, partition_key = %s, \ " + " buffer = %zu, record = %zu", + instance->config.destination, + connector_specific_config->auth_key_id, + connector_specific_config->secure_key, + connector_specific_config->stream_name, + partition_key, + buffer_len, + record_len); kinesis_put_record( connector_specific_data, connector_specific_config->stream_name, partition_key, first_char, record_len); @@ -174,10 +174,11 @@ void aws_kinesis_connector_worker(void *instance_p) if (unlikely(kinesis_get_result( connector_specific_data->request_outcomes, error_message, &sent_bytes, &lost_bytes))) { // oops! we couldn't send (all or some of the) data - error("EXPORTING: %s", error_message); - error( - "EXPORTING: failed to write data to external database '%s'. Willing to write %zu bytes, wrote %zu bytes.", - instance->config.destination, sent_bytes, sent_bytes - lost_bytes); + netdata_log_error("EXPORTING: %s", error_message); + netdata_log_error("EXPORTING: failed to write data to external database '%s'. Willing to write %zu bytes, wrote %zu bytes.", + instance->config.destination, + sent_bytes, + sent_bytes - lost_bytes); stats->transmission_failures++; stats->data_lost_events++; diff --git a/exporting/check_filters.c b/exporting/check_filters.c index 9b573f02a..a9e48e355 100644 --- a/exporting/check_filters.c +++ b/exporting/check_filters.c @@ -29,10 +29,10 @@ int rrdhost_is_exportable(struct instance *instance, RRDHOST *host) if (!instance->config.hosts_pattern || simple_pattern_matches(instance->config.hosts_pattern, host_name)) { *flags |= RRDHOST_FLAG_EXPORTING_SEND; - info("enabled exporting of host '%s' for instance '%s'", host_name, instance->config.name); + netdata_log_info("enabled exporting of host '%s' for instance '%s'", host_name, instance->config.name); } else { *flags |= RRDHOST_FLAG_EXPORTING_DONT_SEND; - info("disabled exporting of host '%s' for instance '%s'", host_name, instance->config.name); + netdata_log_info("disabled exporting of host '%s' for instance '%s'", host_name, instance->config.name); } } @@ -69,18 +69,18 @@ int rrdset_is_exportable(struct instance *instance, RRDSET *st) *flags |= RRDSET_FLAG_EXPORTING_SEND; else { *flags |= RRDSET_FLAG_EXPORTING_IGNORE; - debug(D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s', because it is disabled for exporting.", rrdset_id(st), rrdhost_hostname(host)); + netdata_log_debug(D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s', because it is disabled for exporting.", rrdset_id(st), rrdhost_hostname(host)); return 0; } } if(unlikely(!rrdset_is_available_for_exporting_and_alarms(st))) { - debug(D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s', because it is not available for exporting.", rrdset_id(st), rrdhost_hostname(host)); + netdata_log_debug(D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s', because it is not available for exporting.", rrdset_id(st), rrdhost_hostname(host)); return 0; } if(unlikely(st->rrd_memory_mode == RRD_MEMORY_MODE_NONE && !(EXPORTING_OPTIONS_DATA_SOURCE(instance->config.options) == EXPORTING_SOURCE_DATA_AS_COLLECTED))) { - debug(D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s' because its memory mode is '%s' and the exporting engine requires database access.", rrdset_id(st), rrdhost_hostname(host), rrd_memory_mode_name(host->rrd_memory_mode)); + netdata_log_debug(D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s' because its memory mode is '%s' and the exporting engine requires database access.", rrdset_id(st), rrdhost_hostname(host), rrd_memory_mode_name(host->rrd_memory_mode)); return 0; } diff --git a/exporting/clean_connectors.c b/exporting/clean_connectors.c index ab1fb5dd7..c850c5ffa 100644 --- a/exporting/clean_connectors.c +++ b/exporting/clean_connectors.c @@ -46,7 +46,7 @@ void clean_instance(struct instance *instance) */ void simple_connector_cleanup(struct instance *instance) { - info("EXPORTING: cleaning up instance %s ...", instance->config.name); + netdata_log_info("EXPORTING: cleaning up instance %s ...", instance->config.name); struct simple_connector_data *simple_connector_data = (struct simple_connector_data *)instance->connector_specific_data; @@ -77,6 +77,6 @@ void simple_connector_cleanup(struct instance *instance) (struct simple_connector_config *)instance->config.connector_specific_config; freez(simple_connector_config); - info("EXPORTING: instance %s exited", instance->config.name); + netdata_log_info("EXPORTING: instance %s exited", instance->config.name); instance->exited = 1; } diff --git a/exporting/exporting_engine.c b/exporting/exporting_engine.c index 8f957c7c5..f42a36e92 100644 --- a/exporting/exporting_engine.c +++ b/exporting/exporting_engine.c @@ -124,7 +124,7 @@ static void exporting_main_cleanup(void *ptr) struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr; static_thread->enabled = NETDATA_MAIN_THREAD_EXITING; - info("cleaning up..."); + netdata_log_info("cleaning up..."); if (!engine) { static_thread->enabled = NETDATA_MAIN_THREAD_EXITED; @@ -139,17 +139,17 @@ static void exporting_main_cleanup(void *ptr) for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (!instance->exited) { found++; - info("stopping worker for instance %s", instance->config.name); + netdata_log_info("stopping worker for instance %s", instance->config.name); uv_mutex_unlock(&instance->mutex); instance->data_is_ready = 1; uv_cond_signal(&instance->cond_var); } else - info("found stopped worker for instance %s", instance->config.name); + netdata_log_info("found stopped worker for instance %s", instance->config.name); } while (found && max > 0) { max -= step; - info("Waiting %d exporting connectors to finish...", found); + netdata_log_info("Waiting %d exporting connectors to finish...", found); sleep_usec(step); found = 0; @@ -178,12 +178,12 @@ void *exporting_main(void *ptr) engine = read_exporting_config(); if (!engine) { - info("EXPORTING: no exporting connectors configured"); + netdata_log_info("EXPORTING: no exporting connectors configured"); goto cleanup; } if (init_connectors(engine) != 0) { - error("EXPORTING: cannot initialize exporting connectors"); + netdata_log_error("EXPORTING: cannot initialize exporting connectors"); send_statistics("EXPORTING_START", "FAIL", "-"); goto cleanup; } diff --git a/exporting/exporting_engine.h b/exporting/exporting_engine.h index c04bbeec3..fb436e933 100644 --- a/exporting/exporting_engine.h +++ b/exporting/exporting_engine.h @@ -307,7 +307,7 @@ static inline void disable_instance(struct instance *instance) instance->disabled = 1; instance->scheduled = 0; uv_mutex_unlock(&instance->mutex); - error("EXPORTING: Instance %s disabled", instance->config.name); + netdata_log_error("EXPORTING: Instance %s disabled", instance->config.name); } #include "exporting/prometheus/prometheus.h" diff --git a/exporting/graphite/graphite.c b/exporting/graphite/graphite.c index 3aff24926..254db982e 100644 --- a/exporting/graphite/graphite.c +++ b/exporting/graphite/graphite.c @@ -49,7 +49,7 @@ int init_graphite_instance(struct instance *instance) instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters); if (!instance->buffer) { - error("EXPORTING: cannot create buffer for graphite exporting connector instance %s", instance->config.name); + netdata_log_error("EXPORTING: cannot create buffer for graphite exporting connector instance %s", instance->config.name); return 1; } @@ -141,8 +141,8 @@ int format_dimension_collected_graphite_plaintext(struct instance *instance, RRD (host->tags) ? ";" : "", (host->tags) ? rrdhost_tags(host) : "", (instance->labels_buffer) ? buffer_tostring(instance->labels_buffer) : "", - rd->last_collected_value, - (unsigned long long)rd->last_collected_time.tv_sec); + rd->collector.last_collected_value, + (unsigned long long)rd->collector.last_collected_time.tv_sec); return 0; } diff --git a/exporting/init_connectors.c b/exporting/init_connectors.c index 15e1951f8..5167a68c2 100644 --- a/exporting/init_connectors.c +++ b/exporting/init_connectors.c @@ -85,14 +85,14 @@ int init_connectors(struct engine *engine) #endif break; default: - error("EXPORTING: unknown exporting connector type"); + netdata_log_error("EXPORTING: unknown exporting connector type"); return 1; } // dispatch the instance worker thread int error = uv_thread_create(&instance->thread, instance->worker, instance); if (error) { - error("EXPORTING: cannot create thread worker. uv_thread_create(): %s", uv_strerror(error)); + netdata_log_error("EXPORTING: cannot create thread worker. uv_thread_create(): %s", uv_strerror(error)); return 1; } char threadname[NETDATA_THREAD_NAME_MAX + 1]; @@ -113,7 +113,7 @@ static size_t base64_encode(unsigned char *input, size_t input_size, char *outpu "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; if ((input_size / 3 + 1) * 4 >= output_size) { - error("Output buffer for encoding size=%zu is not large enough for %zu-bytes input", output_size, input_size); + netdata_log_error("Output buffer for encoding size=%zu is not large enough for %zu-bytes input", output_size, input_size); return 0; } size_t count = 0; @@ -123,7 +123,7 @@ static size_t base64_encode(unsigned char *input, size_t input_size, char *outpu output[1] = lookup[(value >> 12) & 0x3f]; output[2] = lookup[(value >> 6) & 0x3f]; output[3] = lookup[value & 0x3f]; - //error("Base-64 encode (%04x) -> %c %c %c %c\n", value, output[0], output[1], output[2], output[3]); + //netdata_log_error("Base-64 encode (%04x) -> %c %c %c %c\n", value, output[0], output[1], output[2], output[3]); output += 4; input += 3; input_size -= 3; @@ -136,7 +136,7 @@ static size_t base64_encode(unsigned char *input, size_t input_size, char *outpu output[1] = lookup[(value >> 6) & 0x3f]; output[2] = lookup[value & 0x3f]; output[3] = '='; - //error("Base-64 encode (%06x) -> %c %c %c %c\n", (value>>2)&0xffff, output[0], output[1], output[2], output[3]); + //netdata_log_error("Base-64 encode (%06x) -> %c %c %c %c\n", (value>>2)&0xffff, output[0], output[1], output[2], output[3]); count += 4; output[4] = '\0'; break; @@ -146,7 +146,7 @@ static size_t base64_encode(unsigned char *input, size_t input_size, char *outpu output[1] = lookup[value & 0x3f]; output[2] = '='; output[3] = '='; - //error("Base-64 encode (%06x) -> %c %c %c %c\n", value, output[0], output[1], output[2], output[3]); + //netdata_log_error("Base-64 encode (%06x) -> %c %c %c %c\n", value, output[0], output[1], output[2], output[3]); count += 4; output[4] = '\0'; break; diff --git a/exporting/json/json.c b/exporting/json/json.c index edbb98ef6..d916fe774 100644 --- a/exporting/json/json.c +++ b/exporting/json/json.c @@ -39,7 +39,7 @@ int init_json_instance(struct instance *instance) instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters); if (!instance->buffer) { - error("EXPORTING: cannot create buffer for json exporting connector instance %s", instance->config.name); + netdata_log_error("EXPORTING: cannot create buffer for json exporting connector instance %s", instance->config.name); return 1; } @@ -200,9 +200,9 @@ int format_dimension_collected_json_plaintext(struct instance *instance, RRDDIM rrdset_units(st), rrddim_id(rd), rrddim_name(rd), - rd->last_collected_value, + rd->collector.last_collected_value, - (unsigned long long)rd->last_collected_time.tv_sec); + (unsigned long long)rd->collector.last_collected_time.tv_sec); if (instance->config.type != EXPORTING_CONNECTOR_TYPE_JSON_HTTP) { buffer_strcat(instance->buffer, "\n"); diff --git a/exporting/mongodb/mongodb.c b/exporting/mongodb/mongodb.c index 186a7dcfd..c65f8d4cc 100644 --- a/exporting/mongodb/mongodb.c +++ b/exporting/mongodb/mongodb.c @@ -18,21 +18,22 @@ int mongodb_init(struct instance *instance) bson_error_t bson_error; if (unlikely(!connector_specific_config->collection || !*connector_specific_config->collection)) { - error("EXPORTING: collection name is a mandatory MongoDB parameter, but it is not configured"); + netdata_log_error("EXPORTING: collection name is a mandatory MongoDB parameter, but it is not configured"); return 1; } uri = mongoc_uri_new_with_error(instance->config.destination, &bson_error); if (unlikely(!uri)) { - error( - "EXPORTING: failed to parse URI: %s. Error message: %s", instance->config.destination, bson_error.message); + netdata_log_error("EXPORTING: failed to parse URI: %s. Error message: %s", + instance->config.destination, + bson_error.message); return 1; } int32_t socket_timeout = mongoc_uri_get_option_as_int32(uri, MONGOC_URI_SOCKETTIMEOUTMS, instance->config.timeoutms); if (!mongoc_uri_set_option_as_int32(uri, MONGOC_URI_SOCKETTIMEOUTMS, socket_timeout)) { - error("EXPORTING: failed to set %s to the value %d", MONGOC_URI_SOCKETTIMEOUTMS, socket_timeout); + netdata_log_error("EXPORTING: failed to set %s to the value %d", MONGOC_URI_SOCKETTIMEOUTMS, socket_timeout); return 1; }; @@ -41,12 +42,12 @@ int mongodb_init(struct instance *instance) connector_specific_data->client = mongoc_client_new_from_uri(uri); if (unlikely(!connector_specific_data->client)) { - error("EXPORTING: failed to create a new client"); + netdata_log_error("EXPORTING: failed to create a new client"); return 1; } if (!mongoc_client_set_appname(connector_specific_data->client, "netdata")) { - error("EXPORTING: failed to set client appname"); + netdata_log_error("EXPORTING: failed to set client appname"); }; connector_specific_data->collection = mongoc_client_get_collection( @@ -108,7 +109,8 @@ int init_mongodb_instance(struct instance *instance) instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters); if (!instance->buffer) { - error("EXPORTING: cannot create buffer for MongoDB exporting connector instance %s", instance->config.name); + netdata_log_error("EXPORTING: cannot create buffer for MongoDB exporting connector instance %s", + instance->config.name); return 1; } if (uv_mutex_init(&instance->mutex)) @@ -128,7 +130,7 @@ int init_mongodb_instance(struct instance *instance) } if (unlikely(mongodb_init(instance))) { - error("EXPORTING: cannot initialize MongoDB exporting connector"); + netdata_log_error("EXPORTING: cannot initialize MongoDB exporting connector"); return 1; } @@ -195,7 +197,7 @@ int format_batch_mongodb(struct instance *instance) insert[documents_inserted] = bson_new_from_json((const uint8_t *)start, -1, &bson_error); if (unlikely(!insert[documents_inserted])) { - error( + netdata_log_error( "EXPORTING: Failed creating a BSON document from a JSON string \"%s\" : %s", start, bson_error.message); free_bson(insert, documents_inserted); return 1; @@ -229,7 +231,7 @@ int format_batch_mongodb(struct instance *instance) */ void mongodb_cleanup(struct instance *instance) { - info("EXPORTING: cleaning up instance %s ...", instance->config.name); + netdata_log_info("EXPORTING: cleaning up instance %s ...", instance->config.name); struct mongodb_specific_data *connector_specific_data = (struct mongodb_specific_data *)instance->connector_specific_data; @@ -261,7 +263,7 @@ void mongodb_cleanup(struct instance *instance) freez(connector_specific_config->collection); freez(connector_specific_config); - info("EXPORTING: instance %s exited", instance->config.name); + netdata_log_info("EXPORTING: instance %s exited", instance->config.name); instance->exited = 1; return; @@ -327,7 +329,7 @@ void mongodb_connector_worker(void *instance_p) data_size += insert[i]->len; } - debug( + netdata_log_debug( D_EXPORTING, "EXPORTING: mongodb_insert(): destination = %s, database = %s, collection = %s, data size = %zu", instance->config.destination, @@ -350,8 +352,8 @@ void mongodb_connector_worker(void *instance_p) stats->receptions++; } else { // oops! we couldn't send (all or some of the) data - error("EXPORTING: %s", bson_error.message); - error( + netdata_log_error("EXPORTING: %s", bson_error.message); + netdata_log_error( "EXPORTING: failed to write data to the database '%s'. " "Willing to write %zu bytes, wrote %zu bytes.", instance->config.destination, data_size, 0UL); diff --git a/exporting/opentsdb/opentsdb.c b/exporting/opentsdb/opentsdb.c index 0248469fa..ffccb5b22 100644 --- a/exporting/opentsdb/opentsdb.c +++ b/exporting/opentsdb/opentsdb.c @@ -46,7 +46,7 @@ int init_opentsdb_telnet_instance(struct instance *instance) instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters); if (!instance->buffer) { - error("EXPORTING: cannot create buffer for opentsdb telnet exporting connector instance %s", instance->config.name); + netdata_log_error("EXPORTING: cannot create buffer for opentsdb telnet exporting connector instance %s", instance->config.name); return 1; } @@ -102,7 +102,7 @@ int init_opentsdb_http_instance(struct instance *instance) instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters); if (!instance->buffer) { - error("EXPORTING: cannot create buffer for opentsdb HTTP exporting connector instance %s", instance->config.name); + netdata_log_error("EXPORTING: cannot create buffer for opentsdb HTTP exporting connector instance %s", instance->config.name); return 1; } @@ -190,8 +190,8 @@ int format_dimension_collected_opentsdb_telnet(struct instance *instance, RRDDIM instance->config.prefix, chart_name, dimension_name, - (unsigned long long)rd->last_collected_time.tv_sec, - rd->last_collected_value, + (unsigned long long)rd->collector.last_collected_time.tv_sec, + rd->collector.last_collected_value, (host == localhost) ? instance->config.hostname : rrdhost_hostname(host), (host->tags) ? " " : "", (host->tags) ? rrdhost_tags(host) : "", @@ -332,8 +332,8 @@ int format_dimension_collected_opentsdb_http(struct instance *instance, RRDDIM * instance->config.prefix, chart_name, dimension_name, - (unsigned long long)rd->last_collected_time.tv_sec, - rd->last_collected_value, + (unsigned long long)rd->collector.last_collected_time.tv_sec, + rd->collector.last_collected_value, (host == localhost) ? instance->config.hostname : rrdhost_hostname(host), (host->tags) ? " " : "", (host->tags) ? rrdhost_tags(host) : "", diff --git a/exporting/process_data.c b/exporting/process_data.c index 22129cff6..c7792fa55 100644 --- a/exporting/process_data.c +++ b/exporting/process_data.c @@ -107,7 +107,7 @@ NETDATA_DOUBLE exporting_calculate_value_from_stored_data( if (unlikely(before < first_t || after > last_t)) { // the chart has not been updated in the wanted timeframe - debug( + netdata_log_debug( D_EXPORTING, "EXPORTING: %s.%s.%s: aligned timeframe %lu to %lu is outside the chart's database range %lu to %lu", rrdhost_hostname(host), @@ -126,7 +126,7 @@ NETDATA_DOUBLE exporting_calculate_value_from_stored_data( size_t counter = 0; NETDATA_DOUBLE sum = 0; - for (storage_engine_query_init(rd->tiers[0].backend, rd->tiers[0].db_metric_handle, &handle, after, before, STORAGE_PRIORITY_LOW); !storage_engine_query_is_finished(&handle);) { + for (storage_engine_query_init(rd->tiers[0].backend, rd->tiers[0].db_metric_handle, &handle, after, before, STORAGE_PRIORITY_SYNCHRONOUS); !storage_engine_query_is_finished(&handle);) { STORAGE_POINT sp = storage_engine_query_next_metric(&handle); points_read++; @@ -142,7 +142,7 @@ NETDATA_DOUBLE exporting_calculate_value_from_stored_data( global_statistics_exporters_query_completed(points_read); if (unlikely(!counter)) { - debug( + netdata_log_debug( D_EXPORTING, "EXPORTING: %s.%s.%s: no values stored in database for range %lu to %lu", rrdhost_hostname(host), @@ -170,7 +170,7 @@ void start_batch_formatting(struct engine *engine) if (instance->scheduled) { uv_mutex_lock(&instance->mutex); if (instance->start_batch_formatting && instance->start_batch_formatting(instance) != 0) { - error("EXPORTING: cannot start batch formatting for %s", instance->config.name); + netdata_log_error("EXPORTING: cannot start batch formatting for %s", instance->config.name); disable_instance(instance); } } @@ -189,7 +189,7 @@ void start_host_formatting(struct engine *engine, RRDHOST *host) if (instance->scheduled) { if (rrdhost_is_exportable(instance, host)) { if (instance->start_host_formatting && instance->start_host_formatting(instance, host) != 0) { - error("EXPORTING: cannot start host formatting for %s", instance->config.name); + netdata_log_error("EXPORTING: cannot start host formatting for %s", instance->config.name); disable_instance(instance); } } else { @@ -211,7 +211,7 @@ void start_chart_formatting(struct engine *engine, RRDSET *st) if (instance->scheduled && !instance->skip_host) { if (rrdset_is_exportable(instance, st)) { if (instance->start_chart_formatting && instance->start_chart_formatting(instance, st) != 0) { - error("EXPORTING: cannot start chart formatting for %s", instance->config.name); + netdata_log_error("EXPORTING: cannot start chart formatting for %s", instance->config.name); disable_instance(instance); } } else { @@ -232,7 +232,7 @@ void metric_formatting(struct engine *engine, RRDDIM *rd) for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (instance->scheduled && !instance->skip_host && !instance->skip_chart) { if (instance->metric_formatting && instance->metric_formatting(instance, rd) != 0) { - error("EXPORTING: cannot format metric for %s", instance->config.name); + netdata_log_error("EXPORTING: cannot format metric for %s", instance->config.name); disable_instance(instance); continue; } @@ -252,7 +252,7 @@ void end_chart_formatting(struct engine *engine, RRDSET *st) for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (instance->scheduled && !instance->skip_host && !instance->skip_chart) { if (instance->end_chart_formatting && instance->end_chart_formatting(instance, st) != 0) { - error("EXPORTING: cannot end chart formatting for %s", instance->config.name); + netdata_log_error("EXPORTING: cannot end chart formatting for %s", instance->config.name); disable_instance(instance); continue; } @@ -271,8 +271,8 @@ void variables_formatting(struct engine *engine, RRDHOST *host) { for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (instance->scheduled && !instance->skip_host && should_send_variables(instance)) { - if (instance->variables_formatting && instance->variables_formatting(instance, host) != 0){ - error("EXPORTING: cannot format variables for %s", instance->config.name); + if (instance->variables_formatting && instance->variables_formatting(instance, host) != 0){ + netdata_log_error("EXPORTING: cannot format variables for %s", instance->config.name); disable_instance(instance); continue; } @@ -293,7 +293,7 @@ void end_host_formatting(struct engine *engine, RRDHOST *host) for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (instance->scheduled && !instance->skip_host) { if (instance->end_host_formatting && instance->end_host_formatting(instance, host) != 0) { - error("EXPORTING: cannot end host formatting for %s", instance->config.name); + netdata_log_error("EXPORTING: cannot end host formatting for %s", instance->config.name); disable_instance(instance); continue; } @@ -312,7 +312,7 @@ void end_batch_formatting(struct engine *engine) for (struct instance *instance = engine->instance_root; instance; instance = instance->next) { if (instance->scheduled) { if (instance->end_batch_formatting && instance->end_batch_formatting(instance) != 0) { - error("EXPORTING: cannot end batch formatting for %s", instance->config.name); + netdata_log_error("EXPORTING: cannot end batch formatting for %s", instance->config.name); disable_instance(instance); continue; } diff --git a/exporting/prometheus/prometheus.c b/exporting/prometheus/prometheus.c index 0e0e8abf0..9f24ba1b0 100644 --- a/exporting/prometheus/prometheus.c +++ b/exporting/prometheus/prometheus.c @@ -41,7 +41,7 @@ inline int can_send_rrdset(struct instance *instance, RRDSET *st, SIMPLE_PATTERN rrdset_flag_set(st, RRDSET_FLAG_EXPORTING_SEND); } else { rrdset_flag_set(st, RRDSET_FLAG_EXPORTING_IGNORE); - debug( + netdata_log_debug( D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s', because it is disabled for exporting.", rrdset_id(st), @@ -51,7 +51,7 @@ inline int can_send_rrdset(struct instance *instance, RRDSET *st, SIMPLE_PATTERN } if (unlikely(!rrdset_is_available_for_exporting_and_alarms(st))) { - debug( + netdata_log_debug( D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s', because it is not available for exporting.", rrdset_id(st), @@ -62,7 +62,7 @@ inline int can_send_rrdset(struct instance *instance, RRDSET *st, SIMPLE_PATTERN if (unlikely( st->rrd_memory_mode == RRD_MEMORY_MODE_NONE && !(EXPORTING_OPTIONS_DATA_SOURCE(instance->config.options) == EXPORTING_SOURCE_DATA_AS_COLLECTED))) { - debug( + netdata_log_debug( D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s' because its memory mode is '%s' and the exporting connector requires database access.", rrdset_id(st), @@ -244,7 +244,7 @@ inline char *prometheus_units_copy(char *d, const char *s, size_t usable, int sh uint32_t hash = simple_hash(s); for (i = 0; units[i].newunit; i++) { if (unlikely(hash == units[i].hash && !strcmp(s, units[i].newunit))) { - // info("matched extension for filename '%s': '%s'", filename, last_dot); + // netdata_log_info("matched extension for filename '%s': '%s'", filename, last_dot); s = units[i].oldunit; sorig = s; break; @@ -497,7 +497,7 @@ static void generate_as_collected_prom_help(BUFFER *wb, struct gen_parameters *p if (prometheus_collector) buffer_sprintf(wb, "1 / 1"); else - buffer_sprintf(wb, COLLECTED_NUMBER_FORMAT " / " COLLECTED_NUMBER_FORMAT, p->rd->multiplier, p->rd->divisor); + buffer_sprintf(wb, "%d / %d", p->rd->multiplier, p->rd->divisor); buffer_sprintf(wb, " %s %s (%s)\n", p->relation, rrdset_units(p->st), p->type); } @@ -540,13 +540,13 @@ static void generate_as_collected_prom_metric(BUFFER *wb, buffer_sprintf( wb, NETDATA_DOUBLE_FORMAT, - (NETDATA_DOUBLE)p->rd->last_collected_value * (NETDATA_DOUBLE)p->rd->multiplier / - (NETDATA_DOUBLE)p->rd->divisor); + (NETDATA_DOUBLE)p->rd->collector.last_collected_value * (NETDATA_DOUBLE)p->rd->multiplier / + (NETDATA_DOUBLE)p->rd->divisor); else - buffer_sprintf(wb, COLLECTED_NUMBER_FORMAT, p->rd->last_collected_value); + buffer_sprintf(wb, COLLECTED_NUMBER_FORMAT, p->rd->collector.last_collected_value); if (p->output_options & PROMETHEUS_OUTPUT_TIMESTAMPS) - buffer_sprintf(wb, " %llu\n", timeval_msec(&p->rd->last_collected_time)); + buffer_sprintf(wb, " %llu\n", timeval_msec(&p->rd->collector.last_collected_time)); else buffer_sprintf(wb, "\n"); } @@ -627,6 +627,8 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus( static struct format_prometheus_chart_label_callback plabels = { .labels_buffer = NULL, }; + + STRING *prometheus = string_strdupz("prometheus"); rrdset_foreach_read(st, host) { if (likely(can_send_rrdset(instance, st, filter))) { @@ -642,16 +644,18 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus( int as_collected = (EXPORTING_OPTIONS_DATA_SOURCE(exporting_options) == EXPORTING_SOURCE_DATA_AS_COLLECTED); int homogeneous = 1; int prometheus_collector = 0; + RRDSET_FLAGS flags = __atomic_load_n(&st->flags, __ATOMIC_RELAXED); if (as_collected) { - if (rrdset_flag_check(st, RRDSET_FLAG_HOMOGENEOUS_CHECK)) + if (flags & RRDSET_FLAG_HOMOGENEOUS_CHECK) rrdset_update_heterogeneous_flag(st); - if (rrdset_flag_check(st, RRDSET_FLAG_HETEROGENEOUS)) + if (flags & RRDSET_FLAG_HETEROGENEOUS) homogeneous = 0; - if (!strcmp(rrdset_module_name(st), "prometheus")) + if (st->module_name == prometheus) prometheus_collector = 1; - } else { + } + else { if (EXPORTING_OPTIONS_DATA_SOURCE(exporting_options) == EXPORTING_SOURCE_DATA_AVERAGE && !(output_options & PROMETHEUS_OUTPUT_HIDEUNITS)) prometheus_units_copy( @@ -671,7 +675,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus( // for each dimension RRDDIM *rd; rrddim_foreach_read(rd, st) { - if (rd->collections_counter && !rrddim_flag_check(rd, RRDDIM_FLAG_OBSOLETE)) { + if (rd->collector.counter && !rrddim_flag_check(rd, RRDDIM_FLAG_OBSOLETE)) { char dimension[PROMETHEUS_ELEMENT_MAX + 1]; char *suffix = ""; @@ -690,7 +694,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus( p.st = st; p.rd = rd; - if (unlikely(rd->last_collected_time.tv_sec < instance->after)) + if (unlikely(rd->collector.last_collected_time.tv_sec < instance->after)) continue; p.type = "gauge"; @@ -953,11 +957,10 @@ void rrd_stats_api_v1_charts_allmetrics_prometheus_all_hosts( prometheus_exporter_instance->before, output_options); - rrd_rdlock(); - rrdhost_foreach_read(host) + dfe_start_reentrant(rrdhost_root_index, host) { rrd_stats_api_v1_charts_allmetrics_prometheus( prometheus_exporter_instance, host, filter_string, wb, prefix, exporting_options, 1, output_options); } - rrd_unlock(); + dfe_done(host); } diff --git a/exporting/prometheus/remote_write/remote_write.c b/exporting/prometheus/remote_write/remote_write.c index 660b798e4..2b53b1c20 100644 --- a/exporting/prometheus/remote_write/remote_write.c +++ b/exporting/prometheus/remote_write/remote_write.c @@ -234,7 +234,7 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM * struct prometheus_remote_write_specific_data *connector_specific_data = (struct prometheus_remote_write_specific_data *)simple_connector_data->connector_specific_data; - if (rd->collections_counter && !rrddim_flag_check(rd, RRDDIM_FLAG_OBSOLETE)) { + if (rd->collector.counter && !rrddim_flag_check(rd, RRDDIM_FLAG_OBSOLETE)) { char name[PROMETHEUS_LABELS_MAX + 1]; char dimension[PROMETHEUS_ELEMENT_MAX + 1]; char *suffix = ""; @@ -243,14 +243,14 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM * if (as_collected) { // we need as-collected / raw data - if (unlikely(rd->last_collected_time.tv_sec < instance->after)) { - debug( + if (unlikely(rd->collector.last_collected_time.tv_sec < instance->after)) { + netdata_log_debug( D_EXPORTING, "EXPORTING: not sending dimension '%s' of chart '%s' from host '%s', " "its last data collection (%lu) is not within our timeframe (%lu to %lu)", rrddim_id(rd), rrdset_id(rd->rrdset), (host == localhost) ? instance->config.hostname : rrdhost_hostname(host), - (unsigned long)rd->last_collected_time.tv_sec, + (unsigned long)rd->collector.last_collected_time.tv_sec, (unsigned long)instance->after, (unsigned long)instance->before); return 0; @@ -272,10 +272,10 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM * snprintf(name, PROMETHEUS_LABELS_MAX, "%s_%s%s", instance->config.prefix, context, suffix); add_metric( - connector_specific_data->write_request, - name, chart, family, dimension, + connector_specific_data->write_request, + name, chart, family, dimension, (host == localhost) ? instance->config.hostname : rrdhost_hostname(host), - rd->last_collected_value, timeval_msec(&rd->last_collected_time)); + rd->collector.last_collected_value, timeval_msec(&rd->collector.last_collected_time)); } else { // the dimensions of the chart, do not have the same algorithm, multiplier or divisor // we create a metric per dimension @@ -289,10 +289,10 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM * suffix); add_metric( - connector_specific_data->write_request, - name, chart, family, NULL, + connector_specific_data->write_request, + name, chart, family, NULL, (host == localhost) ? instance->config.hostname : rrdhost_hostname(host), - rd->last_collected_value, timeval_msec(&rd->last_collected_time)); + rd->collector.last_collected_value, timeval_msec(&rd->collector.last_collected_time)); } } else { // we need average or sum of the data @@ -386,7 +386,7 @@ int format_batch_prometheus_remote_write(struct instance *instance) size_t data_size = get_write_request_size(connector_specific_data->write_request); if (unlikely(!data_size)) { - error("EXPORTING: write request size is out of range"); + netdata_log_error("EXPORTING: write request size is out of range"); return 1; } @@ -394,7 +394,7 @@ int format_batch_prometheus_remote_write(struct instance *instance) buffer_need_bytes(buffer, data_size); if (unlikely(pack_and_clear_write_request(connector_specific_data->write_request, buffer->buffer, &data_size))) { - error("EXPORTING: cannot pack write request"); + netdata_log_error("EXPORTING: cannot pack write request"); return 1; } buffer->len = data_size; diff --git a/exporting/pubsub/pubsub.c b/exporting/pubsub/pubsub.c index d65fc2c40..4989160a4 100644 --- a/exporting/pubsub/pubsub.c +++ b/exporting/pubsub/pubsub.c @@ -32,7 +32,7 @@ int init_pubsub_instance(struct instance *instance) instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters); if (!instance->buffer) { - error("EXPORTING: cannot create buffer for Pub/Sub exporting connector instance %s", instance->config.name); + netdata_log_error("EXPORTING: cannot create buffer for Pub/Sub exporting connector instance %s", instance->config.name); return 1; } uv_mutex_init(&instance->mutex); @@ -48,7 +48,7 @@ int init_pubsub_instance(struct instance *instance) (void *)connector_specific_data, error_message, instance->config.destination, connector_specific_config->credentials_file, connector_specific_config->project_id, connector_specific_config->topic_id)) { - error( + netdata_log_error( "EXPORTING: Cannot initialize a Pub/Sub publisher for instance %s: %s", instance->config.name, error_message); return 1; @@ -64,7 +64,7 @@ int init_pubsub_instance(struct instance *instance) */ void clean_pubsub_instance(struct instance *instance) { - info("EXPORTING: cleaning up instance %s ...", instance->config.name); + netdata_log_info("EXPORTING: cleaning up instance %s ...", instance->config.name); struct pubsub_specific_data *connector_specific_data = (struct pubsub_specific_data *)instance->connector_specific_data; @@ -80,7 +80,7 @@ void clean_pubsub_instance(struct instance *instance) freez(connector_specific_config->topic_id); freez(connector_specific_config); - info("EXPORTING: instance %s exited", instance->config.name); + netdata_log_info("EXPORTING: instance %s exited", instance->config.name); instance->exited = 1; return; @@ -132,7 +132,7 @@ void pubsub_connector_worker(void *instance_p) stats->buffered_bytes = buffer_len; if (pubsub_add_message(instance->connector_specific_data, (char *)buffer_tostring(buffer))) { - error("EXPORTING: Instance %s: Cannot add data to a message", instance->config.name); + netdata_log_error("EXPORTING: Instance %s: Cannot add data to a message", instance->config.name); stats->data_lost_events++; stats->lost_metrics += stats->buffered_metrics; @@ -141,12 +141,12 @@ void pubsub_connector_worker(void *instance_p) goto cleanup; } - debug( + netdata_log_debug( D_EXPORTING, "EXPORTING: pubsub_publish(): project = %s, topic = %s, buffer = %zu", connector_specific_config->project_id, connector_specific_config->topic_id, buffer_len); if (pubsub_publish((void *)connector_specific_data, error_message, stats->buffered_metrics, buffer_len)) { - error("EXPORTING: Instance: %s: Cannot publish a message: %s", instance->config.name, error_message); + netdata_log_error("EXPORTING: Instance: %s: Cannot publish a message: %s", instance->config.name, error_message); stats->transmission_failures++; stats->data_lost_events++; @@ -164,8 +164,8 @@ void pubsub_connector_worker(void *instance_p) if (unlikely(pubsub_get_result( connector_specific_data, error_message, &sent_metrics, &sent_bytes, &lost_metrics, &lost_bytes))) { // oops! we couldn't send (all or some of the) data - error("EXPORTING: %s", error_message); - error( + netdata_log_error("EXPORTING: %s", error_message); + netdata_log_error( "EXPORTING: failed to write data to service '%s'. Willing to write %zu bytes, wrote %zu bytes.", instance->config.destination, lost_bytes, sent_bytes); diff --git a/exporting/read_config.c b/exporting/read_config.c index eab2cdfc0..210ba3c66 100644 --- a/exporting/read_config.c +++ b/exporting/read_config.c @@ -176,7 +176,7 @@ inline EXPORTING_OPTIONS exporting_parse_data_source(const char *data_source, EX exporting_options |= EXPORTING_SOURCE_DATA_SUM; exporting_options &= ~(EXPORTING_OPTIONS_SOURCE_BITS ^ EXPORTING_SOURCE_DATA_SUM); } else { - error("EXPORTING: invalid data data_source method '%s'.", data_source); + netdata_log_error("EXPORTING: invalid data data_source method '%s'.", data_source); } return exporting_options; @@ -211,13 +211,13 @@ struct engine *read_exporting_config() exporting_config_exists = appconfig_load(&exporting_config, filename, 0, NULL); if (!exporting_config_exists) { - info("CONFIG: cannot load user exporting config '%s'. Will try the stock version.", filename); + netdata_log_info("CONFIG: cannot load user exporting config '%s'. Will try the stock version.", filename); freez(filename); filename = strdupz_path_subpath(netdata_configured_stock_config_dir, EXPORTING_CONF); exporting_config_exists = appconfig_load(&exporting_config, filename, 0, NULL); if (!exporting_config_exists) - info("CONFIG: cannot load stock exporting config '%s'. Running with internal defaults.", filename); + netdata_log_info("CONFIG: cannot load stock exporting config '%s'. Running with internal defaults.", filename); } freez(filename); @@ -276,10 +276,10 @@ struct engine *read_exporting_config() } while (get_connector_instance(&local_ci)) { - info("Processing connector instance (%s)", local_ci.instance_name); + netdata_log_info("Processing connector instance (%s)", local_ci.instance_name); if (exporter_get_boolean(local_ci.instance_name, "enabled", 0)) { - info( + netdata_log_info( "Instance (%s) on connector (%s) is enabled and scheduled for activation", local_ci.instance_name, local_ci.connector_name); @@ -290,11 +290,11 @@ struct engine *read_exporting_config() tmp_ci_list_prev = tmp_ci_list; instances_to_activate++; } else - info("Instance (%s) on connector (%s) is not enabled", local_ci.instance_name, local_ci.connector_name); + netdata_log_info("Instance (%s) on connector (%s) is not enabled", local_ci.instance_name, local_ci.connector_name); } if (unlikely(!instances_to_activate)) { - info("No connector instances to activate"); + netdata_log_info("No connector instances to activate"); return NULL; } @@ -313,37 +313,37 @@ struct engine *read_exporting_config() char *instance_name; char *default_destination = "localhost"; - info("Instance %s on %s", tmp_ci_list->local_ci.instance_name, tmp_ci_list->local_ci.connector_name); + netdata_log_info("Instance %s on %s", tmp_ci_list->local_ci.instance_name, tmp_ci_list->local_ci.connector_name); if (tmp_ci_list->exporting_type == EXPORTING_CONNECTOR_TYPE_UNKNOWN) { - error("Unknown exporting connector type"); + netdata_log_error("Unknown exporting connector type"); goto next_connector_instance; } #ifndef ENABLE_PROMETHEUS_REMOTE_WRITE if (tmp_ci_list->exporting_type == EXPORTING_CONNECTOR_TYPE_PROMETHEUS_REMOTE_WRITE) { - error("Prometheus Remote Write support isn't compiled"); + netdata_log_error("Prometheus Remote Write support isn't compiled"); goto next_connector_instance; } #endif #ifndef HAVE_KINESIS if (tmp_ci_list->exporting_type == EXPORTING_CONNECTOR_TYPE_KINESIS) { - error("AWS Kinesis support isn't compiled"); + netdata_log_error("AWS Kinesis support isn't compiled"); goto next_connector_instance; } #endif #ifndef ENABLE_EXPORTING_PUBSUB if (tmp_ci_list->exporting_type == EXPORTING_CONNECTOR_TYPE_PUBSUB) { - error("Google Cloud Pub/Sub support isn't compiled"); + netdata_log_error("Google Cloud Pub/Sub support isn't compiled"); goto next_connector_instance; } #endif #ifndef HAVE_MONGOC if (tmp_ci_list->exporting_type == EXPORTING_CONNECTOR_TYPE_MONGODB) { - error("MongoDB support isn't compiled"); + netdata_log_error("MongoDB support isn't compiled"); goto next_connector_instance; } #endif @@ -381,7 +381,7 @@ struct engine *read_exporting_config() tmp_instance->config.options = exporting_parse_data_source(data_source, tmp_instance->config.options); if (EXPORTING_OPTIONS_DATA_SOURCE(tmp_instance->config.options) != EXPORTING_SOURCE_DATA_AS_COLLECTED && tmp_instance->config.update_every % localhost->rrd_update_every) - info( + netdata_log_info( "The update interval %d for instance %s is not a multiple of the database update interval %d. " "Metric values will deviate at different points in time.", tmp_instance->config.update_every, tmp_instance->config.name, localhost->rrd_update_every); @@ -488,7 +488,7 @@ struct engine *read_exporting_config() #endif #ifdef NETDATA_INTERNAL_CHECKS - info( + netdata_log_info( " Dest=[%s], upd=[%d], buffer=[%d] timeout=[%ld] options=[%u]", tmp_instance->config.destination, tmp_instance->config.update_every, diff --git a/exporting/send_data.c b/exporting/send_data.c index d91fc50d7..3fec7320d 100644 --- a/exporting/send_data.c +++ b/exporting/send_data.c @@ -40,12 +40,11 @@ int exporting_discard_response(BUFFER *buffer, struct instance *instance) { } *d = '\0'; - debug( - D_EXPORTING, - "EXPORTING: received %zu bytes from %s connector instance. Ignoring them. Sample: '%s'", - buffer_strlen(buffer), - instance->config.name, - sample); + netdata_log_debug(D_EXPORTING, + "EXPORTING: received %zu bytes from %s connector instance. Ignoring them. Sample: '%s'", + buffer_strlen(buffer), + instance->config.name, + sample); #else UNUSED(instance); #endif /* NETDATA_INTERNAL_CHECKS */ @@ -96,14 +95,14 @@ void simple_connector_receive_response(int *sock, struct instance *instance) stats->receptions++; } else if (r == 0) { - error("EXPORTING: '%s' closed the socket", instance->config.destination); + netdata_log_error("EXPORTING: '%s' closed the socket", instance->config.destination); close(*sock); *sock = -1; } else { // failed to receive data if (errno != EAGAIN && errno != EWOULDBLOCK) { - error("EXPORTING: cannot receive data from '%s'.", instance->config.destination); + netdata_log_error("EXPORTING: cannot receive data from '%s'.", instance->config.destination); } } @@ -182,7 +181,7 @@ void simple_connector_send_buffer( buffer_flush(buffer); } else { // oops! we couldn't send (all or some of the) data - error( + netdata_log_error( "EXPORTING: failed to write data to '%s'. Willing to write %zu bytes, wrote %zd bytes. Will re-connect.", instance->config.destination, buffer_len, @@ -299,11 +298,11 @@ void simple_connector_worker(void *instance_p) if (exporting_tls_is_enabled(instance->config.type, options) && sock != -1) { if (netdata_ssl_exporting_ctx) { if (sock_delnonblock(sock) < 0) - error("Exporting cannot remove the non-blocking flag from socket %d", sock); + netdata_log_error("Exporting cannot remove the non-blocking flag from socket %d", sock); if(netdata_ssl_open(&connector_specific_data->ssl, netdata_ssl_exporting_ctx, sock)) { if(netdata_ssl_connect(&connector_specific_data->ssl)) { - info("Exporting established a SSL connection."); + netdata_log_info("Exporting established a SSL connection."); struct timeval tv; tv.tv_sec = timeout.tv_sec / 4; @@ -313,7 +312,7 @@ void simple_connector_worker(void *instance_p) tv.tv_sec = 2; if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv))) - error("Cannot set timeout to socket %d, this can block communication", sock); + netdata_log_error("Cannot set timeout to socket %d, this can block communication", sock); } } } @@ -340,7 +339,7 @@ void simple_connector_worker(void *instance_p) connector_specific_data->buffer, buffered_metrics); } else { - error("EXPORTING: failed to update '%s'", instance->config.destination); + netdata_log_error("EXPORTING: failed to update '%s'", instance->config.destination); stats->transmission_failures++; // increment the counter we check for data loss diff --git a/exporting/tests/exporting_fixtures.c b/exporting/tests/exporting_fixtures.c index c9fc9458c..78159a82d 100644 --- a/exporting/tests/exporting_fixtures.c +++ b/exporting/tests/exporting_fixtures.c @@ -91,7 +91,7 @@ int setup_rrdhost() st->rrddim_root_index = dictionary_create(DICT_OPTION_DONT_OVERWRITE_VALUE); dictionary_register_insert_callback(st->rrddim_root_index, rrddim_insert_callback, NULL); - st->dimensions = dictionary_set_advanced(st->rrddim_root_index, "dimension_id", -1, NULL, sizeof(RRDDIM), st); + st->dimensions = dictionary_set_advanced(st->rrddim_root_index, "dimension_id", -1, NULL, rrddim_size(), st); return 0; } |