3

I'm a beginner and I'm totally stuck on this one. I tried many different solutions but haven't been able to find one that works yet, could you help me? :)

I created an Ubuntu 12.04 VM with Vagrant on VirtualBox and installed a Datadog agent on it. I then created a Datadog API script to create a timeboard with different graphs. I'm trying to execute the python script but I get a warning every time, and no results. As you can see here: https://docs.datadoghq.com/api/?lang=python#create-a-timeboard I should be able to see the timeboard in my Datadog dashboard, but it doesn't appear.

Here is the script I created in /home/datadog :

#!/usr/bin/env python

from datadog import initialize, api

options = {
    'api_key': 'MYAPIKEY',
    'app_key': 'MYAPPKEY'
}

initialize(**options)

title = "Visualizing Data for Barbosa"
description = "Timeboard using Datadog's API"
graphs = [

{
    "definition": {
        "events": [],
        "requests": [
            {"q": "my_metric{host:precise64}"}
        ],
        "viz": "timeseries"
    },
    "title": "My metric scoped over my host"
},

{
    "definition": {
        "events": [],
        "requests": [
            {"q": "anomalies(avg:mysql.performance.cpu_time{host:precise64}, 'robust', 2)"}
        ],
        "viz": "timeseries"
    },
    "title": "Anomalies on MySQL for CPU time"

},

{
    "definition": {
        "events": [],
        "requests": [
            {"q": "avg:ùy_metric{host:precise64}.rollup(sum, 3600)"}
    ],
        "viz": "timeseries"
    },
    "title": "Rollup for My metric over the past hour"

}]

read_only = True
api.Timeboard.create(title=title,
                     description=description,
                     graphs=graphs,
                     read_only=read_only)

And when I execute the script using /home/datadog$ ./timeboard.py I am getting the following:

/usr/local/lib/python2.7/dist-packages/urllib3/util/ssl_.py:339: 
SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name 
Indication) extension to TLS is not available on this platform. This may 
cause the server to present an incorrect TLS certificate, which can cause 
validation failures. You can upgrade to a newer version of Python to solve 
this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-
usage.html#ssl-warnings.
SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/urllib3/util/ssl_.py:137: 
InsecurePlatformWarning: A true SSLContext object is not available. This 
prevents urllib3 from configuring SSL appropriately and may cause certain 
SSL connections to fail. You can upgrade to a newer version of Python to 
solve this. For more information, see 
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings.
InsecurePlatformWarning

I tried upgrading python but when executing the code with Python 3, it doesn't recognize the Datadog python package anymore (https://github.com/DataDog/datadogpy) and I don't know how to move it from Python 2.7, or if deleting Python 2.7 will cause huge issues in my code/script. I'm a beginner so sorry if this is confusing!

I also tried following https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings but unfortunately the import command doesn't work either, is there a specific software/package to install to make it work?

What am I doing wrong? Thanks!

2

The answer was to remove the warnings by adding import... directly in the python script, as explained in this answer on stackoverflow.com.

| improve this answer | |
  • Please accept your answer by clicking on the check mark to the left. That will mark the question as answered. – dessert Mar 2 '18 at 12:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.