Sending custom metrics to Datadog

Fri, Jul 20, 2018 One-minute read

In this post we will sending custom metrics to datadog via datadog’s own python library.

from datadog import initialize, api
import time

options = {
    'api_key': '***',
    'app_key': '***'
}

ourPoints=[]

for i in range(len(date)):
    ourPoints.append((date[i],score[i]))
    
initialize(**options)
api.Metric.send(
    metric='webischia.metrics.blog',
    points=ourPoints)

After that we can show our metrics on datadog.com.

PS: Beware you cannot send older metrics from 1 hour ago.

https://help.datadoghq.com/hc/en-us/articles/203038029-I-d-like-to-add-historical-data-to-my-account-is-there-a-way-to-do-that-