Skip to content

Commit

Permalink
Merge pull request #16 from hipages/metric-process-duration
Browse files Browse the repository at this point in the history
Export new metric phpfpm_process_request_duration and update README.md
  • Loading branch information
estahn committed Feb 28, 2018
2 parents e2698ac + a027060 commit 9d75397
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
10 changes: 7 additions & 3 deletions README.md
Expand Up @@ -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.
Expand Down
16 changes: 12 additions & 4 deletions phpfpm/exporter.go
Expand Up @@ -48,6 +48,7 @@ type Exporter struct {
processRequests *prometheus.Desc
processLastRequestMemory *prometheus.Desc
processLastRequestCPU *prometheus.Desc
processRequestDuration *prometheus.Desc
processState *prometheus.Desc
}

Expand Down Expand Up @@ -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),
}
Expand Down Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit 9d75397

Please sign in to comment.