summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorVladimir Kobal <vlad@prokk.net>2020-12-07 16:45:19 +0200
committerGitHub <noreply@github.com>2020-12-07 16:45:19 +0200
commit6d91cedecd5ee3f58e5fe8af48ea5eac33abb967 (patch)
tree6b0d6d0a1680195f705199d26ac9de866cbbc911 /web
parent7a416ecdcba6c1f4dda389731404afa7cc62a3f3 (diff)
Fix exporting config (#10323)
Diffstat (limited to 'web')
-rw-r--r--web/api/exporters/allmetrics.c23
-rw-r--r--web/api/tests/valid_urls.c7
-rw-r--r--web/api/tests/web_api.c6
3 files changed, 30 insertions, 6 deletions
diff --git a/web/api/exporters/allmetrics.c b/web/api/exporters/allmetrics.c
index f3118ba5f3..d10de3d3c5 100644
--- a/web/api/exporters/allmetrics.c
+++ b/web/api/exporters/allmetrics.c
@@ -20,11 +20,22 @@ struct prometheus_output_options {
inline int web_client_api_request_v1_allmetrics(RRDHOST *host, struct web_client *w, char *url) {
int format = ALLMETRICS_SHELL;
const char *prometheus_server = w->client_ip;
- uint32_t prometheus_backend_options = global_backend_options;
+
+ uint32_t prometheus_exporting_options;
+ if (prometheus_exporter_instance)
+ prometheus_exporting_options = prometheus_exporter_instance->config.options;
+ else
+ prometheus_exporting_options = global_backend_options;
+
PROMETHEUS_OUTPUT_OPTIONS prometheus_output_options =
PROMETHEUS_OUTPUT_TIMESTAMPS |
- ((global_backend_options & BACKEND_OPTION_SEND_NAMES) ? PROMETHEUS_OUTPUT_NAMES : 0);
- const char *prometheus_prefix = global_backend_prefix;
+ ((prometheus_exporting_options & BACKEND_OPTION_SEND_NAMES) ? PROMETHEUS_OUTPUT_NAMES : 0);
+
+ const char *prometheus_prefix;
+ if (prometheus_exporter_instance)
+ prometheus_prefix = prometheus_exporter_instance->config.prefix;
+ else
+ prometheus_prefix = global_backend_prefix;
while(url) {
char *value = mystrsep(&url, "&");
@@ -53,7 +64,7 @@ inline int web_client_api_request_v1_allmetrics(RRDHOST *host, struct web_client
prometheus_prefix = value;
}
else if(!strcmp(name, "data") || !strcmp(name, "source") || !strcmp(name, "data source") || !strcmp(name, "data-source") || !strcmp(name, "data_source") || !strcmp(name, "datasource")) {
- prometheus_backend_options = backend_parse_data_source(value, prometheus_backend_options);
+ prometheus_exporting_options = backend_parse_data_source(value, prometheus_exporting_options);
}
else {
int i;
@@ -91,7 +102,7 @@ inline int web_client_api_request_v1_allmetrics(RRDHOST *host, struct web_client
, w->response.data
, prometheus_server
, prometheus_prefix
- , prometheus_backend_options
+ , prometheus_exporting_options
, prometheus_output_options
);
return HTTP_RESP_OK;
@@ -103,7 +114,7 @@ inline int web_client_api_request_v1_allmetrics(RRDHOST *host, struct web_client
, w->response.data
, prometheus_server
, prometheus_prefix
- , prometheus_backend_options
+ , prometheus_exporting_options
, prometheus_output_options
);
return HTTP_RESP_OK;
diff --git a/web/api/tests/valid_urls.c b/web/api/tests/valid_urls.c
index 4a53c2f43f..d8c261c510 100644
--- a/web/api/tests/valid_urls.c
+++ b/web/api/tests/valid_urls.c
@@ -7,6 +7,13 @@
#include <setjmp.h>
#include <cmocka.h>
#include <stdbool.h>
+
+RRDHOST *sql_create_host_by_uuid(char *hostname)
+{
+ (void) hostname;
+ return NULL;
+}
+
RRDHOST *__wrap_sql_create_host_by_uuid(char *hostname)
{
(void) hostname;
diff --git a/web/api/tests/web_api.c b/web/api/tests/web_api.c
index f8681b7d3e..3cc0a790f9 100644
--- a/web/api/tests/web_api.c
+++ b/web/api/tests/web_api.c
@@ -8,6 +8,12 @@
#include <cmocka.h>
#include <stdbool.h>
+RRDHOST *sql_create_host_by_uuid(char *hostname)
+{
+ (void) hostname;
+ return NULL;
+}
+
RRDHOST *__wrap_sql_create_host_by_uuid(char *hostname)
{
(void) hostname;