fix: generate gauge metrics for all states (#173)
This commit is contained in:
parent
75d6e874ed
commit
26cc9ada66
1 changed files with 14 additions and 1 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue