1 Answer
- Newest
- Most votes
- Most comments
1
The CloudWatch metric math enables you to query multiple CloudWatch metrics and use math expressions to create new time series based on these metrics. However, these expressions do not support a feature to limit the time range or set up a window within a day such as from 8am to 8pm.
If you need this level of granular filtering, you might have to export your metrics to another service that provides more advanced analysis capabilities or use an AWS SDK or CLI to programmatically retrieve the metric data and then filter and analyze it in your own application or script.
For example
import boto3
client = boto3.client('cloudwatch')
response = client.get_metric_data(
MetricDataQueries=[
{
'Id': 'm1',
'MetricStat': {
'Metric': {
'Namespace': 'AWS/Route53',
'MetricName': 'HealthCheckPercentageHealthy',
'Dimensions': [
{
'Name': 'HealthCheckId',
'Value': 'your_healthcheck_id'
},
]
},
'Period': 300,
'Stat': 'Average',
},
'ReturnData': True,
},
],
StartTime='2023-04-01T00:00:00Z',
EndTime='2023-05-01T00:00:00Z',
)
Relevant content
- Accepted Answerasked 2 years ago
- Accepted Answerasked a year ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago