updating prometheus metrics names according to naming best practices (#1912)
updating Go names to not use underscores
accidental tab autocomplete 🔪
This commit is contained in:
parent
8975800740
commit
40718c3865
1 changed files with 29 additions and 57 deletions
|
@ -33,13 +33,9 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
nginxStatusData struct {
|
nginxStatusData struct {
|
||||||
active *prometheus.Desc
|
connectionsTotal *prometheus.Desc
|
||||||
accepted *prometheus.Desc
|
requestsTotal *prometheus.Desc
|
||||||
handled *prometheus.Desc
|
connections *prometheus.Desc
|
||||||
requests *prometheus.Desc
|
|
||||||
reading *prometheus.Desc
|
|
||||||
writing *prometheus.Desc
|
|
||||||
waiting *prometheus.Desc
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -55,40 +51,20 @@ func NewNginxStatus(watchNamespace, ingressClass string, ngxHealthPort int, ngxV
|
||||||
}
|
}
|
||||||
|
|
||||||
p.data = &nginxStatusData{
|
p.data = &nginxStatusData{
|
||||||
active: prometheus.NewDesc(
|
connectionsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(ns, "", "active_connections_total"),
|
prometheus.BuildFQName(ns, "", "connections_total"),
|
||||||
"total number of active connections",
|
"total number of connections with state {active, accepted, handled}",
|
||||||
[]string{"ingress_class", "namespace"}, nil),
|
[]string{"ingress_class", "namespace", "state"}, nil),
|
||||||
|
|
||||||
accepted: prometheus.NewDesc(
|
requestsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(ns, "", "accepted_connections_total"),
|
|
||||||
"total number of accepted client connections",
|
|
||||||
[]string{"ingress_class", "namespace"}, nil),
|
|
||||||
|
|
||||||
handled: prometheus.NewDesc(
|
|
||||||
prometheus.BuildFQName(ns, "", "handled_connections_total"),
|
|
||||||
"total number of handled connections",
|
|
||||||
[]string{"ingress_class", "namespace"}, nil),
|
|
||||||
|
|
||||||
requests: prometheus.NewDesc(
|
|
||||||
prometheus.BuildFQName(ns, "", "requests_total"),
|
prometheus.BuildFQName(ns, "", "requests_total"),
|
||||||
"total number of client requests",
|
"total number of client requests",
|
||||||
[]string{"ingress_class", "namespace"}, nil),
|
[]string{"ingress_class", "namespace"}, nil),
|
||||||
|
|
||||||
reading: prometheus.NewDesc(
|
connections: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(ns, "", "current_reading_connections_total"),
|
prometheus.BuildFQName(ns, "", "connnections"),
|
||||||
"current number of connections where nginx is reading the request header",
|
"current number of client connections with state {reading, writing, waiting}",
|
||||||
[]string{"ingress_class", "namespace"}, nil),
|
[]string{"ingress_class", "namespace", "state"}, nil),
|
||||||
|
|
||||||
writing: prometheus.NewDesc(
|
|
||||||
prometheus.BuildFQName(ns, "", "current_writing_connections_total"),
|
|
||||||
"current number of connections where nginx is writing the response back to the client",
|
|
||||||
[]string{"ingress_class", "namespace"}, nil),
|
|
||||||
|
|
||||||
waiting: prometheus.NewDesc(
|
|
||||||
prometheus.BuildFQName(ns, "", "current_waiting_connections_total"),
|
|
||||||
"current number of idle client connections waiting for a request",
|
|
||||||
[]string{"ingress_class", "namespace"}, nil),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
go p.start()
|
go p.start()
|
||||||
|
@ -98,13 +74,9 @@ func NewNginxStatus(watchNamespace, ingressClass string, ngxHealthPort int, ngxV
|
||||||
|
|
||||||
// Describe implements prometheus.Collector.
|
// Describe implements prometheus.Collector.
|
||||||
func (p nginxStatusCollector) Describe(ch chan<- *prometheus.Desc) {
|
func (p nginxStatusCollector) Describe(ch chan<- *prometheus.Desc) {
|
||||||
ch <- p.data.active
|
ch <- p.data.connectionsTotal
|
||||||
ch <- p.data.accepted
|
ch <- p.data.requestsTotal
|
||||||
ch <- p.data.handled
|
ch <- p.data.connections
|
||||||
ch <- p.data.requests
|
|
||||||
ch <- p.data.reading
|
|
||||||
ch <- p.data.writing
|
|
||||||
ch <- p.data.waiting
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect implements prometheus.Collector.
|
// Collect implements prometheus.Collector.
|
||||||
|
@ -134,18 +106,18 @@ func (p nginxStatusCollector) scrape(ch chan<- prometheus.Metric) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(p.data.active,
|
ch <- prometheus.MustNewConstMetric(p.data.connectionsTotal,
|
||||||
prometheus.GaugeValue, float64(s.Active), p.ingressClass, p.watchNamespace)
|
prometheus.CounterValue, float64(s.Active), p.ingressClass, p.watchNamespace, "active")
|
||||||
ch <- prometheus.MustNewConstMetric(p.data.accepted,
|
ch <- prometheus.MustNewConstMetric(p.data.connectionsTotal,
|
||||||
prometheus.GaugeValue, float64(s.Accepted), p.ingressClass, p.watchNamespace)
|
prometheus.CounterValue, float64(s.Accepted), p.ingressClass, p.watchNamespace, "accepted")
|
||||||
ch <- prometheus.MustNewConstMetric(p.data.handled,
|
ch <- prometheus.MustNewConstMetric(p.data.connectionsTotal,
|
||||||
prometheus.GaugeValue, float64(s.Handled), p.ingressClass, p.watchNamespace)
|
prometheus.CounterValue, float64(s.Handled), p.ingressClass, p.watchNamespace, "handled")
|
||||||
ch <- prometheus.MustNewConstMetric(p.data.requests,
|
ch <- prometheus.MustNewConstMetric(p.data.requestsTotal,
|
||||||
prometheus.GaugeValue, float64(s.Requests), p.ingressClass, p.watchNamespace)
|
prometheus.CounterValue, float64(s.Requests), p.ingressClass, p.watchNamespace)
|
||||||
ch <- prometheus.MustNewConstMetric(p.data.reading,
|
ch <- prometheus.MustNewConstMetric(p.data.connections,
|
||||||
prometheus.GaugeValue, float64(s.Reading), p.ingressClass, p.watchNamespace)
|
prometheus.GaugeValue, float64(s.Reading), p.ingressClass, p.watchNamespace, "reading")
|
||||||
ch <- prometheus.MustNewConstMetric(p.data.writing,
|
ch <- prometheus.MustNewConstMetric(p.data.connections,
|
||||||
prometheus.GaugeValue, float64(s.Writing), p.ingressClass, p.watchNamespace)
|
prometheus.GaugeValue, float64(s.Writing), p.ingressClass, p.watchNamespace, "writing")
|
||||||
ch <- prometheus.MustNewConstMetric(p.data.waiting,
|
ch <- prometheus.MustNewConstMetric(p.data.connections,
|
||||||
prometheus.GaugeValue, float64(s.Waiting), p.ingressClass, p.watchNamespace)
|
prometheus.GaugeValue, float64(s.Waiting), p.ingressClass, p.watchNamespace, "waiting")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue