From a0270607e85009cee7bdbd8475f57b2b0ddc68f4 Mon Sep 17 00:00:00 2001 From: Enrico Stahn Date: Thu, 1 Mar 2018 10:54:12 +1100 Subject: [PATCH] Export new metric phpfpm_process_request_duration and update README.md --- README.md | 10 +++++++--- phpfpm/exporter.go | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6d719de1..724b1543 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/phpfpm/exporter.go b/phpfpm/exporter.go index b4cba35f..8235e852 100644 --- a/phpfpm/exporter.go +++ b/phpfpm/exporter.go @@ -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) } } }