Skip to content

Commit 26cc9ad

Browse files
authored
fix: generate gauge metrics for all states (#173)
1 parent 75d6e87 commit 26cc9ad

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

phpfpm/exporter.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,20 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
213213

214214
for childNumber, process := range pool.Processes {
215215
childName := fmt.Sprintf("%d", childNumber)
216-
ch <- prometheus.MustNewConstMetric(e.processState, prometheus.GaugeValue, 1, pool.Name, childName, process.State, pool.Address)
216+
217+
states := map[string]int{
218+
PoolProcessRequestIdle: 0,
219+
PoolProcessRequestRunning: 0,
220+
PoolProcessRequestFinishing: 0,
221+
PoolProcessRequestReadingHeaders: 0,
222+
PoolProcessRequestInfo: 0,
223+
PoolProcessRequestEnding: 0,
224+
}
225+
states[process.State]++
226+
227+
for stateName, inState := range states {
228+
ch <- prometheus.MustNewConstMetric(e.processState, prometheus.GaugeValue, float64(inState), pool.Name, childName, stateName, pool.Address)
229+
}
217230
ch <- prometheus.MustNewConstMetric(e.processRequests, prometheus.CounterValue, float64(process.Requests), pool.Name, childName, pool.Address)
218231
ch <- prometheus.MustNewConstMetric(e.processLastRequestMemory, prometheus.GaugeValue, float64(process.LastRequestMemory), pool.Name, childName, pool.Address)
219232
ch <- prometheus.MustNewConstMetric(e.processLastRequestCPU, prometheus.GaugeValue, process.LastRequestCPU, pool.Name, childName, pool.Address)

0 commit comments

Comments
 (0)