Supporterino / truenas-graphite-to-prometheus

A graphite exporter mapping file for truenas scale >23.10.1 metrics and some example grafana dashboards
GNU General Public License v3.0
78 stars 12 forks source link

added k3s metrics mappings for apps #57

Closed Reanmachine closed 1 month ago

Reanmachine commented 2 months ago

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.

I've been able to identify that these numbers go up/down in the 100,000 -> 10,000,000 range for a mostly idle system. I suspect they're something like CPU time in... nanoseconds? over some period. I will admit I'm not an expert at system metrics to make a better educated guess.

Example Metrics:

# HELP k3s_pod_cpu Graphite metric k3s_pod_cpu
# TYPE k3s_pod_cpu gauge
k3s_pod_cpu{instance="nas.home.internal",job="truenas",pod="coredns_59b4f5bbd5_smzb4"} 3.9131e+06
k3s_pod_cpu{instance="nas.home.internal",job="truenas",pod="csi_nfs_controller_7b74694749_qmcw2"} 2.218731e+06
k3s_pod_cpu{instance="nas.home.internal",job="truenas",pod="csi_nfs_node_6mn5r"} 3.302392e+06
k3s_pod_cpu{instance="nas.home.internal",job="truenas",pod="csi_smb_controller_7fbbb8fb6f_n9jrw"} 1.49449e+06
k3s_pod_cpu{instance="nas.home.internal",job="truenas",pod="csi_smb_node_kf5n9"} 3.265436e+06
k3s_pod_cpu{instance="nas.home.internal",job="truenas",pod="immich_669bb67c8c_nj976"} 3.869711e+06
k3s_pod_cpu{instance="nas.home.internal",job="truenas",pod="immich_machinelearning_84588c7fc6_7b7ml"} 2.128128e+06
k3s_pod_cpu{instance="nas.home.internal",job="truenas",pod="immich_postgres_85744f8847_5sznp"} 1.51312678e+07
k3s_pod_cpu{instance="nas.home.internal",job="truenas",pod="immich_redis_7978c8949b_7rm9f"} 8.875293e+06
k3s_pod_cpu{instance="nas.home.internal",job="truenas",pod="jellyfin_8466dbcb4c_gckln"} 744292
k3s_pod_cpu{instance="nas.home.internal",job="truenas",pod="snapshot_controller_546868dfb4_5rz6q"} 287387
k3s_pod_cpu{instance="nas.home.internal",job="truenas",pod="snapshot_controller_546868dfb4_w6lcn"} 890650
# HELP k3s_pod_mem Graphite metric k3s_pod_mem
# TYPE k3s_pod_mem gauge
k3s_pod_mem{instance="nas.home.internal",job="truenas",pod="coredns_59b4f5bbd5_smzb4"} 2.451046e+07
k3s_pod_mem{instance="nas.home.internal",job="truenas",pod="csi_nfs_controller_7b74694749_qmcw2"} 8.239514e+07
k3s_pod_mem{instance="nas.home.internal",job="truenas",pod="csi_nfs_node_6mn5r"} 4.755456e+07
k3s_pod_mem{instance="nas.home.internal",job="truenas",pod="csi_smb_controller_7fbbb8fb6f_n9jrw"} 6.168986e+07
k3s_pod_mem{instance="nas.home.internal",job="truenas",pod="csi_smb_node_kf5n9"} 5.264589e+07
k3s_pod_mem{instance="nas.home.internal",job="truenas",pod="immich_669bb67c8c_nj976"} 5.581537e+08
k3s_pod_mem{instance="nas.home.internal",job="truenas",pod="immich_machinelearning_84588c7fc6_7b7ml"} 3.181404e+08
k3s_pod_mem{instance="nas.home.internal",job="truenas",pod="immich_postgres_85744f8847_5sznp"} 1.0461184e+07
k3s_pod_mem{instance="nas.home.internal",job="truenas",pod="immich_redis_7978c8949b_7rm9f"} 1.4426112e+07
k3s_pod_mem{instance="nas.home.internal",job="truenas",pod="jellyfin_8466dbcb4c_gckln"} 1.6529162e+09
k3s_pod_mem{instance="nas.home.internal",job="truenas",pod="snapshot_controller_546868dfb4_5rz6q"} 1.501184e+07
k3s_pod_mem{instance="nas.home.internal",job="truenas",pod="snapshot_controller_546868dfb4_w6lcn"} 1.71991e+07
# HELP k3s_pod_net Graphite metric k3s_pod_net
# TYPE k3s_pod_net gauge
k3s_pod_net{direction="incoming",instance="nas.home.internal",job="truenas",pod="coredns_59b4f5bbd5_smzb4"} 1.8815954e+08
k3s_pod_net{direction="incoming",instance="nas.home.internal",job="truenas",pod="csi_nfs_controller_7b74694749_qmcw2"} 7.620715e+09
k3s_pod_net{direction="incoming",instance="nas.home.internal",job="truenas",pod="csi_nfs_node_6mn5r"} 7.620722e+09
k3s_pod_net{direction="incoming",instance="nas.home.internal",job="truenas",pod="csi_smb_controller_7fbbb8fb6f_n9jrw"} 7.6207292e+09
k3s_pod_net{direction="incoming",instance="nas.home.internal",job="truenas",pod="csi_smb_node_kf5n9"} 7.620737e+09
k3s_pod_net{direction="incoming",instance="nas.home.internal",job="truenas",pod="immich_669bb67c8c_nj976"} 2.031233e+10
k3s_pod_net{direction="incoming",instance="nas.home.internal",job="truenas",pod="immich_machinelearning_84588c7fc6_7b7ml"} 3.014143e+09
k3s_pod_net{direction="incoming",instance="nas.home.internal",job="truenas",pod="immich_postgres_85744f8847_5sznp"} 3.806235e+08
k3s_pod_net{direction="incoming",instance="nas.home.internal",job="truenas",pod="immich_redis_7978c8949b_7rm9f"} 1.7458264e+09
k3s_pod_net{direction="incoming",instance="nas.home.internal",job="truenas",pod="jellyfin_8466dbcb4c_gckln"} 3.765717e+09
k3s_pod_net{direction="incoming",instance="nas.home.internal",job="truenas",pod="snapshot_controller_546868dfb4_5rz6q"} 8.384338e+07
k3s_pod_net{direction="incoming",instance="nas.home.internal",job="truenas",pod="snapshot_controller_546868dfb4_w6lcn"} 2.992192e+08
k3s_pod_net{direction="outgoing",instance="nas.home.internal",job="truenas",pod="coredns_59b4f5bbd5_smzb4"} 1.9213308e+08
k3s_pod_net{direction="outgoing",instance="nas.home.internal",job="truenas",pod="csi_nfs_controller_7b74694749_qmcw2"} 5.014854e+10
k3s_pod_net{direction="outgoing",instance="nas.home.internal",job="truenas",pod="csi_nfs_node_6mn5r"} 5.014855e+10
k3s_pod_net{direction="outgoing",instance="nas.home.internal",job="truenas",pod="csi_smb_controller_7fbbb8fb6f_n9jrw"} 5.0148552e+10
k3s_pod_net{direction="outgoing",instance="nas.home.internal",job="truenas",pod="csi_smb_node_kf5n9"} 5.014856e+10
k3s_pod_net{direction="outgoing",instance="nas.home.internal",job="truenas",pod="immich_669bb67c8c_nj976"} 4.389022e+09
k3s_pod_net{direction="outgoing",instance="nas.home.internal",job="truenas",pod="immich_machinelearning_84588c7fc6_7b7ml"} 5.656709e+07
k3s_pod_net{direction="outgoing",instance="nas.home.internal",job="truenas",pod="immich_postgres_85744f8847_5sznp"} 2.005117e+08
k3s_pod_net{direction="outgoing",instance="nas.home.internal",job="truenas",pod="immich_redis_7978c8949b_7rm9f"} 6.8871598e+08
k3s_pod_net{direction="outgoing",instance="nas.home.internal",job="truenas",pod="jellyfin_8466dbcb4c_gckln"} 1.0370508e+09
k3s_pod_net{direction="outgoing",instance="nas.home.internal",job="truenas",pod="snapshot_controller_546868dfb4_5rz6q"} 1.5547909e+07
k3s_pod_net{direction="outgoing",instance="nas.home.internal",job="truenas",pod="snapshot_controller_546868dfb4_w6lcn"} 1.692172e+08