diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2022-05-06 17:31:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-06 17:31:46 +0300 |
commit | 11bd54a49552f6d4d4ae5313cefe4f8e4f5804c0 (patch) | |
tree | b12dfa6955afc7b45207eada338f01a7ea103d08 /exporting/prometheus | |
parent | b20911cbda25a265ac492bbed1bd44ab9d8a7526 (diff) |
make 'send charts matching' behave the same as 'filter' (#12832)
Diffstat (limited to 'exporting/prometheus')
-rw-r--r-- | exporting/prometheus/prometheus.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/exporting/prometheus/prometheus.c b/exporting/prometheus/prometheus.c index dc8e870ef2..c7f3f1d389 100644 --- a/exporting/prometheus/prometheus.c +++ b/exporting/prometheus/prometheus.c @@ -7,6 +7,13 @@ // PROMETHEUS // /api/v1/allmetrics?format=prometheus and /api/v1/allmetrics?format=prometheus_all_hosts +static int is_matches_rrdset(struct instance *instance, RRDSET *st, SIMPLE_PATTERN *filter) { + if (instance->config.options & EXPORTING_OPTION_SEND_NAMES) { + return simple_pattern_matches(filter, st->name); + } + return simple_pattern_matches(filter, st->id); +} + /** * Check if a chart can be sent to Prometheus * @@ -29,28 +36,21 @@ inline int can_send_rrdset(struct instance *instance, RRDSET *st, SIMPLE_PATTERN return 0; if (filter) { - if (instance->config.options & EXPORTING_OPTION_SEND_NAMES) { - if (!simple_pattern_matches(filter, st->name)) - return 0; - } else { - if (!simple_pattern_matches(filter, st->id)) - return 0; + if (!is_matches_rrdset(instance, st, filter)) { + return 0; } - } else { - if (unlikely(!rrdset_flag_check(st, RRDSET_FLAG_EXPORTING_SEND))) { - // we have not checked this chart - if (simple_pattern_matches(instance->config.charts_pattern, st->id) || - simple_pattern_matches(instance->config.charts_pattern, st->name)) - rrdset_flag_set(st, RRDSET_FLAG_EXPORTING_SEND); - else { - rrdset_flag_set(st, RRDSET_FLAG_EXPORTING_IGNORE); - debug( - D_EXPORTING, - "EXPORTING: not sending chart '%s' of host '%s', because it is disabled for exporting.", - st->id, - host->hostname); - return 0; - } + } else if (unlikely(!rrdset_flag_check(st, RRDSET_FLAG_EXPORTING_SEND))) { + // we have not checked this chart + if (is_matches_rrdset(instance, st, instance->config.charts_pattern)) { + rrdset_flag_set(st, RRDSET_FLAG_EXPORTING_SEND); + } else { + rrdset_flag_set(st, RRDSET_FLAG_EXPORTING_IGNORE); + debug( + D_EXPORTING, + "EXPORTING: not sending chart '%s' of host '%s', because it is disabled for exporting.", + st->id, + host->hostname); + return 0; } } |