Sending custom metrics to Datadog
Fri, Jul 20, 2018
One-minute read
Datadog is great for the metrics it gathers on its own, but sometimes the numbers you really want to track are your own. In this post we’ll push custom metrics into Datadog using Datadog’s own Python library, which keeps the whole thing to just a few lines.
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)
Once that runs, the metrics show up over on datadog.com, ready to chart.
PS: One thing to watch out for is that you cannot send metrics older than 1 hour.