---
title: Apache
description: Track requests per second, bytes served, worker threads, uptime, and more.
breadcrumbs: Docs > Integrations > Apache
---

# Apache
Supported OS Integration version7.4.0


## Overview{% #overview %}

The Apache check tracks requests per second, bytes served, number of worker threads, service uptime, and more.

**Minimum Agent version:** 6.0.0

## Setup{% #setup %}

### Installation{% #installation %}

The Apache check is packaged with the [Datadog Agent](https://app.datadoghq.com/account/settings/agent/latest). To start gathering your Apache metrics and logs, you need to:

1. [Install the Agent](https://docs.datadoghq.com/agent.md) on your Apache servers.

1. Install `mod_status` on your Apache servers and enable `ExtendedStatus`.

### Configuration{% #configuration %}

{% tab title="Host" %}
#### Host{% #host %}

To configure this check for an Agent running on a host:

##### Metric collection{% #metric-collection %}

1. Edit the `apache.d/conf.yaml` file in the `conf.d/` folder at the root of your [Agent's configuration directory](https://docs.datadoghq.com/agent/guide/agent-configuration-files.md#agent-configuration-directory) to start collecting your Apache metrics. See the [sample apache.d/conf.yaml](https://github.com/DataDog/integrations-core/blob/master/apache/datadog_checks/apache/data/conf.yaml.example) for all available configuration options.

   ```yaml
   init_config:
   
   instances:
     ## @param apache_status_url - string - required
     ## Status url of your Apache server.
     #
     - apache_status_url: http://localhost/server-status?auto
   ```

1. [Restart the Agent](https://docs.datadoghq.com/agent/guide/agent-commands.md#start-stop-and-restart-the-agent).

##### Log collection{% #log-collection %}

*Available for Agent versions >6.0*

1. Collecting logs is disabled by default in the Datadog Agent. Enable it in `datadog.yaml`:

   ```yaml
   logs_enabled: true
   ```

1. Add this configuration block to your `apache.d/conf.yaml` file to start collecting your Apache logs, adjusting the `path` and `service` values to configure them for your environment:

   ```yaml
   logs:
     - type: file
       path: /path/to/your/apache/access.log
       source: apache
       service: apache
       sourcecategory: http_web_access
   
     - type: file
       path: /path/to/your/apache/error.log
       source: apache
       service: apache
       sourcecategory: http_web_error
   ```

See the [sample apache.d/conf.yaml](https://github.com/DataDog/integrations-core/blob/master/apache/datadog_checks/apache/data/conf.yaml.example) for all available configuration options.

1. [Restart the Agent](https://docs.datadoghq.com/agent/guide/agent-commands.md#start-stop-and-restart-the-agent).

{% /tab %}

{% tab title="Docker" %}
#### Docker{% #docker %}

To configure this check for an Agent running on a container:

##### Metric collection{% #metric-collection %}

Set [Autodiscovery Integrations Templates](https://docs.datadoghq.com/agent/docker/integrations.md?tab=docker) as Docker labels on your application container:

```yaml
LABEL "com.datadoghq.ad.check_names"='["apache"]'
LABEL "com.datadoghq.ad.init_configs"='[{}]'
LABEL "com.datadoghq.ad.instances"='[{"apache_status_url": "http://%%host%%/server-status?auto"}]'
```

##### Log collection{% #log-collection %}

Collecting logs is disabled by default in the Datadog Agent. To enable it, see [Docker Log Collection](https://docs.datadoghq.com/agent/docker/log.md?tab=containerinstallation#installation).

Then, set [Log Integrations](https://docs.datadoghq.com/agent/docker/log.md?tab=containerinstallation#log-integrations) as Docker labels:

```yaml
LABEL "com.datadoghq.ad.logs"='[{"source": "apache", "service": "<SERVICE_NAME>"}]'
```

{% /tab %}

{% tab title="Kubernetes" %}
#### Kubernetes{% #kubernetes %}

To configure this check for an Agent running on Kubernetes:

##### Metric collection{% #metric-collection %}

Set [Autodiscovery Integrations Templates](https://docs.datadoghq.com/agent/kubernetes/integrations.md?tab=kubernetes) as pod annotations on your application container. Aside from this, templates can also be configured with [a file, a configmap, or a key-value store](https://docs.datadoghq.com/agent/kubernetes/integrations.md?tab=kubernetes#configuration).

**Annotations v1** (for Datadog Agent < v7.36)

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: apache
  annotations:
    ad.datadoghq.com/apache.check_names: '["apache"]'
    ad.datadoghq.com/apache.init_configs: '[{}]'
    ad.datadoghq.com/apache.instances: |
      [
        {
          "apache_status_url": "http://%%host%%/server-status?auto"
        }
      ]
spec:
  containers:
    - name: apache
```

**Annotations v2** (for Datadog Agent v7.36+)

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: apache
  annotations:
    ad.datadoghq.com/apache.checks: |
      {
        "apache": {
          "init_config": {},
          "instances": [
            {
              "apache_status_url": "http://%%host%%/server-status?auto"
            }
          ]
        }
      }
spec:
  containers:
    - name: apache
```

##### Log collection{% #log-collection %}

Collecting logs is disabled by default in the Datadog Agent. To enable it, see [Kubernetes Log Collection](https://docs.datadoghq.com/agent/kubernetes/log.md?tab=containerinstallation#setup).

Then, set [Log Integrations](https://docs.datadoghq.com/agent/docker/log.md?tab=containerinstallation#log-integrations) as pod annotations. This can also be configured with [a file, a configmap, or a key-value store](https://docs.datadoghq.com/agent/kubernetes/log.md?tab=daemonset#configuration).

**Annotations v1/v2**

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: apache
  annotations:
    ad.datadoghq.com/apache.logs: '[{"source":"apache","service":"<SERVICE_NAME>"}]'
spec:
  containers:
    - name: apache
```

{% /tab %}

{% tab title="ECS" %}
#### ECS{% #ecs %}

To configure this check for an Agent running on ECS:

##### Metric collection{% #metric-collection %}

Set [Autodiscovery Integrations Templates](https://docs.datadoghq.com/agent/docker/integrations.md?tab=docker) as Docker labels on your application container:

```json
{
  "containerDefinitions": [{
    "name": "apache",
    "image": "apache:latest",
    "dockerLabels": {
      "com.datadoghq.ad.check_names": "[\"apache\"]",
      "com.datadoghq.ad.init_configs": "[{}]",
      "com.datadoghq.ad.instances": "[{\"apache_status_url\": \"http://%%host%%/server-status?auto\"}]"
    }
  }]
}
```

##### Log collection{% #log-collection %}

Collecting logs is disabled by default in the Datadog Agent. To enable it, see [ECS Log Collection](https://docs.datadoghq.com/agent/amazon_ecs/logs.md?tab=linux).

Then, set [Log Integrations](https://docs.datadoghq.com/agent/docker/log.md?tab=containerinstallation#log-integrations) as Docker labels:

```json
{
  "containerDefinitions": [{
    "name": "apache",
    "image": "apache:latest",
    "dockerLabels": {
      "com.datadoghq.ad.logs": "[{\"source\":\"apache\",\"service\":\"<YOUR_APP_NAME>\"}]"
    }
  }]
}
```

{% /tab %}

### Validation{% #validation %}

[Run the Agent's status subcommand](https://docs.datadoghq.com/agent/guide/agent-commands.md#agent-status-and-information) and look for `apache` under the Checks section.

## Data Collected{% #data-collected %}

### Metrics{% #metrics %}

|  |
|  |
| **apache.conns\_async\_closing**(gauge)               | The number of asynchronous closing connections.*Shown as connection*                                                                  |
| **apache.conns\_async\_keep\_alive**(gauge)           | The number of asynchronous keep alive connections.*Shown as connection*                                                               |
| **apache.conns\_async\_writing**(gauge)               | The number of asynchronous writes connections.*Shown as connection*                                                                   |
| **apache.conns\_total**(gauge)                        | The total number of connections performed.*Shown as connection*                                                                       |
| **apache.net.bytes**(gauge)                           | The total number of bytes served.*Shown as byte*                                                                                      |
| **apache.net.bytes\_per\_s**(gauge)                   | The number of bytes served per second.*Shown as byte*                                                                                 |
| **apache.net.hits**(gauge)                            | The total number of requests performed.*Shown as request*                                                                             |
| **apache.net.request\_per\_s**(gauge)                 | The number of requests performed per second.*Shown as request*                                                                        |
| **apache.performance.busy\_workers**(gauge)           | The number of workers serving requests.*Shown as thread*                                                                              |
| **apache.performance.cpu\_load**(gauge)               | The percent of CPU used.*Shown as percent*                                                                                            |
| **apache.performance.idle\_workers**(gauge)           | The number of idle workers.*Shown as thread*                                                                                          |
| **apache.performance.max\_workers**(gauge)            | The maximum number of workers apache can start.*Shown as thread*                                                                      |
| **apache.performance.uptime**(gauge)                  | The amount of time the server has been running.*Shown as second*                                                                      |
| **apache.scoreboard.closing\_connection**(gauge)      | The amount of workers that are currently closing a connection.*Shown as thread*                                                       |
| **apache.scoreboard.disabled**(gauge)                 | These slots will never be able to handle any requests, indicates a misconfiguration.*Shown as thread*                                 |
| **apache.scoreboard.dns\_lookup**(gauge)              | The workers waiting on a DNS lookup.*Shown as thread*                                                                                 |
| **apache.scoreboard.gracefully\_finishing**(gauge)    | The number of workers finishing their request.*Shown as thread*                                                                       |
| **apache.scoreboard.idle\_cleanup**(gauge)            | These workers were idle and their process is being stopped.*Shown as thread*                                                          |
| **apache.scoreboard.keepalive**(gauge)                | The workers intended for a new request from the same client, because it asked to keep the connection alive.*Shown as thread*          |
| **apache.scoreboard.logging**(gauge)                  | The workers writing something to the Apache logs.*Shown as thread*                                                                    |
| **apache.scoreboard.open\_slot**(gauge)               | The amount of workers that Apache can still start before hitting the maximum number of workers.*Shown as thread*                      |
| **apache.scoreboard.reading\_request**(gauge)         | The workers reading the incoming request.*Shown as thread*                                                                            |
| **apache.scoreboard.sending\_reply**(gauge)           | The number of workers sending a reply/response or waiting on a script (like PHP) to finish so they can send a reply.*Shown as thread* |
| **apache.scoreboard.starting\_up**(gauge)             | The workers that are still starting up and not yet able to handle a request.*Shown as thread*                                         |
| **apache.scoreboard.waiting\_for\_connection**(gauge) | The number of workers that can immediately process an incoming request.*Shown as thread*                                              |

### Events{% #events %}

The Apache check does not include any events.

### Service Checks{% #service-checks %}

**apache.can\_connect**

Returns `CRITICAL` if the Agent is unable to connect to the monitored Apache instance. Returns `OK` otherwise.

*Statuses: ok, critical*

## Troubleshooting{% #troubleshooting %}

### Apache status URL{% #apache-status-url %}

If you are having issues with your Apache integration, it is mostly like due to the Agent not being able to access your Apache status URL. Try running curl for the `apache_status_url` listed in [your `apache.d/conf.yaml` file](https://github.com/DataDog/integrations-core/blob/master/apache/datadog_checks/apache/data/conf.yaml.example) (include your login credentials if applicable).

- [Apache SSL certificate issues](https://docs.datadoghq.com/integrations/faq/apache-ssl-certificate-issues.md)

## Further Reading{% #further-reading %}

- [Monitoring Apache web server performance](https://www.datadoghq.com/blog/monitoring-apache-web-server-performance)
- [How to collect Apache performance metrics](https://www.datadoghq.com/blog/collect-apache-performance-metrics)
- [How to monitor Apache web server with Datadog](https://www.datadoghq.com/blog/monitor-apache-web-server-datadog)
