---
title: Memcache
description: Track memory use, hits, misses, evictions, fill percent, and more.
breadcrumbs: Docs > Integrations > Memcache
---

# Memcache
Supported OS Integration version6.4.0
## Overview{% #overview %}

The Agent's Memcache check lets you track Memcache's memory use, hits, misses, evictions, fill percent, and much more.

**Minimum Agent version:** 6.0.0

## Setup{% #setup %}

### Installation{% #installation %}

The Memcache check is included in the [Datadog Agent](https://app.datadoghq.com/account/settings/agent/latest) package, so you don't need to install anything else on your Memcache servers.

### Configuration{% #configuration %}

Follow the instructions below to configure this check for an Agent running on a host. For containerized environments, see the Containerized section

When launching the Memcache server, set the binding protocol `-B` to `binary` or `auto`. Automatic (auto) is the default.

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

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

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

1. Edit the `mcache.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/#agent-configuration-directory). See the [sample mcache.d/conf.yaml](https://github.com/DataDog/integrations-core/blob/master/mcache/datadog_checks/mcache/data/conf.yaml.example) for all available configuration options:

   ```yaml
   init_config:
   
   instances:
     ## @param url - string - required
     ## url used to connect to the Memcached instance.
     #
     - url: localhost
   ```

1. [Restart the Agent](https://docs.datadoghq.com/agent/guide/agent-commands/#start-stop-and-restart-the-agent) to begin sending Memcache metrics to Datadog.

##### Trace collection{% #trace-collection %}

Datadog APM integrates with Memcache to see the traces across your distributed system. Trace collection is enabled by default in the Datadog Agent v6+. To start collecting traces:

1. [Enable trace collection in Datadog](https://docs.datadoghq.com/tracing/send_traces/).
1. [Instrument your application that makes requests to Memcache](https://docs.datadoghq.com/tracing/setup/).

{% /tab %}

{% tab title="Containerized" %}
#### Containerized{% #containerized %}

For containerized environments, see the [Autodiscovery Integration Templates](https://docs.datadoghq.com/agent/kubernetes/integrations/) for guidance on applying the parameters below.

| Parameter            | Value                                 |
| -------------------- | ------------------------------------- |
| `<INTEGRATION_NAME>` | `mcache`                              |
| `<INIT_CONFIG>`      | blank or `{}`                         |
| `<INSTANCE_CONFIG>`  | `{"url": "%%host%%","port": "11211"}` |

##### Trace collection{% #trace-collection %}

APM for containerized apps is supported on hosts running Agent v6+ but requires extra configuration to begin collecting traces.

Required environment variables on the Agent container:

| Parameter                    | Value     |
| ---------------------------- | --------- |
| `<DD_API_KEY>`               | `api_key` |
| `<DD_APM_ENABLED>`           | true      |
| `<DD_APM_NON_LOCAL_TRAFFIC>` | true      |

See [Tracing Kubernetes Applications](https://docs.datadoghq.com/agent/kubernetes/apm/?tab=java) and the [Kubernetes Daemon Setup](https://docs.datadoghq.com/agent/kubernetes/daemonset_setup/?tab=k8sfile#apm-and-distributed-tracing) for a complete list of available environment variables and configuration.

Then, [instrument your application container](https://docs.datadoghq.com/tracing/setup/) and set `DD_AGENT_HOST` to the name of your Agent container.

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

*Available for Agent versions >6.0*

1. Add this configuration block to your `mcache.d/conf.yaml` file to start collecting your Memcached Logs:

   ```yaml
   logs:
     - type: file
       path: /var/log/memcached.log
       source: memcached
       service: mcache
   ```

Change the `path` and `service` parameter values and configure them for your environment.

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

{% /tab %}

### Validation{% #validation %}

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

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

### Metrics{% #metrics %}

|  |
|  |
| **memcache.avg\_item\_size**(gauge)                | The average size of an item.*Shown as byte*                                                                                         |
| **memcache.bytes**(gauge)                          | Current number of bytes used by this server to store items.*Shown as byte*                                                          |
| **memcache.bytes\_read\_rate**(gauge)              | Rate of bytes read from the network by this server.*Shown as byte*                                                                  |
| **memcache.bytes\_written\_rate**(gauge)           | Rate of bytes written to the network by this server.*Shown as byte*                                                                 |
| **memcache.cas\_badval\_rate**(gauge)              | Rate at which keys are compared and swapped where the comparison (original) value did not match the supplied value.*Shown as key*   |
| **memcache.cas\_hits\_rate**(gauge)                | Rate at which keys are compared and swapped and found present.*Shown as hit*                                                        |
| **memcache.cas\_misses\_rate**(gauge)              | Rate at which keys are compared and swapped and not found present.*Shown as miss*                                                   |
| **memcache.cmd\_flush\_rate**(gauge)               | Rate of "flush_all" commands.*Shown as command*                                                                                     |
| **memcache.cmd\_get\_rate**(gauge)                 | Rate of "get" commands.*Shown as command*                                                                                           |
| **memcache.cmd\_set\_rate**(gauge)                 | Rate of "set" commands.*Shown as command*                                                                                           |
| **memcache.connection\_structures**(gauge)         | Number of connection structures allocated by the server.                                                                            |
| **memcache.curr\_connections**(gauge)              | Number of open connections to this server.*Shown as connection*                                                                     |
| **memcache.curr\_items**(gauge)                    | Current number of items stored by the server.*Shown as item*                                                                        |
| **memcache.delete\_hits\_rate**(gauge)             | Rate at which delete commands result in items being removed.*Shown as hit*                                                          |
| **memcache.delete\_misses\_rate**(gauge)           | Rate at which delete commands result in no items being removed.*Shown as miss*                                                      |
| **memcache.evictions\_rate**(gauge)                | Rate at which valid items are removed from cache to free memory for new items.*Shown as eviction*                                   |
| **memcache.fill\_percent**(gauge)                  | Amount of memory being used by the server for storing items as a percentage of the max allowed.*Shown as percent*                   |
| **memcache.get\_hit\_percent**(gauge)              | Percentage of requested keys that are found present since the start of the memcache server.*Shown as percent*                       |
| **memcache.get\_hits\_rate**(gauge)                | Rate at which keys are requested and found present.*Shown as hit*                                                                   |
| **memcache.get\_misses\_rate**(gauge)              | Rate at which keys are requested and not found.*Shown as miss*                                                                      |
| **memcache.items.age**(gauge)                      | Age of the oldest item in the LRU*Shown as second*                                                                                  |
| **memcache.items.crawler\_reclaimed\_rate**(gauge) | Rate at which items freed by the LRU Crawler*Shown as operation*                                                                    |
| **memcache.items.direct\_reclaims\_rate**(gauge)   | Rate at which worker threads had to directly pull LRU tails to find memory for a new item*Shown as operation*                       |
| **memcache.items.evicted\_nonzero\_rate**(gauge)   | Rate at which nonzero items which had an explicit expire time set had to be evicted from the LRU before expiring*Shown as eviction* |
| **memcache.items.evicted\_rate**(gauge)            | Rate at which items had to be evicted from the LRU before expiring*Shown as eviction*                                               |
| **memcache.items.evicted\_time**(gauge)            | Seconds since the last access for the most recent item evicted from this class*Shown as second*                                     |
| **memcache.items.evicted\_unfetched\_rate**(gauge) | Rate at which valid items evicted from the LRU which were never touched after being set*Shown as eviction*                          |
| **memcache.items.expired\_unfetched\_rate**(gauge) | Rate at which expired items reclaimed from the LRU which were never touched after being set*Shown as eviction*                      |
| **memcache.items.lrutail\_reflocked\_rate**(gauge) | Rate at which items found to be refcount locked in the LRU tail*Shown as item*                                                      |
| **memcache.items.moves\_to\_cold\_rate**(gauge)    | Rate at which items were moved from HOT or WARM into COLD*Shown as item*                                                            |
| **memcache.items.moves\_to\_warm\_rate**(gauge)    | Rate at which items were moved from COLD to WARM*Shown as item*                                                                     |
| **memcache.items.moves\_within\_lru\_rate**(gauge) | Rate at which active items were bumped within HOT or WARM*Shown as item*                                                            |
| **memcache.items.number**(gauge)                   | Number of items presently stored in this slab class*Shown as item*                                                                  |
| **memcache.items.number\_cold**(gauge)             | Number of items presently stored in the COLD LRU*Shown as item*                                                                     |
| **memcache.items.number\_hot**(gauge)              | Number of items presently stored in the HOT LRU*Shown as item*                                                                      |
| **memcache.items.number\_noexp**(gauge)            | Number of items presently stored in the NOEXP class*Shown as item*                                                                  |
| **memcache.items.number\_warm**(gauge)             | Number of items presently stored in the WARM LRU*Shown as item*                                                                     |
| **memcache.items.outofmemory\_rate**(gauge)        | Rate at which the underlying slab class was unable to store a new item*Shown as error*                                              |
| **memcache.items.reclaimed\_rate**(gauge)          | Rate at which entries were stored using memory from an expired entry*Shown as operation*                                            |
| **memcache.items.tailrepairs\_rate**(gauge)        | Rate at which memcache self-healed a slab with a refcount leak*Shown as operation*                                                  |
| **memcache.limit\_maxbytes**(gauge)                | Number of bytes this server is allowed to use for storage.*Shown as byte*                                                           |
| **memcache.listen\_disabled\_num\_rate**(gauge)    | Rate at which the server has reached the max connection limit.*Shown as event*                                                      |
| **memcache.max\_connections**(gauge)               | Maximum number of connections to this server.*Shown as connection*                                                                  |
| **memcache.pointer\_size**(gauge)                  | Default size of pointers on the host OS (generally 32 or 64)*Shown as bit*                                                          |
| **memcache.rusage\_system\_rate**(gauge)           | Fraction of time the CPU spent executing kernel code on behalf of this server process.*Shown as fraction*                           |
| **memcache.rusage\_user\_rate**(gauge)             | Fraction of user time the CPU spent executing this server process.*Shown as fraction*                                               |
| **memcache.slabs.active\_slabs**(gauge)            | Total number of slab classes allocated*Shown as occurrence*                                                                         |
| **memcache.slabs.cas\_badval\_rate**(gauge)        | Rate at which CAS commands failed to modify a value due to a bad CAS id*Shown as key*                                               |
| **memcache.slabs.cas\_hits\_rate**(gauge)          | Rate at which CAS commands modified this slab class*Shown as operation*                                                             |
| **memcache.slabs.chunk\_size**(gauge)              | The amount of space each chunk uses*Shown as byte*                                                                                  |
| **memcache.slabs.chunks\_per\_page**(gauge)        | How many chunks exist within one page*Shown as buffer*                                                                              |
| **memcache.slabs.cmd\_set\_rate**(gauge)           | Rate at which set requests stored data in this slab class*Shown as command*                                                         |
| **memcache.slabs.decr\_hits\_rate**(gauge)         | Rate at which decrs commands modified this slab class*Shown as operation*                                                           |
| **memcache.slabs.delete\_hits\_rate**(gauge)       | Rate at which delete commands succeeded in this slab class*Shown as operation*                                                      |
| **memcache.slabs.free\_chunks**(gauge)             | Chunks not yet allocated to items or freed via delete*Shown as buffer*                                                              |
| **memcache.slabs.free\_chunks\_end**(gauge)        | Number of free chunks at the end of the last allocated page*Shown as buffer*                                                        |
| **memcache.slabs.get\_hits\_rate**(gauge)          | Rate at which get requests were serviced by this slab class*Shown as hit*                                                           |
| **memcache.slabs.incr\_hits\_rate**(gauge)         | Rate at which incrs commands modified this slab class*Shown as operation*                                                           |
| **memcache.slabs.mem\_requested**(gauge)           | Number of bytes requested to be stored in this slab*Shown as byte*                                                                  |
| **memcache.slabs.total\_chunks**(gauge)            | Total number of chunks allocated to the slab class*Shown as buffer*                                                                 |
| **memcache.slabs.total\_malloced**(gauge)          | Total amount of memory allocated to slab pages*Shown as byte*                                                                       |
| **memcache.slabs.total\_pages**(gauge)             | Total number of pages allocated to the slab class*Shown as page*                                                                    |
| **memcache.slabs.touch\_hits\_rate**(gauge)        | Rate of touches serviced by this slab class*Shown as operation*                                                                     |
| **memcache.slabs.used\_chunks**(gauge)             | How many chunks have been allocated to items*Shown as buffer*                                                                       |
| **memcache.slabs.used\_chunks\_rate**(gauge)       | Rate at which chunks have been allocated to items*Shown as buffer*                                                                  |
| **memcache.threads**(gauge)                        | Number of threads used by the current Memcached server process.*Shown as thread*                                                    |
| **memcache.total\_connections\_rate**(gauge)       | Rate at which connections to this server are opened.*Shown as connection*                                                           |
| **memcache.total\_items**(gauge)                   | Total number of items stored by this server since it started.*Shown as item*                                                        |
| **memcache.uptime**(gauge)                         | Number of seconds this server has been running.*Shown as second*                                                                    |

The check only collects `memcache.slabs.*` metrics if you set `options.slabs: true` in `mcache.d/conf.yaml`. Likewise, it only collects `memcache.items.*` metrics if you set `options.items: true`.

### Events{% #events %}

The Mcache check does not include any events.

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

**memcache.can\_connect**

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

*Statuses: ok, critical*

## Troubleshooting{% #troubleshooting %}

Need help? Contact [Datadog support](https://docs.datadoghq.com/help/).

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

- [Speed up web applications with Memcached monitoring](https://www.datadoghq.com/blog/speed-up-web-applications-memcached)
- [Instrument Memcached performance metrics with DogStatsD](https://www.datadoghq.com/blog/instrument-memcached-performance-metrics-dogstatsd)
- [Monitoring ElastiCache performance metrics](https://www.datadoghq.com/blog/monitoring-elasticache-performance-metrics-with-redis-or-memcached)
