DataDog / datadogpy

The Datadog Python library
https://datadoghq.com/
Other
612 stars 304 forks source link

lib not pushing custom metric (using api) #727

Closed cesdperez closed 2 years ago

cesdperez commented 2 years ago

I'm trying to push a metric from my laptop using this code

from datadog import initialize, api
import time

# This expects `DD_API_KEY` and `DD_APP_KEY` in your env
initialize()

count = 99

response = api.Metric.send(
    metric="my.metric",
    points=[(time.time(), count)],
    tags=["tag1:x", "tag2:y"],
    type="count"
)
print(response)

I get {'status': 'ok'} as response but my metric never shows up on Datadog Metrics explorer.

lib version: 0.44.0

therve commented 2 years ago

You're not using the EU instance by any chance? This would require you to set DD_SITE as well.

cesdperez commented 2 years ago

oh, that was it 😅. I may have missed it, but don't remember many references to DD_SITE in the documentation. Also, the API should return an error.

Thanks!

therve commented 2 years ago

I think if you pass a valid key, for performance reason it doesn't return an error to not check the credentials synchronously. This is a backend behavior though, please open a support ticket. Thank you!