diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2022-08-16 10:33:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-16 10:33:08 +0300 |
commit | 708efb41bdf952c84b60326d40c07cc69e58d19c (patch) | |
tree | 119af9c39fe3dfc6126ef1359ef95d10e86b955b /database/rrdlabels.c | |
parent | 62ca74b0a4f5db5ae31d02cb6cbde8d322174249 (diff) |
Support chart labels in alerts (#13290)
* chart labels for alerts
* proper termination
* use strchr
* change if statement
* change label variable. add docs
* change doc
* assign buf to temp
* use new dictionary functions
* reduce variable scope
* reduce line length
* make sure rrdcalc updates labels after inserted
* reduce var scope
* add rrdcalc.c for cmocka tests
* Revert "add rrdcalc.c for cmocka tests"
This reverts commit 5fe122adcf7abcbe6d67fa2ebd7c4ff8620cf9c8.
* Fix cmocka unit tests
* valgrind errors
Co-authored-by: Vladimir Kobal <vlad@prokk.net>
Diffstat (limited to 'database/rrdlabels.c')
-rw-r--r-- | database/rrdlabels.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/database/rrdlabels.c b/database/rrdlabels.c index 5198cb4aae..afd738c3f3 100644 --- a/database/rrdlabels.c +++ b/database/rrdlabels.c @@ -620,7 +620,7 @@ void rrdlabels_add_pair(DICTIONARY *dict, const char *string, RRDLABEL_SRC ls) { } // ---------------------------------------------------------------------------- -// rrdlabels_get_to_buffer_or_null() +// rrdlabels_get_value_to_buffer_or_null() void rrdlabels_get_value_to_buffer_or_null(DICTIONARY *labels, BUFFER *wb, const char *key, const char *quote, const char *null) { DICTIONARY_ITEM *acquired_item = dictionary_get_and_acquire_item(labels, key); @@ -634,6 +634,17 @@ void rrdlabels_get_value_to_buffer_or_null(DICTIONARY *labels, BUFFER *wb, const dictionary_acquired_item_release(labels, acquired_item); } +// ---------------------------------------------------------------------------- +// rrdlabels_get_value_to_char_or_null() + +void rrdlabels_get_value_to_char_or_null(DICTIONARY *labels, char **value, const char *key) { + DICTIONARY_ITEM *acquired_item = dictionary_get_and_acquire_item(labels, key); + RRDLABEL *lb = dictionary_acquired_item_value(acquired_item); + + *value = (lb && lb->label_value) ? strdupz(string2str(lb->label_value)) : NULL; + + dictionary_acquired_item_release(labels, acquired_item); +} // ---------------------------------------------------------------------------- // rrdlabels_unmark_all() @@ -939,6 +950,8 @@ void rrdset_update_rrdlabels(RRDSET *st, DICTIONARY *new_rrdlabels) { if (new_rrdlabels) rrdlabels_migrate_to_these(st->state->chart_labels, new_rrdlabels); + rrdcalc_update_rrdlabels(st); + // TODO - we should also cleanup sqlite from old new_rrdlabels that have been removed rrdlabels_walkthrough_read(st->state->chart_labels, chart_label_store_to_sql_callback, st); } |