Memcached

Stay organized with collections Save and categorize content based on your preferences.

The Memcached integration primarily collects cache-usage metrics, such as the number of items in a cache, the number of evictions, and the number of bytes stored. It also collects general performance metrics for CPU usage and network throughput.

For more information about Memcached, see the Memcached documentation.

Prerequisites

To collect Memcached telemetry, you must install the Ops Agent:

  • For metrics, install version 2.8.0 or higher.
  • For logs, install version 2.15.0 or higher.

This integration supports Memcached version 1.6.

Configure the Ops Agent for Memcached

Following the guide for Configuring the Ops Agent, add the required elements to collect telemetry from Memcached instances, and restart the agent.

Example configuration

The following command creates the configuration to collect and ingest telemetry for Memcached and restarts the Ops Agent.

set -e

# Create a back up of the existing file so existing configurations are not lost.
sudo cp /etc/google-cloud-ops-agent/config.yaml /etc/google-cloud-ops-agent/config.yaml.bak

# Configure the Ops Agent.
sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF
metrics:
  receivers:
    memcached:
      type: memcached
  service:
    pipelines:
      memcached:
        receivers:
          - memcached
EOF

sudo service google-cloud-ops-agent restart
sleep 60

Collect logs

Memcached writes logs to syslog, which is captured by the Ops Agent by default. No additional user configuration is required.

Configure metrics collection

To ingest metrics from Memcached, you must create receivers for the metrics that Memcached produces and then create a pipeline for the new receivers.

To configure a receiver for your memcached metrics, specify the following fields:

Field Default Description
collection_interval 60s A time duration value, such as 30s or 5m.
endpoint localhost:3306 The URL, or Unix socket file path, for your Memcached server.
type This value must be memcached.

What is monitored

The following table provides the list of metrics that the Ops Agent collects from the Memcached instance.

Metric type 
Kind, Type
Monitored resources
Labels
workload.googleapis.com/memcached.bytes
GAUGEINT64
gce_instance
 
workload.googleapis.com/memcached.commands
CUMULATIVEINT64
gce_instance
command
workload.googleapis.com/memcached.connections.current
GAUGEINT64
gce_instance
 
workload.googleapis.com/memcached.connections.total
CUMULATIVEINT64
gce_instance
 
workload.googleapis.com/memcached.cpu.usage
CUMULATIVEDOUBLE
gce_instance
state
workload.googleapis.com/memcached.current_items
GAUGEINT64
gce_instance
 
workload.googleapis.com/memcached.evictions
CUMULATIVEINT64
gce_instance
 
workload.googleapis.com/memcached.network
CUMULATIVEINT64
gce_instance
direction
workload.googleapis.com/memcached.operations
CUMULATIVEINT64
gce_instance
operation
type
workload.googleapis.com/memcached.threads
GAUGEINT64
gce_instance
 

Sample dashboard

To view your Memcached metrics, you must have a chart or dashboard configured. Cloud Monitoring provides a library of sample dashboards for integrations, which contain preconfigured charts. For information about installing these dashboards, see Installing sample dashboards.

Verify the configuration

This section describes how to verify that you correctly configured the Memcached receiver. It might take one or two minutes for the Ops Agent to begin collecting telemetry.

To verify that the logs are ingested, go to the Logs Explorer and run the following query to view the Memcached logs:

resource.type="gce_instance"
log_id("syslog")
jsonPayload.message~='(systemd-memcached-wrapper|memcached)(\[[0-9]+\])*:'

To verify that the metrics are ingested, go to Metrics Explorer and run the following query in the MQL tab:

fetch gce_instance
| metric 'workload.googleapis.com/memcached.bytes'
| every 1m

What's next

For a walkthrough on how to use Ansible to install the Ops Agent, configure a third-party application, and install a sample dashboard, see the Install the Ops Agent to troubleshoot third-party applications video.