Apache HTTP server integration for Grafana Cloud
Apache HTTP server integration is an observability package of dashboards and alerts filled with metrics and logs.
This integration includes 5 useful alerts and 2 pre-built dashboards to help monitor and visualize Apache HTTP server metrics and logs.
Before you begin
Metrics are scraped from server-status page.
To enable it, add this code to your httpd.conf configuration file
<Location "/server-status">
SetHandler server-status
</Location>
For more information please check the official guide
Install Apache HTTP server integration for Grafana Cloud
- In your Grafana Cloud stack, click Connections in the left-hand menu.
- Find Apache HTTP server and click its tile to open the integration.
- Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send Apache HTTP server metrics and logs to your Grafana Cloud instance.
- Click Install to add this integration’s pre-built dashboards and alerts to your Grafana Cloud instance, and you can start monitoring your Apache HTTP server setup.
Post-install configuration for the Apache HTTP server integration
After enabling the metrics generation, instruct Grafana Agent to scrape your Apache HTTP nodes.
Apache HTTP exposes a /server-status?auto
endpoint. To scrape it, add the snippets above to your agent configuration file.
This integration supports metrics and logs from Apache HTTP server. If you want to see your logs and metrics correlated on your dashboards, as a single pane of glass, do the following:
job
andinstance
label values must match forapache_http
integration andlogs
scrape config in the agent configuration file.job
label must be set tointegrations/apache_http
(already configured in the snippets)instance
label must be set to a value that uniquely identifies your Apache Http Node. Replace<yourhostname>
in the snippets with a value appropriate to your environment.
Make sure to change targets
in the snippet according to your environment.
Logs are scraped from access.log and error.log files. Make sure to point the agent to these locations.
Configuration snippets for Grafana Agent
This integration relies on the Agent exporter, which is provided by default (with a reduced set of metrics) when you installed Grafana Agent.
Replace the existing agent
entry with the one provided here.
Below integrations
, insert the following lines, following the instructions above:
apache_http:
enabled: true
instance: '<your-instance-name>'
# job is integrations/apache_http by default
scrape_uri: 'http://localhost:8080/server-status?auto'
agent:
enabled: true
metric_relabel_configs:
# required for apache integration.
# scraping agent endpoint is required for apache histogram metric collection.
- source_labels: [exported_job]
target_label: job
- source_labels: [exported_instance]
target_label: instance
- regex: (exported_instance|exported_job)
action: labeldrop
Below logs.configs.scrape_configs
, insert the following lines according to your environment.
- job_name: integrations/apache_error
static_configs:
- targets:
- localhost
labels:
__path__: /var/log/apache2/error.log
job: integrations/apache_http
instance: '<your-instance-name>'
pipeline_stages:
- regex:
expression: '^\[[^ ]* (?P<timestamp>[^\]]*)\] \[(?:(?P<module>[^:\]]+):)?(?P<level>[^\]]+)\](?: \[pid (?P<pid>[^\]]*)\])?(?: \[client (?P<client>[^\]]*)\])? (?P<message>.*)$'
- labels:
module:
level:
- static_labels:
logtype: error
- job_name: integrations/apache_access
static_configs:
- targets:
- localhost
labels:
__path__: /var/log/apache2/access.log
job: integrations/apache_http
instance: '<your-instance-name>'
pipeline_stages:
- regex:
expression: '^(?P<ip>[^ ]*) [^ ]* (?P<user>[^ ]*) \[(?P<timestamp>[^\]]*)\] "(?P<method>\S+)(?: +(?P<path>[^ ]*) +\S*)?" (?P<code>[^ ]*) (?P<size>[^ ]*)(?: "(?P<referer>[^\"]*)" "(?P<agent>.*)")?$'
- metrics:
response_http_codes:
type: Histogram
description: "Apache responses by HTTP codes"
prefix: apache_
source: code
config:
buckets: [199,299,399,499,599]
- labels:
method:
- static_labels:
logtype: access
Full example configuration for Grafana Agent
Refer to the following Grafana Agent configuration for a complete example that contains all the snippets used for the Apache HTTP server integration. This example also includes metrics that are sent to monitor your Grafana Agent instance.
integrations:
prometheus_remote_write:
- basic_auth:
password: <your_prom_pass>
username: <your_prom_user>
url: <your_prom_url>
# Add here any snippet that belongs to the `integrations` section.
# For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
apache_http:
enabled: true
instance: '<your-instance-name>'
# job is integrations/apache_http by default
scrape_uri: 'http://localhost:8080/server-status?auto'
agent:
enabled: true
metric_relabel_configs:
# required for apache integration.
# scraping agent endpoint is required for apache histogram metric collection.
- source_labels: [exported_job]
target_label: job
- source_labels: [exported_instance]
target_label: instance
- regex: (exported_instance|exported_job)
action: labeldrop
logs:
configs:
- clients:
- basic_auth:
password: <your_loki_pass>
username: <your_loki_user>
url: <your_loki_url>
name: integrations
positions:
filename: /tmp/positions.yaml
scrape_configs:
# Add here any snippet that belongs to the `logs.configs.scrape_configs` section.
# For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
- job_name: integrations/apache_error
static_configs:
- targets:
- localhost
labels:
__path__: /var/log/apache2/error.log
job: integrations/apache_http
instance: '<your-instance-name>'
pipeline_stages:
- regex:
expression: '^\[[^ ]* (?P<timestamp>[^\]]*)\] \[(?:(?P<module>[^:\]]+):)?(?P<level>[^\]]+)\](?: \[pid (?P<pid>[^\]]*)\])?(?: \[client (?P<client>[^\]]*)\])? (?P<message>.*)$'
- labels:
module:
level:
- static_labels:
logtype: error
- job_name: integrations/apache_access
static_configs:
- targets:
- localhost
labels:
__path__: /var/log/apache2/access.log
job: integrations/apache_http
instance: '<your-instance-name>'
pipeline_stages:
- regex:
expression: '^(?P<ip>[^ ]*) [^ ]* (?P<user>[^ ]*) \[(?P<timestamp>[^\]]*)\] "(?P<method>\S+)(?: +(?P<path>[^ ]*) +\S*)?" (?P<code>[^ ]*) (?P<size>[^ ]*)(?: "(?P<referer>[^\"]*)" "(?P<agent>.*)")?$'
- metrics:
response_http_codes:
type: Histogram
description: "Apache responses by HTTP codes"
prefix: apache_
source: code
config:
buckets: [199,299,399,499,599]
- labels:
method:
- static_labels:
logtype: access
metrics:
configs:
- name: integrations
remote_write:
- basic_auth:
password: <your_prom_pass>
username: <your_prom_user>
url: <your_prom_url>
scrape_configs:
# Add here any snippet that belongs to the `metrics.configs.scrape_configs` section.
# For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
global:
scrape_interval: 60s
wal_directory: /tmp/grafana-agent-wal
Dashboards
The Apache HTTP server integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.
- Apache HTTP server
- Apache HTTP server logs
Apache HTTP server overview
Apache logs
Alerts
The Apache HTTP server integration includes the following useful alerts:
Alert | Description |
---|---|
ApacheDown | Warning: Apache is down. |
ApacheRestart | Info: Apache restart. |
ApacheWorkersLoad | Warning: Apache workers load is too high. |
ApacheResponseTimeTooHigh | Warning: Apache response time is too high. |
ApacheErrorsRateTooHigh | Critical: Apache errors rate is too high. |
Metrics
The most important metrics provided by the Apache HTTP server integration, which are used on the pre-built dashboards and Prometheus alerts, are as follows:
- apache_accesses_total
- apache_cpuload
- apache_duration_ms_total
- apache_info
- apache_response_http_codes_bucket
- apache_response_http_codes_count
- apache_scoreboard
- apache_sent_kilobytes_total
- apache_up
- apache_uptime_seconds_total
- apache_workers
Changelog
# 0.0.3 - September 2023
* New Filter Metrics option for configuring the Grafana Agent, which saves on metrics cost by dropping any metric not used by this integration. Beware that anything custom built using metrics that are not on the snippet will stop working.
* New hostname relabel option, which applies the instance name you write on the text box to the Grafana Agent configuration snippets, making it easier and less error prone to configure this mandatory label.
# 0.0.2 - August 2023
* Add regex filter for logs datasource
# 0.0.1 - June 2022
* Initial release
Cost
By connecting your Apache HTTP server instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see Active series and dpm usage and Cloud tier pricing.
Related resources from Grafana Labs


