question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cloudwatch.Metric.put_data() docs inaccurate or incomplete?

See original GitHub issue

I was looking at how to use the Metric resource in the cloudwatch namespace, and I was surprised to see that its put_data method doesn’t accept any arguments, according to the docs. I expect that this is a mistake, since the seemingly analogous put_metric_data client method does mention parameters in its docs. In fact, the two functions’ docstrings are identical, except that put_metric_data has **kwargs in its signature, and the example request reflects the required parameters.

I’m about to test this out, so I guess I’ll find out if I understand this right. 😃 Unfortunately, since boto3 is very meta-programmed, it’s very difficult for me to figure out how to call this function simply by looking at the source code.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:16
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
choughton85commented, Jan 7, 2019

@brettdh, @boolafish, and @joguSD Here’s a code snippet I used:

import boto3
import datetime

cloudwatch = boto3.resource('cloudwatch')
metric = cloudwatch.Metric('Namespace', 'MetricName')
metric.put_data(
    Namespace=metric.namespace,
    MetricData=[
        {
            'MetricName': metric.metric_name,
            'Timestamp': datetime.datetime.utcnow(),
            'Value': 1,
            'Unit': 'None',
            'Dimensions': [
                {'Name': 'Environment',
                 'Value': 'dev'
                 }
            ]
        }
    ]
)

I think it pulls most of the structure directly from the API docs: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricData.html

2reactions
swetashrecommented, Nov 13, 2019

@choughton85 - Yes you are right. It pulls most of the structure directly from API docs. Boto3 resource documentation is definitely lacking all these parameter. We should update our documentation.

I would mark this as documentation and see what can i do to update the documentation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PutMetricData - Amazon CloudWatch - AWS Documentation
Publishes metric data points to Amazon CloudWatch. CloudWatch associates the data points with the specified metric. If the specified metric does not exist, ......
Read more >
class CloudWatch. Client - Boto3 Docs 1.26.34 documentation
Amazon CloudWatch monitors your Amazon Web Services (Amazon Web Services) resources and ... For all other expressions and metrics, set ReturnData to false...
Read more >
Put data into a CloudWatch metric using an Amazon SDK
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, ...
Read more >
@aws-cdk/aws-autoscaling-common | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >
Amazon Managed Streaming for Apache Kafka (Amazon MSK)
To put data in the my-input-stream Kinesis Data Stream, ... It integrates with other AWS services such as Amazon CloudWatch, where you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found