22 Nov 2019
10:25 AM
- last edited on
03 Oct 2022
01:23 PM
by
Ana_Kuzmenchuk
I am using the Dynatrace API V1 and trying to POST custom metrics into it. I have followed the below link and the workflow.
I'm have PUT the custom metric, GET the custom metric and Register a custom device using POST
However, when I try to POST metrics to the custom device I get the below error. Any thoughts on what it means and how to fix it?
{
"error": {
"code": 400,
"message": "The timeframe is not clear -- either start & end timestamp or relativeTime."
}
}
Hi Hannah, Im pretty much duplicating whats in the below link but with updated timestamps https://www.dynatrace.com/support/help/extend-dynatrace/dynatrace-api/environment-api/topology-and-s...
{ "tags": [ "tag2" ], "type": "F5-Firewall", "properties" : { "Sample Property 2": "Sample value 2" }, "series" : [ { "timeseriesId" : "custom:firewall.connections.dropped", "dimensions" : { "nic" : "ethernetcard1" }, "dataPoints" : [ [ 1539860400000, 460 ], [ 1539860460000, 456 ] ] }, { "timeseriesId" : "custom:firewall.connections.dropped", "dimensions" : { "nic" : "ethernetcard2" }, "dataPoints" : [ [ 1539860430000, 439 ], [ 1539860490000, 460 ] ] } ] }
Here are the calls I am making. The first three work fine, its the last one that fails with the error
PUT /e/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/api/v1/timeseries/custom%3ACustomMetricName HTTP/1.1
Content-Type: application/json
cache-control: no-cache
{
"displayName" : "Custom Display Name",
"unit" : "Percent",
"dimensions": [
"CustomDimension"
],
"types": [
"Custom-Type"
]
}
GET /e/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/api/v1/timeseries/custom%3ACustomMetricName HTTP/1.1
Content-Type: application/json
cache-control: no-cache
{
"displayName" : "Custom Display Name",
"unit" : "Percent",
"dimensions": [
"CustomDimension"
],
"types": [
"Custom-Type"
]
}
POST /e/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/api/v1/entity/infrastructure/custom/CustomDevice HTTP/1.1
Content-Type: application/json
cache-control: no-cache
{
"displayName" : "Custom Display Name",
"type" : "Custom-Type",
"tags": [
"REST example"
],
"properties" : {
"Sample Property 1": "Sample value 1"
}
}
POST /e/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/api/v1/timeseries/custom%3ACustomMetricName HTTP/1.1
Content-Type: application/json
cache-control: no-cache
{
"tags": [
"tag2"
],
"type": "Custom-Type",
"properties" : {
"Sample Property 2": "Sample value 2"
},
"series" : [
{
"timeseriesId" : "custom:TimeSeries.Id",
"dimensions" : {
"CustomDimension" : "Dimension1"
},
"dataPoints" : [
[ 1574349600000, 60 ],
[ 1574350200000, 55 ]
]
},
{
"timeseriesId" : "custom:TimeSeries.Id",
"dimensions" : {
"CustomDimension" : "Dimension2"
},
"dataPoints" : [
[ 1574349600000, 76 ],
[ 1574350200000, 80 ]
]
},
{
"timeseriesId" : "custom:TimeSeries.Id",
"dimensions" : {
"CustomDimension" : "Dimension3"
},
"dataPoints" : [
[ 1574349600000, 39 ],
[ 1574350200000, 25 ]
]
}
]
}
22 Nov 2019
10:58 AM
- last edited on
29 May 2023
10:31 AM
by
MaciejNeumann
Does it work if you run it from the API Explorer?
https://<yourtenant>.live.dynatrace.com/rest-api-doc/index.jsp?urls.primaryName=Environment%20API%20v1#/Topology%20%26%20Smartscape%20-%20Custom%20device/createCustomDataPoints
I tried that before I moved over to postman as I was not able to authenticate the API token using the API explorer as it doesnt seem to be adding the API token to the request and there is no way for me to amend it. BTW, I have authorised and entered the API token at the top right of the page too.
You're call does look ok. Does it work if you send a single dimension?
Tried that too and no, that didn't work either!