package federation import "github.com/prometheus/client_golang/prometheus" var ( upDesc = prometheus.NewDesc("llmgw_federation_peer_up", "Whether a federated peer answered its last check: 1 up, 0 down and not sent requests.", []string{"peer"}, nil) latencyDesc = prometheus.NewDesc("llmgw_federation_peer_latency_seconds", "How long a federated peer took to answer /ready at its last check.", []string{"peer"}, nil) modelsDesc = prometheus.NewDesc("llmgw_federation_peer_models", "How many models a federated peer offers this cluster.", []string{"peer"}, nil) ) // Describe and Collect publish each peer's health beside the traffic it // takes, so "overflow went to the other site" and "the other site was slow" // are on one chart. func (s *Service) Describe(ch chan<- *prometheus.Desc) { ch <- upDesc ch <- latencyDesc ch <- modelsDesc } func (s *Service) Collect(ch chan<- prometheus.Metric) { for _, st := range s.List() { up := 0.0 if st.Up { up = 1 } offered := 0 for _, m := range st.Models { if !m.Withdrawn { offered++ } } ch <- prometheus.MustNewConstMetric(upDesc, prometheus.GaugeValue, up, st.Name) ch <- prometheus.MustNewConstMetric(latencyDesc, prometheus.GaugeValue, st.Latency.Seconds(), st.Name) ch <- prometheus.MustNewConstMetric(modelsDesc, prometheus.GaugeValue, float64(offered), st.Name) } }