---
title: "Apache HTTP server integration | Grafana Cloud documentation"
description: "Learn about Apache HTTP server Grafana Cloud integration."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# 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

![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```none
<Location "/server-status">
    SetHandler server-status
</Location>
```

For more information please check the official [guide](https://httpd.apache.org/docs/2.4/mod/mod_status.html#enable).

## Install Apache HTTP server integration for Grafana Cloud

1. In your Grafana Cloud stack, click **Connections** in the left-hand menu.
2. Find **Apache HTTP server** and click its tile to open the integration.
3. Review the prerequisites in the **Configuration Details** tab and set up Grafana Alloy to send Apache HTTP server metrics and logs to your Grafana Cloud instance.
4. 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.

## Configuration snippets for Grafana Alloy

### Simple mode

These snippets are configured to scrape a single Apache HTTP server instance running locally with default ports.

First, **manually** copy and append the following snippets into your alloy configuration file.

### Integrations snippets

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
prometheus.exporter.self "integrations_apache_http_histogram" { }

discovery.relabel "integrations_apache_http_histogram" {
    targets = prometheus.exporter.self.integrations_apache_http_histogram.targets

    rule {
        replacement  = "integrations/apache_http"
        target_label = "job"
    }

    rule {
        source_labels = ["exported_instance"]
        target_label = "instance"
    }
}

prometheus.scrape "integrations_apache_http_histogram" {
    targets    = discovery.relabel.integrations_apache_http_histogram.output
    forward_to = [prometheus.remote_write.metrics_service.receiver]
}

prometheus.exporter.apache "integrations_apache_http" {
    scrape_uri = "http://localhost:8080/server-status?auto"
}

discovery.relabel "integrations_apache_http" {
    targets = prometheus.exporter.apache.integrations_apache_http.targets

    rule {
        target_label = "instance"
        replacement  = constants.hostname
    }

    rule {
        target_label = "job"
        replacement  = "integrations/apache_http"
    }
}

prometheus.scrape "integrations_apache_http" {
    targets    = discovery.relabel.integrations_apache_http.output
    forward_to = [prometheus.remote_write.metrics_service.receiver]
    job_name   = "integrations/apache_http"
}
```

### Logs snippets

#### darwin

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_apache_error" {
    path_targets = [{
        __address__ = "localhost",
        __path__    = "/var/log/apache2/error.log",
        instance    = constants.hostname,
        job         = "integrations/apache_http",
    }]
}

loki.process "logs_integrations_integrations_apache_error" {
    forward_to = []

    stage.regex {
        expression = "^\\[[^ ]* (?P<timestamp>[^\\]]*)\\] \\[(?:(?P<module>[^:\\]]+):)?(?P<level>[^\\]]+)\\](?: \\[pid (?P<pid>[^\\]]*)\\])?(?: \\[client (?P<client>[^\\]]*)\\])? (?P<message>.*)$"
    }

    stage.labels {
        values = {
            level  = null,
            module = null,
        }
    }

    stage.static_labels {
        values = {
            logtype = "error",
        }
    }
}

loki.source.file "logs_integrations_integrations_apache_error" {
    targets    = local.file_match.logs_integrations_integrations_apache_error.targets
    forward_to = [loki.write.grafana_cloud_loki.receiver]
}

local.file_match "logs_integrations_integrations_apache_access" {
    path_targets = [{
        __address__ = "localhost",
        __path__    = "/var/log/apache2/access.log",
        instance    = constants.hostname,
        job         = "integrations/apache_http",
    }]
}

loki.process "logs_integrations_integrations_apache_access" {
    forward_to = [loki.write.grafana_cloud_loki.receiver]

    stage.regex {
        expression = "^(?P<ip>[^ ]*) [^ ]* (?P<user>[^ ]*) \\[(?P<timestamp>[^\\]]*)\\] \"(?P<method>\\S+)(?: +(?P<path>[^ ]*) +\\S*)?\" (?P<code>[^ ]*) (?P<size>[^ ]*)(?: \"(?P<referer>[^\\\"]*)\" \"(?P<agent>.*)\")?$"
    }

    stage.metrics { 
        metric.histogram {
            name    = "response_http_codes"
            description = "Apache responses by HTTP codes"
            source    = "code"
            prefix    = "apache_"
            buckets   = [199,299,399,499,599]
        }
    }

    stage.labels {
        values = {
            method = null,
        }
    }

    stage.static_labels {
        values = {
            logtype = "access",
        }
    }
}

loki.source.file "logs_integrations_integrations_apache_access" {
    targets    = local.file_match.logs_integrations_integrations_apache_access.targets
    forward_to = [loki.process.logs_integrations_integrations_apache_access.receiver]
}
```

#### linux

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_apache_error" {
    path_targets = [{
        __address__ = "localhost",
        __path__    = "/var/log/apache2/error.log",
        instance    = constants.hostname,
        job         = "integrations/apache_http",
    }]
}

loki.process "logs_integrations_integrations_apache_error" {
    forward_to = []

    stage.regex {
        expression = "^\\[[^ ]* (?P<timestamp>[^\\]]*)\\] \\[(?:(?P<module>[^:\\]]+):)?(?P<level>[^\\]]+)\\](?: \\[pid (?P<pid>[^\\]]*)\\])?(?: \\[client (?P<client>[^\\]]*)\\])? (?P<message>.*)$"
    }

    stage.labels {
        values = {
            level  = null,
            module = null,
        }
    }

    stage.static_labels {
        values = {
            logtype = "error",
        }
    }
}

loki.source.file "logs_integrations_integrations_apache_error" {
    targets    = local.file_match.logs_integrations_integrations_apache_error.targets
    forward_to = [loki.write.grafana_cloud_loki.receiver]
}

local.file_match "logs_integrations_integrations_apache_access" {
    path_targets = [{
        __address__ = "localhost",
        __path__    = "/var/log/apache2/access.log",
        instance    = constants.hostname,
        job         = "integrations/apache_http",
    }]
}

loki.process "logs_integrations_integrations_apache_access" {
    forward_to = [loki.write.grafana_cloud_loki.receiver]

    stage.regex {
        expression = "^(?P<ip>[^ ]*) [^ ]* (?P<user>[^ ]*) \\[(?P<timestamp>[^\\]]*)\\] \"(?P<method>\\S+)(?: +(?P<path>[^ ]*) +\\S*)?\" (?P<code>[^ ]*) (?P<size>[^ ]*)(?: \"(?P<referer>[^\\\"]*)\" \"(?P<agent>.*)\")?$"
    }

    stage.metrics { 
        metric.histogram {
            name    = "response_http_codes"
            description = "Apache responses by HTTP codes"
            source    = "code"
            prefix    = "apache_"
            buckets   = [199,299,399,499,599]
        }
    }

    stage.labels {
        values = {
            method = null,
        }
    }

    stage.static_labels {
        values = {
            logtype = "access",
        }
    }
}

loki.source.file "logs_integrations_integrations_apache_access" {
    targets    = local.file_match.logs_integrations_integrations_apache_access.targets
    forward_to = [loki.process.logs_integrations_integrations_apache_access.receiver]
}
```

#### windows

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_apache_error" {
    path_targets = [{
        __address__ = "localhost",
        __path__    = "/var/log/apache2/error.log",
        instance    = constants.hostname,
        job         = "integrations/apache_http",
    }]
}

loki.process "logs_integrations_integrations_apache_error" {
    forward_to = []

    stage.regex {
        expression = "^\\[[^ ]* (?P<timestamp>[^\\]]*)\\] \\[(?:(?P<module>[^:\\]]+):)?(?P<level>[^\\]]+)\\](?: \\[pid (?P<pid>[^\\]]*)\\])?(?: \\[client (?P<client>[^\\]]*)\\])? (?P<message>.*)$"
    }

    stage.labels {
        values = {
            level  = null,
            module = null,
        }
    }

    stage.static_labels {
        values = {
            logtype = "error",
        }
    }
}

loki.source.file "logs_integrations_integrations_apache_error" {
    targets    = local.file_match.logs_integrations_integrations_apache_error.targets
    forward_to = [loki.write.grafana_cloud_loki.receiver]
}

local.file_match "logs_integrations_integrations_apache_access" {
    path_targets = [{
        __address__ = "localhost",
        __path__    = "/var/log/apache2/access.log",
        instance    = constants.hostname,
        job         = "integrations/apache_http",
    }]
}

loki.process "logs_integrations_integrations_apache_access" {
    forward_to = [loki.write.grafana_cloud_loki.receiver]

    stage.regex {
        expression = "^(?P<ip>[^ ]*) [^ ]* (?P<user>[^ ]*) \\[(?P<timestamp>[^\\]]*)\\] \"(?P<method>\\S+)(?: +(?P<path>[^ ]*) +\\S*)?\" (?P<code>[^ ]*) (?P<size>[^ ]*)(?: \"(?P<referer>[^\\\"]*)\" \"(?P<agent>.*)\")?$"
    }

    stage.metrics { 
        metric.histogram {
            name    = "response_http_codes"
            description = "Apache responses by HTTP codes"
            source    = "code"
            prefix    = "apache_"
            buckets   = [199,299,399,499,599]
        }
    }

    stage.labels {
        values = {
            method = null,
        }
    }

    stage.static_labels {
        values = {
            logtype = "access",
        }
    }
}

loki.source.file "logs_integrations_integrations_apache_access" {
    targets    = local.file_match.logs_integrations_integrations_apache_access.targets
    forward_to = [loki.process.logs_integrations_integrations_apache_access.receiver]
}
```

### Advanced mode

The following snippets provide examples to guide you through the configuration process.

To instruct Grafana Alloy to scrape your Apache HTTP server instances, **manually** copy and append the snippets to your alloy configuration file, then follow subsequent instructions.

### Advanced integrations snippets

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
prometheus.exporter.self "integrations_apache_http_histogram" { }

discovery.relabel "integrations_apache_http_histogram" {
    targets = prometheus.exporter.self.integrations_apache_http_histogram.targets

    rule {
        replacement  = "integrations/apache_http"
        target_label = "job"
    }

    rule {
        source_labels = ["exported_instance"]
        target_label = "instance"
    }
}

prometheus.scrape "integrations_apache_http_histogram" {
    targets    = discovery.relabel.integrations_apache_http_histogram.output
    forward_to = [prometheus.remote_write.metrics_service.receiver]
}

prometheus.exporter.apache "integrations_apache_http" {
    scrape_uri = "http://localhost:8080/server-status?auto"
}

discovery.relabel "integrations_apache_http" {
    targets = prometheus.exporter.apache.integrations_apache_http.targets

    rule {
        target_label = "instance"
        replacement  = constants.hostname
    }

    rule {
        target_label = "job"
        replacement  = "integrations/apache_http"
    }
}

prometheus.scrape "integrations_apache_http" {
    targets    = discovery.relabel.integrations_apache_http.output
    forward_to = [prometheus.remote_write.metrics_service.receiver]
    job_name   = "integrations/apache_http"
}
```

This integrations uses the [prometheus.exporter.apache](/docs/alloy/latest/reference/components/prometheus.exporter.apache/) component to generate metrics from a Apache HTTP server instance.

For the full array of configuration options, refer to the [prometheus.exporter.apache](/docs/alloy/latest/reference/components/prometheus.exporter.apache/) component reference documentation.

This exporter must be linked with a [discovery.relabel](/docs/alloy/latest/reference/components/discovery.relabel/) component to apply the necessary relabelings.

For each Apache HTTP server instance to be monitored you must create a pair of these components.

Configure the following properties within each `discovery.relabel` component:

- `instance` label: `constants.hostname` sets the `instance` label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this Apache HTTP server instance. Make sure this label value is the same for all telemetry data collected for this instance.

You can then scrape them by including each `discovery.relabel` under `targets` within the [prometheus.scrape](/docs/alloy/latest/reference/components/prometheus.scrape/) component.

### Advanced logs snippets

#### darwin

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_apache_error" {
    path_targets = [{
        __address__ = "localhost",
        __path__    = "/var/log/apache2/error.log",
        instance    = constants.hostname,
        job         = "integrations/apache_http",
    }]
}

loki.process "logs_integrations_integrations_apache_error" {
    forward_to = []

    stage.regex {
        expression = "^\\[[^ ]* (?P<timestamp>[^\\]]*)\\] \\[(?:(?P<module>[^:\\]]+):)?(?P<level>[^\\]]+)\\](?: \\[pid (?P<pid>[^\\]]*)\\])?(?: \\[client (?P<client>[^\\]]*)\\])? (?P<message>.*)$"
    }

    stage.labels {
        values = {
            level  = null,
            module = null,
        }
    }

    stage.static_labels {
        values = {
            logtype = "error",
        }
    }
}

loki.source.file "logs_integrations_integrations_apache_error" {
    targets    = local.file_match.logs_integrations_integrations_apache_error.targets
    forward_to = [loki.write.grafana_cloud_loki.receiver]
}

local.file_match "logs_integrations_integrations_apache_access" {
    path_targets = [{
        __address__ = "localhost",
        __path__    = "/var/log/apache2/access.log",
        instance    = constants.hostname,
        job         = "integrations/apache_http",
    }]
}

loki.process "logs_integrations_integrations_apache_access" {
    forward_to = [loki.write.grafana_cloud_loki.receiver]

    stage.regex {
        expression = "^(?P<ip>[^ ]*) [^ ]* (?P<user>[^ ]*) \\[(?P<timestamp>[^\\]]*)\\] \"(?P<method>\\S+)(?: +(?P<path>[^ ]*) +\\S*)?\" (?P<code>[^ ]*) (?P<size>[^ ]*)(?: \"(?P<referer>[^\\\"]*)\" \"(?P<agent>.*)\")?$"
    }           

    stage.labels {
        values = {
            method = null,
        }
    }

    stage.metrics { 
        metric.histogram {
            name    = "response_http_codes"
            description = "Apache responses by HTTP codes"
            source    = "code"
            prefix    = "apache_"
            buckets   = [199,299,399,499,599]
        }
    }

    stage.static_labels {
        values = {
            logtype = "access",
        }
    }
}

loki.source.file "logs_integrations_integrations_apache_access" {
    targets    = local.file_match.logs_integrations_integrations_apache_access.targets
    forward_to = [loki.process.logs_integrations_integrations_apache_access.receiver]
}
```

#### linux

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_apache_error" {
    path_targets = [{
        __address__ = "localhost",
        __path__    = "/var/log/apache2/error.log",
        instance    = constants.hostname,
        job         = "integrations/apache_http",
    }]
}

