Skip to content

Commit d02e40f

Browse files
committed
feat: Add blog post for elasticache-slowlog-to-datadog
1 parent 0853738 commit d02e40f

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
layout: post
3+
title: "Sending Elasticache slowlog metrics to Datadog"
4+
authors:
5+
- jimp
6+
tags:
7+
- terraform
8+
- monitoring
9+
team: Core Infrastructure
10+
---
11+
12+
13+
# Sending Elasticache slowlog metrics to Datadog
14+
15+
We’ve recently migrated our Redis workloads to AWS Elasticache. We really like having a managed service, since we don’t have any more Redis servers to maintain. However, as with all managed services, there are some tradeoffs. One of those tradeoffs was that we no longer had access to all of [Datadog’s Redis integration’s](https://docs.datadoghq.com/integrations/redisdb/) features. Instead, we have [Datadog’s AWS Elasticache integration](https://docs.datadoghq.com/integrations/amazon_elasticache/#overview). One of the most noticeable features we saw as missing was the lack of slowlog metrics in AWS Elasticache. This metric is useful as it gives us valuable data to alert against when Redis behavior starts running afoul. There is no ability to run a Datadog agent on Elasticache’s servers, so we had to obtain the metric some other way. 
16+
17+
We decided to use AWS Lambda to periodically query our Elasticache redis instances and submit those missing slowlog metrics directly to Datadog, much as the datadog-agent integration would have otherwise.  
18+
19+
## The Lambda job
20+
21+
We wrote [https://github.com/scribd/elasticache-slowlog-to-datadog](https://github.com/scribd/elasticache-slowlog-to-datadog) to connect to an AWS Elasticache job (given by the REDIS_HOST parameter), gather its slowlogs, and submit a [HISTOGRAM](https://docs.datadoghq.com/developers/metrics/types/?tab=histogram) metric type to Datadog, consistent with Datadog’s Redis integration. 
22+
23+
The application is packaged with its required libraries as a ready-to-deploy archive in our [releases page](https://github.com/scribd/elasticache-slowlog-to-datadog/releases). To deploy directly to AWS from the console, upload the “Full zip distribution” and supply the [required parameters](https://github.com/scribd/elasticache-slowlog-to-datadog#parameters). I’d recommend using our Terraform wrapper, however.
24+
25+
## The Terraform wrapper
26+
27+
We wrote [https://github.com/scribd/terraform-elasticache-slowlog-to-datadog](https://github.com/scribd/terraform-elasticache-slowlog-to-datadog) to apply the elasticache-slowlog-to-datadog lambda job to target AWS accounts and Elasticache instances. 
28+
29+
When lambda jobs include libraries that must be vendored in, as elasticache-slowlog-to-datadog does, the existing patterns include [building locally, or uploading artifacts to S3](https://www.terraform.io/docs/providers/aws/r/lambda_function.html#specifying-the-deployment-package). However, I like the approach of maintaining a separate repository and build pipeline, as this works around Terraform’s [intentionally limited build functionality](https://github.com/hashicorp/terraform/issues/8344#issuecomment-361014199). Instead, the terraform wrapper merely [consumes the elasticache-slowlog-to-datadog artifact](https://github.com/scribd/terraform-elasticache-slowlog-to-datadog/blob/master/main.tf#L97).
30+
31+
## Usage
32+
33+
To deploy elasticache-slowlog-to-datadog via terraform, add the following to your terraform file: 
34+
35+
```
36+
module slowlog_check {
37+
  source                      = "git::https://github.com/scribd/terraform-elasticache-slowlog-to-datadog.git?ref=master"
38+
  elasticache_endpoint        = "master.replicationgroup.abcdef.use2.cache.amazonaws.com"
39+
  elasticache_security_groups = ["sg-12345"]
40+
  subnet_ids                  = [ "subnet-0123456789abcdef", "subnet-abcdef1234567890", "subnet-1234567890abcdef", ]
41+
  vpc_id                      = "vpc-0123456789abcdef"
42+
  datadog_api_key             = "abc123"
43+
  datadog_app_key             = "abc123"
44+
  namespace                   = "example"
45+
  env                         = "dev"
46+
  tags                        = {"foo" = "bar"}
47+
}
48+
```
49+
50+
## Conclusion
51+
52+
Using AWS Lambda, we can supplement the metrics we get natively from Datadog’s AWS Elasticache integration. 
53+
54+
Stay apprised of future developments by watching our release pages: 
55+
56+
- [elasticache-slowlog-to-datadog](https://github.com/scribd/elasticache-slowlog-to-datadog/releases)
57+
- [terraform-elasticache-slowlog-to-datadog](https://github.com/scribd/terraform-elasticache-slowlog-to-datadog/releases)

0 commit comments

Comments
 (0)