Merge pull request #16 from hipages/metric-process-duration

Export new metric phpfpm_process_request_duration and update README.md
This commit is contained in:
Enrico Stahn 2018-03-01 10:57:24 +11:00 committed by GitHub
commit 9d75397387
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 7 deletions

View file

@ -120,12 +120,16 @@ If you like to have a more granular reporting please use `phpfpm_process_state`.
# TYPE phpfpm_max_children_reached counter
# HELP phpfpm_max_listen_queue The maximum number of requests in the queue of pending connections since FPM has started.
# TYPE phpfpm_max_listen_queue counter
# HELP phpfpm_process_last_request_cpu
# HELP phpfpm_process_last_request_cpu The %cpu the last request consumed.
# TYPE phpfpm_process_last_request_cpu gauge
# HELP phpfpm_process_last_request_memory
# HELP phpfpm_process_last_request_memory The max amount of memory the last request consumed.
# TYPE phpfpm_process_last_request_memory gauge
# HELP phpfpm_process_requests
# HELP phpfpm_process_request_duration The duration in microseconds of the requests.
# TYPE phpfpm_process_request_duration gauge
# HELP phpfpm_process_requests The number of requests the process has served.
# TYPE phpfpm_process_requests counter
# HELP phpfpm_process_state The state of the process (Idle, Running, ...).
# TYPE phpfpm_process_state gauge
# HELP phpfpm_scrape_failures The number of failures scraping from PHP-FPM.
# TYPE phpfpm_scrape_failures counter
# HELP phpfpm_slow_requests The number of requests that exceeded your 'request_slowlog_timeout' value.

View file

@ -48,6 +48,7 @@ type Exporter struct {
processRequests *prometheus.Desc
processLastRequestMemory *prometheus.Desc
processLastRequestCPU *prometheus.Desc
processRequestDuration *prometheus.Desc
processState *prometheus.Desc
}
@ -138,25 +139,31 @@ func NewExporter(pm PoolManager) *Exporter {
processRequests: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "process_requests"),
"",
"The number of requests the process has served.",
[]string{"pool", "pid_hash"},
nil),
processLastRequestMemory: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "process_last_request_memory"),
"",
"The max amount of memory the last request consumed.",
[]string{"pool", "pid_hash"},
nil),
processLastRequestCPU: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "process_last_request_cpu"),
"",
"The %cpu the last request consumed.",
[]string{"pool", "pid_hash"},
nil),
processRequestDuration: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "process_request_duration"),
"The duration in microseconds of the requests.",
[]string{"pool", "pid_hash"},
nil),
processState: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "process_state"),
"The process state.",
"The state of the process (Idle, Running, ...).",
[]string{"pool", "pid_hash", "state"},
nil),
}
@ -208,6 +215,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric(e.processRequests, prometheus.CounterValue, float64(process.Requests), pool.Name, pidHash)
ch <- prometheus.MustNewConstMetric(e.processLastRequestMemory, prometheus.GaugeValue, float64(process.LastRequestMemory), pool.Name, pidHash)
ch <- prometheus.MustNewConstMetric(e.processLastRequestCPU, prometheus.GaugeValue, process.LastRequestCPU, pool.Name, pidHash)
ch <- prometheus.MustNewConstMetric(e.processRequestDuration, prometheus.GaugeValue, float64(process.RequestDuration), pool.Name, pidHash)
}
}
}