Memcached

Memcached is an in-memory key-value store for small chunks of arbitrary data, such as strings and objects, from the results of database calls, API calls, or page rendering.

For more information visit memcached.org.

Prerequisites

To collect and ingest Memcached logs and metrics, you must install Ops Agent version 2.8.0 or higher.

Configure the Ops Agent for Memcached

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

Example configuration

The following command creates the configuration file to collect and ingest logs and metrics for Memcached and restarts the Ops Agent on Linux.

sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF
metrics:
  receivers:
    memcached_metrics:
      type: memcached
      collection_interval: 60s
  service:
    pipelines:
      memcached_pipeline:
        receivers:
          - memcached_metrics
EOF
sudo service google-cloud-ops-agent restart

Configure metrics collection

To collect metrics from Memcached, you must create a receiver for Memcached metrics and then create a pipeline for the new receiver. To configure a receiver for your Memcached metrics, specify the following fields:

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

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.current_connections
GAUGEINT64
gce_instance
 
workload.googleapis.com/memcached.current_items
GAUGEDOUBLE
gce_instance
 
workload.googleapis.com/memcached.evictions
CUMULATIVEINT64
gce_instance
 
workload.googleapis.com/memcached.network
CUMULATIVEINT64
gce_instance
direction
workload.googleapis.com/memcached.operation_hit_ratio
GAUGEDOUBLE
gce_instance
operation
workload.googleapis.com/memcached.operations
CUMULATIVEINT64
gce_instance
operation
type
workload.googleapis.com/memcached.rusage
CUMULATIVEDOUBLE
gce_instance
state
workload.googleapis.com/memcached.threads
GAUGEDOUBLE
gce_instance
 
workload.googleapis.com/memcached.total_connections
CUMULATIVEINT64
gce_instance
 

Collect logs

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

Verify the ingestion

To verify the logs are ingested, go to the Logs Explorer and run the following query to view the Memcached logs (Replace systemd-memcached-wrapper with your system unit name for Memcached if needed):

resource.type="gce_instance"
logName="projects/PROJECT_ID/logs/syslog"
systemd-memcached-wrapper

You can use the Metrics Explorer to verify that you correctly configured the Memcached receiver. It might take one or two minutes for the Ops agent to begin collecting metrics.


To verify 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.commands'
| align rate(1m)
| 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.