We use this prometheus query to extract the installed k8s chart names in our cluster:
sum(label_join(kube_deployment_labels{namespace="mynamspace"}, "mylabel", "", "label_chart", "label_helm_sh_chart") ) by (mylabel)
The results (in mylabel
) are looking like that (plus some noise we hide in the table view)
super-nice-chart-12.34-0 even-better-chart-2.12.0-32 notsogood-0.36.0 another-amazing-thing-0.1.12
We want to show the name and the version in separate colums of a table.
The regex for splitting mylabel
is ([a-z-]+)-([0-9.-]*)
for name (matching group 1) and version (matching group 2)
super-nice-chart 12.34-0 even-better-chart 2.12.0-32 notsogood 0.36.0 another-amazing-thing 0.1.12
But I have no idea how to implement this regex into the query or $(which is the right place?)
Any suggestions?