Skip to content

Commit

Permalink
feat: added k3s metrics mappings for apps
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Reanmachine committed Sep 21, 2024
1 parent 80cd76c commit 3cad1aa
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
11 changes: 10 additions & 1 deletion METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`|<ul><li>`pool` name of the pool</li><li>`state`</li></ul>|`boolean`|Shows the states of the pool with boolean indicating if they are active.|
|`zfs_pool`|<ul><li>`pool` name of the pool</li><li>`state`</li></ul>|`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`|<ul><li>`pod` the pod name</li><li>`direction` the direction of network traffic</li></ul>|`bytes`|The number of bytes in/out of the pod over the network interface.|

29 changes: 29 additions & 0 deletions graphite_mapping.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit 3cad1aa

Please sign in to comment.