boto3 caught_exception botocore.exceptions.EndpointConnectio

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
sgargano
Posts: 51
Joined: Mon May 23, 2016 9:06 am

boto3 caught_exception botocore.exceptions.EndpointConnectio

Post by sgargano »

Dear all,

we have just installed boto3 as requested by the AWS Wizard.

The Wizard itself works perfectly, we were able to pass the credentials and any information requested.

But we got some error even launching manually the command:

Code: Select all

sudo ./check_ec2.py -P 5 --metricname CPUCreditBalance --instanceid 'i-xxxxxxxx' --accesskeyid 'ACCESSKEY' --secretaccesskey 'SECRETYKEY' --region 'eu-central-1b' --warning '100:' --critical '25:'

Code: Select all

Traceback (most recent call last):
  File "./check_ec2.py", line 561, in <module>
    main()
  File "./check_ec2.py", line 460, in main
    check_ec2(options.metricname, options.instanceid, options.period, statistics, options.accesskeyid, options.secretaccesskey, options.region)
  File "./check_ec2.py", line 139, in check_ec2
    Statistics=statistics
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 648, in _make_api_call
    operation_model, request_dict, request_context)
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 667, in _make_request
    return self._endpoint.make_request(operation_model, request_dict)
  File "/usr/lib/python2.7/site-packages/botocore/endpoint.py", line 102, in make_request
    return self._send_request(request_dict, operation_model)
  File "/usr/lib/python2.7/site-packages/botocore/endpoint.py", line 137, in _send_request
    success_response, exception):
  File "/usr/lib/python2.7/site-packages/botocore/endpoint.py", line 231, in _needs_retry
    caught_exception=caught_exception, request_dict=request_dict)
  File "/usr/lib/python2.7/site-packages/botocore/hooks.py", line 356, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/usr/lib/python2.7/site-packages/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/usr/lib/python2.7/site-packages/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/usr/lib/python2.7/site-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "/usr/lib/python2.7/site-packages/botocore/retryhandler.py", line 251, in __call__
    caught_exception)
  File "/usr/lib/python2.7/site-packages/botocore/retryhandler.py", line 277, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/usr/lib/python2.7/site-packages/botocore/retryhandler.py", line 317, in __call__
    caught_exception)
  File "/usr/lib/python2.7/site-packages/botocore/retryhandler.py", line 223, in __call__
    attempt_number, caught_exception)
  File "/usr/lib/python2.7/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://monitoring.eu-central-1b.amazonaws.com/"
I tried to modify the Region to "eu-central-1" without "b" and I got this error:

Code: Select all

sudo ./check_ec2.py -P 5 --metricname CPUCreditBalance --instanceid 'i-xxxxxxxx' --accesskeyid 'ACCESSKEY' --secretaccesskey 'SECRETYKEY' --region 'eu-central-1' --warning '100:' --critical '25:'

Code: Select all

The check has received a response with no data. This is generally caused by an incorrect region name, invalid metric name, or invalid instance ID.
Please verify the following:
Region: eu-central-1
Metric: CPUCreditBalance
Instance ID: i-xxxxxxxxxxxxxxx
Currently all the information looks correct!
Do you have any suggestion or workaround to avoid those errors?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: boto3 caught_exception botocore.exceptions.EndpointConne

Post by scottwilkerson »

Are you 100% sure i-xxxxxxxxxxxxxxx is active AND in that region?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
sgargano
Posts: 51
Joined: Mon May 23, 2016 9:06 am

Re: boto3 caught_exception botocore.exceptions.EndpointConne

Post by sgargano »

scottwilkerson wrote:Are you 100% sure i-xxxxxxxxxxxxxxx is active AND in that region?
yes they are,
should we enable some security rule from AWS or some API function for the metrics?
sgargano
Posts: 51
Joined: Mon May 23, 2016 9:06 am

Re: boto3 caught_exception botocore.exceptions.EndpointConne

Post by sgargano »

./check_ec2.py -P 5 --metricname CPUCreditBalance --instanceid 'i-' --accesskeyid '' --secretaccesskey '' --region 'eu-central-1' --warning '100:' --critical '25:'
The check has received a response with no data. This is generally caused by an incorrect region name, invalid metric name, or invalid instance ID.
Please verify the following:
Region: eu-central-1
Metric: CPUCreditBalance
Instance ID: i-........

created a new user in aws for nagios to double check
but same issue..
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: boto3 caught_exception botocore.exceptions.EndpointConne

Post by scottwilkerson »

Is this a Burstable Performance Instances? I believe these metrics are only available if they are

https://docs.aws.amazon.com/AWSEC2/late ... cw-metrics
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
sgargano
Posts: 51
Joined: Mon May 23, 2016 9:06 am

Re: boto3 caught_exception botocore.exceptions.EndpointConne

Post by sgargano »

yes it is a t2 and we can see the metrics on CloudWatch.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: boto3 caught_exception botocore.exceptions.EndpointConne

Post by scottwilkerson »

The users do need permissions to cloudwatch in AWS, such as CloudWatchFullAccess policy
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
sgargano
Posts: 51
Joined: Mon May 23, 2016 9:06 am

Re: boto3 caught_exception botocore.exceptions.EndpointConne

Post by sgargano »

yes we checked the user permissions and we are able to see the results by using the AWS cli:

Code: Select all

C:\Users\ss>aws cloudwatch get-metric-statistics --metric-name CPUUtilization --start-time 2019-05-28T10:18:00Z --end-time 2019-05-28T11:18:00Z --period 3600 --namespace AWS/EC2 --statistics Maximum --dimensions Name=InstanceId,Value=i-xxxxxxxxx

{

    "Datapoints": [

        {

            "Timestamp": "2019-05-28T10:18:00Z",

            "Maximum": 2.06896551724107,

            "Unit": "Percent"

        }

    ],

    "Label": "CPUUtilization"

}
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: boto3 caught_exception botocore.exceptions.EndpointConne

Post by scottwilkerson »

The metric you were previously trying to get and failed was CPUCreditBalance not CPUUtilization
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
sgargano
Posts: 51
Joined: Mon May 23, 2016 9:06 am

Re: boto3 caught_exception botocore.exceptions.EndpointConne

Post by sgargano »

[root@chlugmw1 ~]# aws cloudwatch get-metric-statistics --metric-name CPUCreditBalance --start-time 2019-05-28T10:18:00Z --end-time 2019-05-28T11:18:00Z --period 3600 --namespace AWS/EC2 --statistics Maximum --dimensions Name=InstanceId,Value=i-xxxxxxx
{
"Datapoints": [
{
"Timestamp": "2019-05-28T10:18:00Z",
"Maximum": 288.0,
"Unit": "Count"
}
],
"Label": "CPUCreditBalance"
}
Locked