Memcached - OpenTelemetry Collector
The Memcached app is a logs-based app that helps you monitor the availability, performance, health, and resource utilization of your Memcached clusters. Preconfigured dashboards provide insight into operational metrics, cache performance, resource utilization, errors, warnings, and commands executed.
The Sumo Logic app for Memcached is tested for Version: 1.4.15.
Memcached logs are sent to Sumo Logic through the OpenTelemetry filelog receiver. Memcached metrics are sent through the Memcached metrics receiver.
This app includes built-in monitors. For details on creating custom monitors, refer to the Create monitors for Memcached app.
Fields creation in Sumo Logic for Memcached
Following are the Fields which will be created as part of Memcached App install if not already present.
sumo.datasource
. Has a fixed value of memcached.db.system
. Has a fixed value of memcached.deployment.environment
. User configured. This is the deployment environment where the Memcache cluster resides. For example: dev, prod, or qa.db.cluster.name
. User configured. Enter a name to identify this Memcached cluster. This cluster name will be shown in the Sumo Logic dashboards.db.node.name
. This has value of the FQDN of the machine where OpenTelemetry collector is collecting logs and metrics from.
Prerequisites
- Configure logging in Memcached: By default, the installation of Memcached will not write any request logs to disk. To add a log file for Memcached, you can use the following syntax:
memcached -d -m 3072 -l localhost -p 11211 -u nobody -v 2>>/var/log/memcached/memcached.log
- Or, if you're on RHEL/CentOS, you can edit the file
/etc/sysconfig/memcached
like so:PORT="11211"
USER="memcached"
MAXCONN="3048"
CACHESIZE="256"
OPTIONS="-vv >> /var/log/memcached/memcached.log 2>&1" - Save the file and restart Memcached.
For Linux systems with ACL Support, the otelcol install process should have created the ACL grants necessary for the otelcol system user to access default log locations. You can verify the active ACL grants using the getfacl
command. Install the ACL in your Linux environment, if not installed.
The required ACL may not be supported for some rare cases, for example, Linux OS Distro, which is officially not supported by Sumo Logic. In this case, you can run the following command to explicitly grant the permissions.
sudo setfacl -R -m d:u:otelcol-sumo:r-x,d:g:otelcol-sumo:r-x,u:otelcol-sumo:r-x,g:otelcol-sumo:r-x <PATH_TO_LOG_FILE>
Run the above command for all the log files in the directory that need to be ingested, which are not residing in the default location.
If Linux ACL Support is not available, traditional Unix-styled user and group permission must be modified. It should be sufficient to add the otelcol system user to the specific group that has access to the log files.
For Windows systems, log files which are collected should be accessible by the SYSTEM group. Use the following set of PowerShell commands if the SYSTEM group does not have access.
$NewAcl = Get-Acl -Path "<PATH_TO_LOG_FILE>"
# Set properties
$identity = "NT AUTHORITY\SYSTEM"
$fileSystemRights = "ReadAndExecute"
$type = "Allow"
# Create new rule
$fileSystemAccessRuleArgumentList = $identity, $fileSystemRights, $type
$fileSystemAccessRule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $fileSystemAccessRuleArgumentList
# Apply new rule
$NewAcl.SetAccessRule($fileSystemAccessRule)
Set-Acl -Path "<PATH_TO_LOG_FILE>" -AclObject $NewAcl
Collection configuration and app installation
As part of data collection setup and app installation, you can select the App from App Catalog and click on Install App. Follow the steps below.
Step 1: Set up Collector
If you want to use an existing OpenTelemetry Collector, you can skip this step by selecting the Use an existing Collector option.
To create a new Collector:
- Select the Add a new Collector option.
- Select the platform where you want to install the Sumo Logic OpenTelemetry Collector.
This will generate a command that you can execute in the machine environment you need to monitor. Once executed, it will install the Sumo Logic OpenTelemetry Collector.
Step 2: Configure integration
In this step, you will configure the yaml file required for Memcached Collection. Path of the log file configured to capture Memcached logs needs to be given here.
The files are typically located in /var/log/memcached/memcached.log
. If you're using a customized path, check the respective conf file (default location: /etc/memcached.conf
) for this information.
For metrics, you're required to provide the Memcached endpoint (default is localhost:11211) along with the collection_interval
(default is 1 minute).
You can add any custom fields which you want to tag along with the data ingested in Sumo. Click on the Download YAML File button to get the yaml file.
Step 3: Send logs to Sumo Logic
Once you have downloaded the YAML file as described in the previous step, follow the below steps based on your platform.
- Linux
- Windows
- macOS
- Chef
- Ansible
- Puppet
- Copy the yaml file to
/etc/otelcol-sumo/conf.d/
folder in the Memcache instance which needs to be monitored. - Restart the collector using:
sudo systemctl restart otelcol-sumo
- Copy the yaml file to
C:\ProgramData\Sumo Logic\OpenTelemetry Collector\config\conf.d
folder in the machine which needs to be monitored. - Restart the collector using:
Restart-Service -Name OtelcolSumo
- Copy the yaml file to
/etc/otelcol-sumo/conf.d/
folder in the Memcache instance which needs to be monitored. - Restart the otelcol-sumo process using:
otelcol-sumo --config /etc/otelcol-sumo/sumologic.yaml --config "glob:/etc/otelcol-sumo/conf.d/*.yaml"
- Copy the yaml file into your Chef cookbook files directory
files/<downloaded_yaml_file>
. - Use a Chef file resource in a recipe to manage it.
cookbook_file '/etc/otelcol-sumo/conf.d/<downloaded_yaml_file>' do mode 0644 notifies :restart, 'service[otelcol-sumo]', :delayed end
- Add the recipe to your collector setup to start collecting the data. Every team typically has their established way of applying the Chef recipe. The resulting Chef recipe should look something like:
cookbook_file '/etc/otelcol-sumo/conf.d/<downloaded_yaml_file>' do
mode 0644
notifies :restart, 'service[otelcol-sumo]', :delayed
end
- Place the file into your Ansible playbook files directory.
- Run the Ansible playbook.
ansible-playbook -i inventory install_sumologic_otel_collector.yaml
-e '{"installation_token": "<YOUR_TOKEN>", "collector_tags": {<YOUR_TAGS>}, "src_config_path": "files/conf.d"}'
- Place the file into your Puppet module files directory
modules/install_otel_collector/files/<downloaded_yaml>
. - Use a Puppet file resource to manage it.
file { '/etc/otelcol-sumo/conf.d/<downloaded_yaml_file>':
ensure => present,
source => 'puppet:///modules/install_otel_collector/<downloaded_yaml_file>',
mode => '0644',
notify => Service[otelcol-sumo],
} - Apply the Puppet manifest. Every team typically has their established way of applying the Puppet manifest. The resulting Puppet manifest should look something like:
node 'default' {
class { 'install_otel_collector'
installation_token => '<YOUR_TOKEN>',
collector_tags => { <YOUR_TAGS> },
}
service { 'otelcol-sumo':
provider => 'systemd',
ensure => running,
enable => true,
require => Class['install_otel_collector'],
}
file { '/etc/otelcol-sumo/conf.d/<downloaded_yaml_file>':
ensure => present,
source => 'puppet:///modules/install_otel_collector/<downloaded_yaml_file>',
mode => '0644',
notify => Service[otelcol-sumo],
}
}
After successfully executing the above command, Sumo Logic will start receiving data from your host machine.
Click Next. This will install the app (dashboards and monitors) to your Sumo Logic Org.
Dashboard panels will start to fill automatically. It's important to note that each panel fills with data matching the time range query and received since the panel was created. Results won't immediately be available, but within 20 minutes, you'll see full graphs and maps.
Sample log messages
Jun 23 07:35:01 node03 memcached: \
<31 set GFcIh47CswfCnwk3JkmJ 0 0 4096
Sample metric messages
{
"queryId": "A",
"_source": "memcached-otel",
"_metricId": "lU4jhUa6YoiLX9eJZGHHjA",
"_sourceName": "Http Input",
"host.id": "i-0cc7753247bad73ae",
"host.group": "memcachedlinux",
"os.type": "linux",
"sumo.datasource": "memcached",
"db.system": "memcached",
"command": "touch",
"db.node.name": "ip-172-31-64-180.ec2.internal",
"_sourceCategory": "Labs/memcached-otel",
"deployment.environment": "memcachedlinux",
"_contentType": "Carbon2",
"host.name": "ip-172-31-64-180.ec2.internal",
"metric": "memcached.commands",
"_collectorId": "000000000F90B095",
"_sourceId": "00000000594E7C3A",
"unit": "{commands}",
"db.cluster.name": "test",
"_collector": "Labs - memcached-otel",
"max": 10,
"min": 0,
"avg": 7,
"sum": 70,
"latest": 10,
"count": 10
}
Sample logs queries
Following is the query from Errors panel of Memcached app's overview Dashboard:
%"deployment.environment"=* %"db.cluster.name"=* %"sumo.datasource"=memcached memcached ">" ERROR | json "log" as _rawlog nodrop
| if (isEmpty(_rawlog), _raw, _rawlog) as memcached_log_message
| parse regex field=memcached_log_message ">(?<pid>\d+) (?<cmd>\w+)"
| if(cmd matches "ERROR",1,0) as ERROR
| timeslice by 1h
| sum(ERROR) as ERROR by _timeslice
Sample metrics queries
sumo.datasource=memcached deployment.environment=* db.cluster.name=* db.node.name=* metric=memcached.commands command=get | sum
Viewing the Memcached dashboards
Overview
The Memcached - Overview dashboard provides an at-a-glance view of the Memcached server status, error logs, and database metrics.
Operations
The Memcached - Operations Dashboard provides detailed analysis on connections, thread requested, network bytes, and table size.
Command Stats
The Memcached - Command Stats dashboard provides detailed insights into the number of commands being performed.
Cache Information
The Memcached - Cache Information dashboard provides insight into cache states, cache hit, and miss rate over time.
Logs
The Memcached - Logs dashboard helps you quickly analyze your Memcached error logs, commands executed, and objects stored.
Create monitors for Memcached app
From your App Catalog:
- From the Sumo Logic navigation, select App Catalog.
- In the Search Apps field, search for and then select your app.
- Make sure the app is installed.
- Navigate to What's Included tab and scroll down to the Monitors section.
- Click Create next to the pre-configured monitors. In the create monitors window, adjust the trigger conditions and notifications settings based on your requirements.
- Scroll down to Monitor Details.
- Under Location click on New Folder.
note
By default, monitor will be saved in the root folder. So to make the maintenance easier, create a new folder in the location of your choice.
- Enter Folder Name. Folder Description is optional.
tip
Using app version in the folder name will be helpful to determine the versioning for future updates.
- Click Create. Once the folder is created, click on Save.
Memcached alerts
Name | Description | Alert Condition | Recover Condition |
---|---|---|---|
Memcached - Cache Hit Ratio | This alert is triggered when low cache hit ratio is less than 50%. The hit rate is one of the most important indicators of Memcached performance. A high hit rate means faster responses to your users. If the hit rate is falling, you need quick visibility into why. | Count < = 50% | Count > 50% |
Memcached - Commands Error | This alert is triggered when Memcached has error commands. | Count > 0 | Count < = 0 |
Memcached - Current Connections | This alert is triggered when current connections to Memcached are zero. | Count < = 0 | Count > 0 |
Memcached - High Memory Usage | This alert is triggered when the Memcached exceed given threshold memory usage (in GB). | Count > 5 | Count < = 5 |
Memcached - High Number of Connections | This alert is triggered when the number of current connection for Memcached exceed given threshold. | Count > = 1000 | Count < 1000 |