loki.process "logs_integrations_integrations_apache_error" {
    forward_to = []

    stage.regex {
        expression = "^\\[[^ ]* (?P<timestamp>[^\\]]*)\\] \\[(?:(?P<module>[^:\\]]+):)?(?P<level>[^\\]]+)\\](?: \\[pid (?P<pid>[^\\]]*)\\])?(?: \\[client (?P<client>[^\\]]*)\\])? (?P<message>.*)$"
    }

    stage.labels {
        values = {
            level  = null,
            module = null,
        }
    }

    stage.static_labels {
        values = {
            logtype = "error",
        }
    }
}

loki.source.file "logs_integrations_integrations_apache_error" {
    targets    = local.file_match.logs_integrations_integrations_apache_error.targets
    forward_to = [loki.write.grafana_cloud_loki.receiver]
}

local.file_match "logs_integrations_integrations_apache_access" {
    path_targets = [{
        __address__ = "localhost",
        __path__    = "/var/log/apache2/access.log",
        instance    = constants.hostname,
        job         = "integrations/apache_http",
    }]
}

loki.process "logs_integrations_integrations_apache_access" {
    forward_to = [loki.write.grafana_cloud_loki.receiver]

    stage.regex {
        expression = "^(?P<ip>[^ ]*) [^ ]* (?P<user>[^ ]*) \\[(?P<timestamp>[^\\]]*)\\] \"(?P<method>\\S+)(?: +(?P<path>[^ ]*) +\\S*)?\" (?P<code>[^ ]*) (?P<size>[^ ]*)(?: \"(?P<referer>[^\\\"]*)\" \"(?P<agent>.*)\")?$"
    }           

    stage.labels {
        values = {
            method = null,
        }
    }

    stage.metrics { 
        metric.histogram {
            name    = "response_http_codes"
            description = "Apache responses by HTTP codes"
            source    = "code"
            prefix    = "apache_"
            buckets   = [199,299,399,499,599]
        }
    }

    stage.static_labels {
        values = {
            logtype = "access",
        }
    }
}

