Skip to content

Commit

Permalink
✨ Nouvelles métriques Kotary pour afficher l'overcommit à travers Pro…
Browse files Browse the repository at this point in the history
…metheus

L'objectif est que les Dashboard clients au travers de la solution Grafana Entreprise puisse automatiquement détecter le ratio configuré sur le cluster.
Ainsi le client n'a plus besoin de connaitre la valeur définie sur son cluster, elle est automatiquement récupérée sur son instance Prometheus.
  • Loading branch information
Kévin PEREZ committed Feb 6, 2024
1 parent 451bdea commit 3fd32df
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions internal/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io/ioutil"
"strings"

"github.com/prometheus/client_golang/prometheus"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/client-go/kubernetes"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -171,6 +172,37 @@ func parseConfigMap(configMap *v1.ConfigMap) (parsed *Config, err error) {

klog.Infof("Loaded config map : %+v\n", parsed)

generateMetricsFromConfigmap(parsed)

return

}

func generateMetricsFromConfigmap(parsed *Config) (err error) {

var (
kotaryRatioOvercommitMemory = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "kotary_ratio_overcommit_memory",
Help: "The ratioOverCommitMemory defined in the configmap",
},
)

kotaryRatioOvercommitCPU = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "kotary_ratio_overcommit_cpu",
Help: "The ratioOverCommitCPU defined in the configmap",
},
)
)

kotaryRatioOvercommitMemory.Set(parsed.RatioOverCommitMemory)
prometheus.MustRegister(kotaryRatioOvercommitMemory)

kotaryRatioOvercommitCPU.Set(parsed.RatioOverCommitCPU)
prometheus.MustRegister(kotaryRatioOvercommitCPU)

klog.Infof("Overcommit metrics are set")

return
}

0 comments on commit 3fd32df

Please sign in to comment.