fix: generate gauge metrics for all states (#173)

This commit is contained in:
Andrei Kirillov 2021-09-02 04:32:57 +03:00 committed by GitHub
parent 75d6e874ed
commit 26cc9ada66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -213,7 +213,20 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
for childNumber, process := range pool.Processes { for childNumber, process := range pool.Processes {
childName := fmt.Sprintf("%d", childNumber) childName := fmt.Sprintf("%d", childNumber)
ch <- prometheus.MustNewConstMetric(e.processState, prometheus.GaugeValue, 1, pool.Name, childName, process.State, pool.Address)
states := map[string]int{
PoolProcessRequestIdle: 0,
PoolProcessRequestRunning: 0,
PoolProcessRequestFinishing: 0,
PoolProcessRequestReadingHeaders: 0,
PoolProcessRequestInfo: 0,
PoolProcessRequestEnding: 0,
}
states[process.State]++
for stateName, inState := range states {
ch <- prometheus.MustNewConstMetric(e.processState, prometheus.GaugeValue, float64(inState), pool.Name, childName, stateName, pool.Address)
}
ch <- prometheus.MustNewConstMetric(e.processRequests, prometheus.CounterValue, float64(process.Requests), pool.Name, childName, pool.Address) ch <- prometheus.MustNewConstMetric(e.processRequests, prometheus.CounterValue, float64(process.Requests), pool.Name, childName, pool.Address)
ch <- prometheus.MustNewConstMetric(e.processLastRequestMemory, prometheus.GaugeValue, float64(process.LastRequestMemory), pool.Name, childName, pool.Address) ch <- prometheus.MustNewConstMetric(e.processLastRequestMemory, prometheus.GaugeValue, float64(process.LastRequestMemory), pool.Name, childName, pool.Address)
ch <- prometheus.MustNewConstMetric(e.processLastRequestCPU, prometheus.GaugeValue, process.LastRequestCPU, pool.Name, childName, pool.Address) ch <- prometheus.MustNewConstMetric(e.processLastRequestCPU, prometheus.GaugeValue, process.LastRequestCPU, pool.Name, childName, pool.Address)