'No custom metrics when posting by HTTP

There seems to be very limited documentation on this. I'm looking to post a custom metric (actually from an IoT microcontroller) via HTTP.

According to this page the appropriate endpoint is POST https://api.datadoghq.com/api/v1/series?api_key=xyz, although this does seem more geared to posting a bulk set of time series data and not for individual measurements. Anyway, I've posted to it in various ways (including the EXAMPLE JSON given on that page) and receiving back HTTP 202s, which leads me to believe the data is sinking in somewhere.

However, nothing appears in the Metrics Explorer section on my account.

Can anyone provide some direction?



Solution 1:[1]

With the information provided, I don't see where the issue can come from. Could you share the full code used for the submission (without the API key).

If another example could help, here is what I use in Python:

import json
import requests
import time

def submit_timeseries_point(config, metricname, hostname, value, tags, type = "gauge"):
  timestamp = time.time()
  payload = { "series": [{
      "metric": metricname,
      "points": [[timestamp, value]],
      "type": type,
      "host": hostname,
      "tags": tags
  }]}
  headers = {'content-type': 'application/json'}
  url = '{}api/v1/series?api_key={}'.format(config["api_host"], config["api_key"])
  r = requests.post(url, data=json.dumps(payload), headers=headers)
  jsonResponse = r.json()

Then I usually check if the metric appears in the metric summary page.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 XYZ123