Custom Alarms
📋 Table of Contents
- Overview
- Custom Metrics
- Custom Alarms
- Anomaly Detection
- Best Practices
- Examples from Our Infrastructure
🌟 Overview
This document provides detailed information about custom alarms and metrics in CloudWatch, which are crucial for monitoring aspects of our infrastructure not covered by default AWS metrics.
Note: Custom metrics and alarms allow us to tailor our monitoring strategy to our specific needs, but they require careful management to avoid unnecessary costs and complexity.
📊 Custom Metrics
Custom metrics allow us to track data points specific to our application or infrastructure that are not provided by default AWS metrics.
Key Concepts
- Namespace: A container for CloudWatch metrics. Use a unique namespace for your custom metrics.
- Metric Name: The name of your metric (e.g.,
DatabaseConnections). - Dimensions: Key-value pairs that further identify your metric (e.g.,
{Service: "UserAPI", Environment: "Production"}).
Publishing Custom Metrics
Use the PutMetricData API call or AWS SDKs to publish custom metrics. Here's a basic example using AWS CLI:
aws cloudwatch put-metric-data --namespace "MyApplication" --metric-name "DatabaseConnections" --value 42 --dimensions Service=UserAPI,Environment=Production
Important: Be mindful of costs when publishing custom metrics. Each unique combination of namespace, metric name, and dimension is billed separately.