diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-06-09 02:06:23 +0300 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-06-09 02:06:23 +0300 |
commit | 6267958567f4e76c27030b7357af3de35decf03b (patch) | |
tree | b0c6e9e62b9bd0f6cebac82e6534a46693d50953 /src/backends.c | |
parent | 24e28a52e4cded6ed7d7af62b320fcc8d930f2e9 (diff) |
allow filtering metrics sent to backends; fixes #2257
Diffstat (limited to 'src/backends.c')
-rw-r--r-- | src/backends.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/backends.c b/src/backends.c index 0951027b1e..4125d59bbf 100644 --- a/src/backends.c +++ b/src/backends.c @@ -384,7 +384,23 @@ static inline int process_json_response(BUFFER *b) { // ---------------------------------------------------------------------------- // the backend thread +static SIMPLE_PATTERN *charts_pattern = NULL; + static inline int backends_can_send_rrdset(uint32_t options, RRDSET *st) { + if(unlikely(rrdset_flag_check(st, RRDSET_FLAG_BACKEND_IGNORE))) + return 0; + + if(unlikely(!rrdset_flag_check(st, RRDSET_FLAG_BACKEND_SEND))) { + // we have not checked this chart + if(simple_pattern_matches(charts_pattern, st->id) || simple_pattern_matches(charts_pattern, st->name)) + rrdset_flag_set(st, RRDSET_FLAG_BACKEND_SEND); + else { + rrdset_flag_set(st, RRDSET_FLAG_BACKEND_IGNORE); + debug(D_BACKEND, "BACKEND: not sending chart '%s' of host '%s', because it is disabled for backends.", st->id, st->rrdhost->hostname); + return 0; + } + } + if(unlikely(!rrdset_is_available_for_backends(st))) { debug(D_BACKEND, "BACKEND: not sending chart '%s' of host '%s', because it is not available for backends.", st->id, st->rrdhost->hostname); return 0; @@ -433,6 +449,9 @@ void *backends_main(void *ptr) { int buffer_on_failures = (int)config_get_number(CONFIG_SECTION_BACKEND, "buffer on failures", 10); long timeoutms = config_get_number(CONFIG_SECTION_BACKEND, "timeout ms", frequency * 2 * 1000); + charts_pattern = simple_pattern_create(config_get(CONFIG_SECTION_BACKEND, "send charts matching", "*"), SIMPLE_PATTERN_EXACT); + + // ------------------------------------------------------------------------ // validate configuration options // and prepare for sending data to our backend |