loki.source.file "logs_integrations_integrations_apache_access" {
    targets    = local.file_match.logs_integrations_integrations_apache_access.targets
    forward_to = [loki.process.logs_integrations_integrations_apache_access.receiver]
}
```

#### windows

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_apache_error" {
    path_targets = [{
        __address__ = "localhost",
        __path__    = "/var/log/apache2/error.log",
        instance    = constants.hostname,
        job         = "integrations/apache_http",
    }]
}

loki.process "logs_integrations_integrations_apache_error" {
    forward_to = []

    stage.regex {
        expression = "^\\[[^ ]* (?P<timestamp>[^\\]]*)\\] \\[(?:(?P<module>[^:\\]]+):)?(?P<level>[^\\]]+)\\](?: \\[pid (?P<pid>[^\\]]*)\\])?(?: \\[client (?P<client>[^\\]]*)\\])? (?P<message>.*)$"
    }

    stage.labels {
        values = {
            level  = null,
            module = null,
        }
    }

    stage.static_labels {
        values = {
            logtype = "error",
        }
    }
}

loki.source.file "logs_integrations_integrations_apache_error" {
    targets    = local.file_match.logs_integrations_integrations_apache_error.targets
    forward_to = [loki.write.grafana_cloud_loki.receiver]
}

local.file_match "logs_integrations_integrations_apache_access" {
    path_targets = [{
        __address__ = "localhost",
        __path__    = "/var/log/apache2/access.log",
        instance    = constants.hostname,
        job         = "integrations/apache_http",
    }]
}

loki.process "logs_integrations_integrations_apache_access" {
    forward_to = [loki.write.grafana_cloud_loki.receiver]

    stage.regex {
        expression = "^(?P<ip>[^ ]*) [^ ]* (?P<user>[^ ]*) \\[(?P<timestamp>[^\\]]*)\\] \"(?P<method>\\S+)(?: +(?P<path>[^ ]*) +\\S*)?\" (?P<code>[^ ]*) (?P<size>[^ ]*)(?: \"(?P<referer>[^\\\"]*)\" \"(?P<agent>.*)\")?$"
    }           

    stage.labels {
        values = {
            method = null,
        }
    }

    stage.metrics { 
        metric.histogram {
            name    = "response_http_codes"
            description = "Apache responses by HTTP codes"
            source    = "code"
            prefix    = "apache_"
            buckets   = [199,299,399,499,599]
        }
    }

    stage.static_labels {
        values = {
            logtype = "access",
        }
    }
}

loki.source.file "logs_integrations_integrations_apache_access" {
    targets    = local.file_match.logs_integrations_integrations_apache_access.targets
    forward_to = [loki.process.logs_integrations_integrations_apache_access.receiver]
}
```

## 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:

Expand table

| 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
- up

## Changelog

md ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```md
# 1.0.1 - October 2024

* Update Alloy snippets to properly pass job label from alloy histogram data

# 1.0.0 - July 2024

* Update mixin - fix issue with the HTTP code histogram panel
* Update Alloy snippets to generate HTTP code histograms from access log

# 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](/docs/grafana-cloud/fundamentals/active-series-and-dpm/) and [Cloud tier pricing](/products/cloud/pricing/).
