rrdlabels.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_RRDLABELS_H
  3. #define NETDATA_RRDLABELS_H
  4. #include "rrd.h"
  5. typedef enum __attribute__ ((__packed__)) rrdlabel_source {
  6. RRDLABEL_SRC_AUTO = (1 << 0), // set when Netdata found the label by some automation
  7. RRDLABEL_SRC_CONFIG = (1 << 1), // set when the user configured the label
  8. RRDLABEL_SRC_K8S = (1 << 2), // set when this label is found from k8s (RRDLABEL_SRC_AUTO should also be set)
  9. RRDLABEL_SRC_ACLK = (1 << 3), // set when this label is found from ACLK (RRDLABEL_SRC_AUTO should also be set)
  10. // more sources can be added here
  11. RRDLABEL_FLAG_DONT_DELETE = (1 << 29), // set when this label should never be removed (can be overwritten though)
  12. RRDLABEL_FLAG_OLD = (1 << 30), // marks for rrdlabels internal use - they are not exposed outside rrdlabels
  13. RRDLABEL_FLAG_NEW = (1 << 31) // marks for rrdlabels internal use - they are not exposed outside rrdlabels
  14. } RRDLABEL_SRC;
  15. #define RRDLABEL_FLAG_INTERNAL (RRDLABEL_FLAG_OLD | RRDLABEL_FLAG_NEW | RRDLABEL_FLAG_DONT_DELETE)
  16. size_t text_sanitize(unsigned char *dst, const unsigned char *src, size_t dst_size, unsigned char *char_map, bool utf, const char *empty, size_t *multibyte_length);
  17. RRDLABELS *rrdlabels_create(void);
  18. void rrdlabels_destroy(RRDLABELS *labels_dict);
  19. void rrdlabels_add(RRDLABELS *labels, const char *name, const char *value, RRDLABEL_SRC ls);
  20. void rrdlabels_add_pair(RRDLABELS *labels, const char *string, RRDLABEL_SRC ls);
  21. void rrdlabels_value_to_buffer_array_item_or_null(RRDLABELS *labels, BUFFER *wb, const char *key);
  22. void rrdlabels_get_value_strdup_or_null(RRDLABELS *labels, char **value, const char *key);
  23. void rrdlabels_get_value_to_buffer_or_unset(RRDLABELS *labels, BUFFER *wb, const char *key, const char *unset);
  24. bool rrdlabels_exist(RRDLABELS *labels, const char *key);
  25. size_t rrdlabels_entries(RRDLABELS *labels __maybe_unused);
  26. size_t rrdlabels_version(RRDLABELS *labels __maybe_unused);
  27. void rrdlabels_get_value_strcpyz(RRDLABELS *labels, char *dst, size_t dst_len, const char *key);
  28. void rrdlabels_unmark_all(RRDLABELS *labels);
  29. void rrdlabels_remove_all_unmarked(RRDLABELS *labels);
  30. int rrdlabels_walkthrough_read(RRDLABELS *labels, int (*callback)(const char *name, const char *value, RRDLABEL_SRC ls, void *data), void *data);
  31. void rrdlabels_log_to_buffer(RRDLABELS *labels, BUFFER *wb);
  32. bool rrdlabels_match_simple_pattern(RRDLABELS *labels, const char *simple_pattern_txt);
  33. bool rrdlabels_match_simple_pattern_parsed(RRDLABELS *labels, SIMPLE_PATTERN *pattern, char equal, size_t *searches);
  34. int rrdlabels_to_buffer(RRDLABELS *labels, BUFFER *wb, const char *before_each, const char *equal, const char *quote, const char *between_them,
  35. bool (*filter_callback)(const char *name, const char *value, RRDLABEL_SRC ls, void *data), void *filter_data,
  36. void (*name_sanitizer)(char *dst, const char *src, size_t dst_size),
  37. void (*value_sanitizer)(char *dst, const char *src, size_t dst_size));
  38. void rrdlabels_to_buffer_json_members(RRDLABELS *labels, BUFFER *wb);
  39. void rrdlabels_migrate_to_these(RRDLABELS *dst, RRDLABELS *src);
  40. void rrdlabels_copy(RRDLABELS *dst, RRDLABELS *src);
  41. int rrdlabels_unittest(void);
  42. // unfortunately this break when defined in exporting_engine.h
  43. bool exporting_labels_filter_callback(const char *name, const char *value, RRDLABEL_SRC ls, void *data);
  44. #endif /* NETDATA_RRDLABELS_H */