summaryrefslogtreecommitdiffstats
path: root/collectors/cgroups.plugin/sys_fs_cgroup.c
diff options
context:
space:
mode:
authorIlya Mashchenko <ilya@netdata.cloud>2023-04-09 11:46:15 +0300
committerGitHub <noreply@github.com>2023-04-09 11:46:15 +0300
commit61c641e468c741a63681b2ee82aae89503f72574 (patch)
treea8e450db30579703161da9a09d1a4319f6487c91 /collectors/cgroups.plugin/sys_fs_cgroup.c
parent5b7aaaefdb85a846057f21e5114a09eeebc49a8b (diff)
cgroups.plugin: add image label (#14872)
Diffstat (limited to 'collectors/cgroups.plugin/sys_fs_cgroup.c')
-rw-r--r--collectors/cgroups.plugin/sys_fs_cgroup.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/collectors/cgroups.plugin/sys_fs_cgroup.c b/collectors/cgroups.plugin/sys_fs_cgroup.c
index 4e31b459c4..4bb88c374f 100644
--- a/collectors/cgroups.plugin/sys_fs_cgroup.c
+++ b/collectors/cgroups.plugin/sys_fs_cgroup.c
@@ -1769,7 +1769,7 @@ static inline void substitute_dots_in_id(char *s) {
// ----------------------------------------------------------------------------
// parse k8s labels
-char *k8s_parse_resolved_name_and_labels(DICTIONARY *labels, char *data) {
+char *cgroup_parse_resolved_name_and_labels(DICTIONARY *labels, char *data) {
// the first word, up to the first space is the name
char *name = mystrsep(&data, " ");
@@ -1898,19 +1898,21 @@ static inline void discovery_rename_cgroup(struct cgroup *cg) {
break;
}
- if(cg->pending_renames || cg->processed) return;
- if(!new_name || !*new_name || *new_name == '\n') return;
- if(!(new_name = trim(new_name))) return;
+ if (cg->pending_renames || cg->processed)
+ return;
+ if (!new_name || !*new_name || *new_name == '\n')
+ return;
+ if (!(new_name = trim(new_name)))
+ return;
char *name = new_name;
- if (!strncmp(new_name, "k8s_", 4)) {
- if(!cg->chart_labels) cg->chart_labels = rrdlabels_create();
- // read the new labels and remove the obsolete ones
- rrdlabels_unmark_all(cg->chart_labels);
- name = k8s_parse_resolved_name_and_labels(cg->chart_labels, new_name);
- rrdlabels_remove_all_unmarked(cg->chart_labels);
- }
+ if (!cg->chart_labels)
+ cg->chart_labels = rrdlabels_create();
+ // read the new labels and remove the obsolete ones
+ rrdlabels_unmark_all(cg->chart_labels);
+ name = cgroup_parse_resolved_name_and_labels(cg->chart_labels, new_name);
+ rrdlabels_remove_all_unmarked(cg->chart_labels);
freez(cg->chart_title);
cg->chart_title = cgroup_title_strdupz(name);
@@ -2713,13 +2715,18 @@ static inline void discovery_process_cgroup(struct cgroup *cg) {
return;
}
- worker_is_busy(WORKER_DISCOVERY_PROCESS_NETWORK);
- read_cgroup_network_interfaces(cg);
if (!cg->chart_labels)
cg->chart_labels = rrdlabels_create();
+
if (!k8s_is_kubepod(cg)) {
rrdlabels_add(cg->chart_labels, "cgroup_name", cg->chart_id, RRDLABEL_SRC_AUTO);
+ if (!dictionary_get(cg->chart_labels, "image")) {
+ rrdlabels_add(cg->chart_labels, "image", "", RRDLABEL_SRC_AUTO);
+ }
}
+
+ worker_is_busy(WORKER_DISCOVERY_PROCESS_NETWORK);
+ read_cgroup_network_interfaces(cg);
}
static inline void discovery_find_all_cgroups() {