From 3cad1aaed3dbdebaf5ebe8ad3b52de087f7b47dc Mon Sep 17 00:00:00 2001 From: Aren Blondahl Date: Sat, 21 Sep 2024 04:01:53 -0600 Subject: [PATCH] feat: added k3s metrics mappings for apps This change adds mappings to the graphite exporter configuration file that map the k3s metrics into unified prometheus metrics. When running apps in TrueNAS scale the pods are exported by the metrics exporter and can be captured here to get some basic operational details. The metrics exported are not documented in TrueNAS or k3s in this format, and this poses a problem making sense of the `cpu` metric. --- METRICS.md | 11 ++++++++++- graphite_mapping.conf | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/METRICS.md b/METRICS.md index 1d0d56c..44fcdd3 100644 --- a/METRICS.md +++ b/METRICS.md @@ -128,4 +128,13 @@ Both memeory statistics from TrueNAS are exported on the onside the physical mem |`zfs_prefetch_data_hits_rate`|`op` hit or miss type|`events/s`|Number of hits for the type of cache hit.| |`zfs_hash_elements`|`op` current, max|`elements`|Number of hash elements present and maximum.| |`zfs_hash_chains`|`op` current, max|`chains`|Number of hash chains present and maximum.| -|`zfs_pool`||`boolean`|Shows the states of the pool with boolean indicating if they are active.| \ No newline at end of file +|`zfs_pool`||`boolean`|Shows the states of the pool with boolean indicating if they are active.| + +## k3s + +|Metric name|Labels|Unit|Description| +|-----------|------|----|-----------| +|`k3s_pod_cpu`|`pod` the pod name|`unknown`|A number that represents the cpu usage of the pod. (no documentation)| +|`k3s_pod_mem`|`pod` the pod name|`bytes`|The number of bytes of memory this pod is using.| +|`k3s_pod_net`||`bytes`|The number of bytes in/out of the pod over the network interface.| + diff --git a/graphite_mapping.conf b/graphite_mapping.conf index aac17ca..34f0cae 100644 --- a/graphite_mapping.conf +++ b/graphite_mapping.conf @@ -488,3 +488,32 @@ mappings: job: "truenas" instance: "${1}" op: "${2}" + +################################################ +# k3s mappings +################################################ + +- match: 'truenas\.(.*)\.k3s_stats\.k3s_pod_stats\.(.*)\.cpu' + match_type: "regex" + name: "k3s_pod_cpu" + labels: + job: "truenas" + instance: "${1}" + pod: "${2}" + +- match: 'truenas\.(.*)\.k3s_stats\.k3s_pod_stats\.(.*)\.mem' + match_type: "regex" + name: "k3s_pod_mem" + labels: + job: "truenas" + instance: "${1}" + pod: "${2}" + +- match: 'truenas\.(.*)\.k3s_stats\.k3s_pod_stats\.(.*)\.net\.(.*)' + match_type: "regex" + name: "k3s_pod_net" + labels: + job: "truenas" + instance: "${1}" + pod: "${2}" + direction: "${3}"