Skip to content
Snippets Groups Projects
Commit f8d07562 authored by dborysenko's avatar dborysenko Committed by Pedro Gomes
Browse files

Added cpuload metric from ExtendedStatus option

Added cpuload metric.
Updated readme with changes made.
parent db8d373a
No related branches found
No related tags found
No related merge requests found
...@@ -48,15 +48,17 @@ docker run -d -p 9117:9117 apache_exporter \ ...@@ -48,15 +48,17 @@ docker run -d -p 9117:9117 apache_exporter \
The exporter collects a number of statistics from the server: The exporter collects a number of statistics from the server:
``` ```
# HELP apache_accesses_total Current total apache accesses # HELP apache_accesses_total Current total apache accesses (*)
# TYPE apache_accesses_total counter # TYPE apache_accesses_total counter
# HELP apache_scoreboard Apache scoreboard statuses # HELP apache_scoreboard Apache scoreboard statuses
# TYPE apache_scoreboard gauge # TYPE apache_scoreboard gauge
# HELP apache_sent_kilobytes_total Current total kbytes sent # HELP apache_sent_kilobytes_total Current total kbytes sent (*)
# TYPE apache_sent_kilobytes_total counter # TYPE apache_sent_kilobytes_total counter
# HELP apache_cpu_load CPU Load (*)
# TYPE apache_cpu_load gauge
# HELP apache_up Could the apache server be reached # HELP apache_up Could the apache server be reached
# TYPE apache_up gauge # TYPE apache_up gauge
# HELP apache_uptime_seconds_total Current uptime in seconds # HELP apache_uptime_seconds_total Current uptime in seconds (*)
# TYPE apache_uptime_seconds_total counter # TYPE apache_uptime_seconds_total counter
# HELP apache_workers Apache worker statuses # HELP apache_workers Apache worker statuses
# TYPE apache_workers gauge # TYPE apache_workers gauge
...@@ -90,6 +92,7 @@ Process metrics: ...@@ -90,6 +92,7 @@ Process metrics:
# TYPE process_virtual_memory_bytes gauge # TYPE process_virtual_memory_bytes gauge
``` ```
Metrics marked '(*)' are only available if ExtendedStatus is On in apache webserver configuration. In version 2.3.6, loading mod_status will toggle ExtendedStatus On by default.
## Author ## Author
......
...@@ -37,6 +37,7 @@ type Exporter struct { ...@@ -37,6 +37,7 @@ type Exporter struct {
scrapeFailures prometheus.Counter scrapeFailures prometheus.Counter
accessesTotal *prometheus.Desc accessesTotal *prometheus.Desc
kBytesTotal *prometheus.Desc kBytesTotal *prometheus.Desc
cpuload prometheus.Gauge
uptime *prometheus.Desc uptime *prometheus.Desc
workers *prometheus.GaugeVec workers *prometheus.GaugeVec
scoreboard *prometheus.GaugeVec scoreboard *prometheus.GaugeVec
...@@ -58,17 +59,22 @@ func NewExporter(uri string) *Exporter { ...@@ -58,17 +59,22 @@ func NewExporter(uri string) *Exporter {
}), }),
accessesTotal: prometheus.NewDesc( accessesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "accesses_total"), prometheus.BuildFQName(namespace, "", "accesses_total"),
"Current total apache accesses", "Current total apache accesses (*)",
nil, nil,
nil), nil),
kBytesTotal: prometheus.NewDesc( kBytesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "sent_kilobytes_total"), prometheus.BuildFQName(namespace, "", "sent_kilobytes_total"),
"Current total kbytes sent", "Current total kbytes sent (*)",
nil, nil,
nil), nil),
cpuload: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "cpuload",
Help: "The current percentage CPU used by each worker and in total by all workers combined (*)",
}),
uptime: prometheus.NewDesc( uptime: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "uptime_seconds_total"), prometheus.BuildFQName(namespace, "", "uptime_seconds_total"),
"Current uptime in seconds", "Current uptime in seconds (*)",
nil, nil,
nil), nil),
workers: prometheus.NewGaugeVec(prometheus.GaugeOpts{ workers: prometheus.NewGaugeVec(prometheus.GaugeOpts{
...@@ -105,6 +111,7 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) { ...@@ -105,6 +111,7 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
ch <- e.accessesTotal ch <- e.accessesTotal
ch <- e.kBytesTotal ch <- e.kBytesTotal
ch <- e.uptime ch <- e.uptime
e.cpuload.Describe(ch)
e.scrapeFailures.Describe(ch) e.scrapeFailures.Describe(ch)
e.workers.Describe(ch) e.workers.Describe(ch)
e.scoreboard.Describe(ch) e.scoreboard.Describe(ch)
...@@ -200,6 +207,13 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) error { ...@@ -200,6 +207,13 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) error {
} }
ch <- prometheus.MustNewConstMetric(e.kBytesTotal, prometheus.CounterValue, val) ch <- prometheus.MustNewConstMetric(e.kBytesTotal, prometheus.CounterValue, val)
case key == "CPULoad":
val, err := strconv.ParseFloat(v, 64)
if err != nil {
return err
}
e.cpuload.Set(val)
case key == "Uptime": case key == "Uptime":
val, err := strconv.ParseFloat(v, 64) val, err := strconv.ParseFloat(v, 64)
if err != nil { if err != nil {
...@@ -258,6 +272,7 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) error { ...@@ -258,6 +272,7 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) error {
} }
e.cpuload.Collect(ch)
e.workers.Collect(ch) e.workers.Collect(ch)
if connectionInfo { if connectionInfo {
e.connections.Collect(ch) e.connections.Collect(ch)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment