Menu
Grafana Cloud

Apache HTTP server integration for Grafana Cloud

Apache HTTP server integration is an observability package of dashboards and alerts filled with metrics and logs.

Install Apache HTTP server integration for Grafana Cloud

  1. In your Grafana instance, Click Integrations and Connections (lightning bolt icon), then click on install integration on Apache HTTP server tile.
  2. Wait for the integration to be installed and then follow the steps shown to setup Grafana Agent to automatically scrape and send Apache HTTP server metrics to your Cloud Instance.

Pre-install configuration for the Apache HTTP server integration

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

Logs are scraped from access.log and error.log files. You would need to point Grafana Agent to their locations.

Post-install configuration for the Apache HTTP server integration

This integration supports metrics and logs from Apache HTTP server. In order to see these signals correlated on the same dashboard, job and instance labels must match for apache_http integration, agent integration, and logs scrape config in the Agent configuration file:

metrics:
  wal_directory: /var/lib/grafana-agent/wal
    remote_write:
      - url: https://cortex/api/v1/write

integrations:
  apache_http:
    enabled: true
    instance: "<yourhostname>"
    # 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:
  - name: integrations
    clients:
      - url: http://loki:3100/loki/api/v1/push
    positions:
      filename: /var/lib/grafana-agent/logs/positions.yaml
    scrape_configs:
    - job_name: integrations/apache_error
      static_configs:
      - targets:
        - localhost
        labels:
          __path__: /var/log/apache2/error.log
          job: integrations/apache_http
          instance: <yourhostname>
      pipeline_stages:
        - regex:
            # https://regex101.com/r/zNIq1V/1
            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: <yourhostname>
      pipeline_stages:
        - regex:
            # https://regex101.com/r/9G75bY/1
            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

Dashboards

This integration includes the following dashboards.

  • Apache HTTP server logs
  • Apache HTTP server

Apache HTTP server overview

image

Apache logs

image

Metrics

Below is a list of the metrics used on the dashboards and in alerts of the integration and are automatically written to your Grafana Cloud instance.

  • 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

Alerts

The integration also comes packaged with a number of handy alerts.

Group: apache-http

AlertDescription
ApacheDownWarning: Apache is down.
ApacheRestartInfo: Apache restart.
ApacheWorkersLoadWarning: Apache workers load is too high.
ApacheResponseTimeTooHighWarning: Apache response time is too high.
ApacheErrorsRateTooHighCritical: Apache errors rate is too high.

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.