Closed mrigank002 closed 1 year ago
This obj_params is a dictionary and it should run .get method. But I don't know why it is throwing exception.
when I am running this code in my machine for tis dict it is working fine:
for obj_params in metrics["series"]: print(obj_params.get("host", ""))
Thanks for your contribution!
This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.
If you would like this issue to remain open:
Verify that you can still reproduce the issue in the latest version of this project.
Comment that the issue is still reproducible and include updated details requested in the issue template.
Hi,
Sorry for not responding earlier. The issue is that you have a series
key which should not be here. Here's a working example:
metrics = [
{
"type": "rate",
"interval": 1,
"host": "GitLab",
"metric": "thl.certificate.days.test",
"tags": [
"source:vault",
"sre-environment:dev",
"sre-appstackcode:odccsm",
"namespace:namespace",
"name:name",
"region:region",
"trigram:trigram",
"purpose:purpose",
],
"points": [[time.time(), 5]],
}
]
api.Metric.send(metrics=metrics)
This is what my metrics is: metrics={ "series": [ { "type": "rate", "interval":1, "host": "GitLab", "metric": "thl.certificate.days.test", "tags": [ "source:vault", "sre-environment:dev", "sre-appstackcode:odccsm", "namespace:namespace", "name:name", "region:region", "trigram:trigram", "purpose:purpose" ], "points": [ [ time.time(), "5" ] ] } ] }
api.Metric.send(metrics=metrics)
error:
Traceback (most recent call last): File "/home/gitlab-runner/builds/wkpzw2iM/0/mcs/odc/certificate-operations/datadog_test.py", line 47, in
api.Metric.send(metrics=metrics)
File "/home/gitlab-runner/.local/lib/python3.10/site-packages/datadog/api/metrics.py", line 109, in send
return super(Metric, cls).send(
File "/home/gitlab-runner/.local/lib/python3.10/site-packages/datadog/api/resources.py", line 80, in send
return APIClient.submit(
File "/home/gitlab-runner/.local/lib/python3.10/site-packages/datadog/api/api_client.py", line 145, in submit
if obj_params.get("host", "") == "":
AttributeError: 'str' object has no attribute 'get'