Skip to content

Metric plugins - mackerel-plugin-apache2

mackerel-plugin-apache2 provides a way to monitor statistics about Apache2 as a metric.

To use this plugin, the Apache Status module (mod_status) must be enabled and accessible from the plugin.

Monitorable metrics

The metrics that can be monitored by mackerel-plugin-apache2 are as follows.

Apache Workers

The number of running server processes and threads can be monitored.

Metric Display NameMetric NameDiffStackedDescription
Busy Workerscustom.apache2.workers.busy_workersThe number of busy worker requests/threads
Idle Workerscustom.apache2.workers.idle_workersThe number of idle worker requests/threads

Apache Bytes

The amount of data sent out by the httpd process can be monitored.

Metric Display NameMetric NameDiffStackedDescription
Bytes Sentcustom.apache2.bytes.bytes_sentTotal traffic bytes per minute

Apache CPU Load

CPU utilization of the httpd process can be monitored.

Metric Display NameMetric NameDiffStackedDescription
CPU Loadcustom.apache2.cpu.cpu_loadCPU utilization

Apache Requests

The number of requests can be monitored.

Metric Display NameMetric NameDiffStackedDescription
Requestscustom.apache2.req.requestsThe number of requests received per minute

Apache Scoreboard

Each metric on the scoreboard (state of running server processes) can be monitored.

Metric Display NameMetric NameDiffStackedDescription
Waiting for connectioncustom.apache2.scoreboard.score-_The number of processes/threads started and waiting to be accessed
Starting upcustom.apache2.scoreboard.score-SThe number of processes/threads running
Reading requestcustom.apache2.scoreboard.score-RThe number of client requests being read
Sending replycustom.apache2.scoreboard.score-WThe number of responses to clients
Keepalivecustom.apache2.scoreboard.score-KThe number of requests waiting for KeepAlive
DNS lookupcustom.apache2.scoreboard.score-DThe number of names resolved by DNS
Closing connectioncustom.apache2.scoreboard.score-CThe number of connections closed
Loggingcustom.apache2.scoreboard.score-LThe number of logs output
Gracefully finishingcustom.apache2.scoreboard.score-GThe number of cases waiting for the end of processing in graceful restart
Idle cleanupcustom.apache2.scoreboard.score-IThe number of processes/threads stopped
Open slotcustom.apache2.scoreboard.score-The number of slots available

Configurable options

The options which can be configured in the plugin are as follows.

OptionShortEnvironment VariablesDescriptionDefault
--http_host-oIP address being listened to by httpd127.0.0.1
--http_port-pPort number being listened to by httpd80
--header-HHTTP header to be given at the time of request from plugin
--status_page-sURL path where statistics are available/server-status?auto
--tempfile-tMACKEREL_PLUGIN_WORKDIRDestination path for temporary file
--metric-key-prefixString to be given as prefix to the metric nameapache2
--metric-label-prefixString to be assigned to the graph name as prefixApache
  • Temporary files are created by default under /var/tmp/mackerel-agent or /tmp in the format mackerel-plugin-{Prefix or other string}-{hash string}.

Example configuration

toml
[plugin.metrics.apache2]
command = ["mackerel-plugin-apache2", "-p", "1080"]

To check the above settings manually, you can execute the following at the terminal.

mackerel-plugin-apache2 -p 1080

Configuration for Apache

Make sure that the Apache Status module (mod_status) is enabled in order to use mackerel-plugin-apache2.

The following configuration assumes publication at http://127.0.0.1:1080/server-status.

ExtendedStatus On
<VirtualHost 127.0.0.1:1080>
  <Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from localhost
  </Location>
</VirtualHost>

Troubleshooting

Cannot get metrics

If you are unable to obtain a metric after setting up the plugin, it may be due to a configuration that has not been reflected or an incorrect setting of the Status module on the Apache side. Please check the following points.

  • Whether or not mackerel-agent has been restarted after the plugin has been configured.
    • Restarting mackerel-agent is required for the settings to take effect.
  • Can you connect to the server-status endpoint with the curl command?
    • Please confirm that you can receive the HTTP 200 OK response with the following command when configured as shown in the configuration example.

      curl http://127.0.0.1:1080/server-status
    • If you have a http to https redirect configured in mod_rewrite, the plugin will not track the redirect; the Status module endpoint should be excluded from the redirect.

    • If you cannot get the results of the Status module with the curl command, it may be because it has been incorrectly configured or Apache has not been restarted.

Repository

https://github.com/mackerelio/mackerel-agent-plugins/tree/master/mackerel-plugin-apache2

References