diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2020-12-14 17:27:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-14 17:27:55 +0300 |
commit | 0f8175dd3060691394e263cdab01c8f940b1b5d3 (patch) | |
tree | 4b14cd6b7e6ba7797eeec4c74b4c4c35cdad4494 /collectors/proc.plugin | |
parent | 7bfa8c8eba72a109d940b1fa5c7acaed9cd7a52c (diff) |
Kubernetes labels (#10107)
Co-authored-by: Markos Fountoulakis <markos.fountoulakis.senior@gmail.com>
Co-authored-by: Vladimir Kobal <vlad@prokk.net>
Diffstat (limited to 'collectors/proc.plugin')
-rw-r--r-- | collectors/proc.plugin/plugin_proc.h | 3 | ||||
-rw-r--r-- | collectors/proc.plugin/proc_net_dev.c | 30 |
2 files changed, 31 insertions, 2 deletions
diff --git a/collectors/proc.plugin/plugin_proc.h b/collectors/proc.plugin/plugin_proc.h index 50ffb184ed..108c026ab2 100644 --- a/collectors/proc.plugin/plugin_proc.h +++ b/collectors/proc.plugin/plugin_proc.h @@ -65,7 +65,8 @@ extern int get_numa_node_count(void); extern unsigned long long tcpext_TCPSynRetrans; // netdev renames -extern void netdev_rename_device_add(const char *host_device, const char *container_device, const char *container_name); +extern void netdev_rename_device_add( + const char *host_device, const char *container_device, const char *container_name, struct label *labels); extern void netdev_rename_device_del(const char *host_device); #include "proc_self_mountinfo.h" diff --git a/collectors/proc.plugin/proc_net_dev.c b/collectors/proc.plugin/proc_net_dev.c index 9bfb0597b8..a90e3c3ee3 100644 --- a/collectors/proc.plugin/proc_net_dev.c +++ b/collectors/proc.plugin/proc_net_dev.c @@ -60,6 +60,8 @@ static struct netdev { const char *chart_family; + struct label *chart_labels; + int flipped; unsigned long priority; @@ -192,6 +194,7 @@ static void netdev_free_chart_strings(struct netdev *d) { static void netdev_free(struct netdev *d) { netdev_charts_release(d); netdev_free_chart_strings(d); + free_label_list(d->chart_labels); freez((void *)d->name); freez((void *)d->filename_speed); @@ -211,6 +214,8 @@ static struct netdev_rename { const char *container_device; const char *container_name; + struct label *chart_labels; + int processed; struct netdev_rename *next; @@ -230,7 +235,9 @@ static struct netdev_rename *netdev_rename_find(const char *host_device, uint32_ } // other threads can call this function to register a rename to a netdev -void netdev_rename_device_add(const char *host_device, const char *container_device, const char *container_name) { +void netdev_rename_device_add( + const char *host_device, const char *container_device, const char *container_name, struct label *labels) +{ netdata_mutex_lock(&netdev_rename_mutex); uint32_t hash = simple_hash(host_device); @@ -240,6 +247,7 @@ void netdev_rename_device_add(const char *host_device, const char *container_dev r->host_device = strdupz(host_device); r->container_device = strdupz(container_device); r->container_name = strdupz(container_name); + update_label_list(&r->chart_labels, labels); r->hash = hash; r->next = netdev_rename_root; r->processed = 0; @@ -254,6 +262,9 @@ void netdev_rename_device_add(const char *host_device, const char *container_dev r->container_device = strdupz(container_device); r->container_name = strdupz(container_name); + + update_label_list(&r->chart_labels, labels); + r->processed = 0; netdev_pending_renames++; info("CGROUP: altered network interface rename for '%s' as '%s' under '%s'", r->host_device, r->container_device, r->container_name); @@ -285,6 +296,7 @@ void netdev_rename_device_del(const char *host_device) { freez((void *) r->host_device); freez((void *) r->container_name); freez((void *) r->container_device); + free_label_list(r->chart_labels); freez((void *) r); break; } @@ -334,6 +346,8 @@ static inline void netdev_rename_cgroup(struct netdev *d, struct netdev_rename * snprintfz(buffer, RRD_ID_LENGTH_MAX, "net %s", r->container_device); d->chart_family = strdupz(buffer); + update_label_list(&d->chart_labels, r->chart_labels); + d->priority = NETDATA_CHART_PRIO_CGROUP_NET_IFACE; d->flipped = 1; } @@ -677,6 +691,8 @@ int do_proc_net_dev(int update_every, usec_t dt) { , RRDSET_TYPE_AREA ); + rrdset_update_labels(d->st_bandwidth, d->chart_labels); + d->rd_rbytes = rrddim_add(d->st_bandwidth, "received", NULL, 8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); d->rd_tbytes = rrddim_add(d->st_bandwidth, "sent", NULL, -8, BITS_IN_A_KILOBIT, RRD_ALGORITHM_INCREMENTAL); @@ -820,6 +836,8 @@ int do_proc_net_dev(int update_every, usec_t dt) { rrdset_flag_set(d->st_packets, RRDSET_FLAG_DETAIL); + rrdset_update_labels(d->st_packets, d->chart_labels); + d->rd_rpackets = rrddim_add(d->st_packets, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_tpackets = rrddim_add(d->st_packets, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_rmulticast = rrddim_add(d->st_packets, "multicast", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -866,6 +884,8 @@ int do_proc_net_dev(int update_every, usec_t dt) { rrdset_flag_set(d->st_errors, RRDSET_FLAG_DETAIL); + rrdset_update_labels(d->st_errors, d->chart_labels); + d->rd_rerrors = rrddim_add(d->st_errors, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_terrors = rrddim_add(d->st_errors, "outbound", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -910,6 +930,8 @@ int do_proc_net_dev(int update_every, usec_t dt) { rrdset_flag_set(d->st_drops, RRDSET_FLAG_DETAIL); + rrdset_update_labels(d->st_drops, d->chart_labels); + d->rd_rdrops = rrddim_add(d->st_drops, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_tdrops = rrddim_add(d->st_drops, "outbound", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -954,6 +976,8 @@ int do_proc_net_dev(int update_every, usec_t dt) { rrdset_flag_set(d->st_fifo, RRDSET_FLAG_DETAIL); + rrdset_update_labels(d->st_fifo, d->chart_labels); + d->rd_rfifo = rrddim_add(d->st_fifo, "receive", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_tfifo = rrddim_add(d->st_fifo, "transmit", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -998,6 +1022,8 @@ int do_proc_net_dev(int update_every, usec_t dt) { rrdset_flag_set(d->st_compressed, RRDSET_FLAG_DETAIL); + rrdset_update_labels(d->st_compressed, d->chart_labels); + d->rd_rcompressed = rrddim_add(d->st_compressed, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_tcompressed = rrddim_add(d->st_compressed, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); @@ -1042,6 +1068,8 @@ int do_proc_net_dev(int update_every, usec_t dt) { rrdset_flag_set(d->st_events, RRDSET_FLAG_DETAIL); + rrdset_update_labels(d->st_events, d->chart_labels); + d->rd_rframe = rrddim_add(d->st_events, "frames", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_tcollisions = rrddim_add(d->st_events, "collisions", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); d->rd_tcarrier = rrddim_add(d->st_events, "carrier", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); |