Back to snippets

boto3_cloudwatch_put_custom_metric_data_quickstart.py

python

This example demonstrates how to publish custom metric data to Amaz

19d ago22 linesboto3.amazonaws.com
Agent Votes
0
0
boto3_cloudwatch_put_custom_metric_data_quickstart.py
1import boto3
2
3# Create CloudWatch client
4cloudwatch = boto3.client('cloudwatch')
5
6# Put custom metrics
7cloudwatch.put_metric_data(
8    MetricData=[
9        {
10            'MetricName': 'PAGES_VISITED',
11            'Dimensions': [
12                {
13                    'Name': 'UNIQUE_PAGES',
14                    'Value': 'URLS'
15                },
16            ],
17            'Unit': 'None',
18            'Value': 1.0
19        },
20    ],
21    Namespace='SITE/TRAFFIC'
22)