Just started using Boto3 with Python so definitely new at this.
I'm trying to use a simple get_metric_statistics script to return information about CPUUtilization for an instance. Here is the script I'm looking to use:
import boto3
import datetime
cw = boto3.client('cloudwatch')
cw.get_metric_statistics(
300,
datetime.datetime.utcnow() - datetime.timedelta(seconds=600),
datetime.datetime.utcnow(),
'CPUUtilization',
'AWS/EC2',
'Average',
{'InstanceId':'i-11111111111'},
)
but I keep getting the following message:
Traceback (most recent call last):
File "C:..../CloudWatch_GetMetricStatistics.py", line 13, in <module>
{'InstanceId':'i-0c996c11414476c7c'},
File "C:\Program Files\Python27\lib\site-packages\botocore\client.py", line 251, in _api_call
"%s() only accepts keyword arguments." % py_operation_name)
TypeError: get_metric_statistics() only accepts keyword arguments.
I have:
- Looked at the documentation on Boto3 and I believe I have got everything correctly written/included
- Set the correct region/output format/security credentials in the .aws folder
- Googled similar problems with put_metric_statistics, etc to try and figure it out
I'm still stuck as to what I'm missing?
Any guidance would be much appreciated.
Many thanks Ben