21 Jun 2019
03:40 PM
- last edited on
25 May 2021
12:53 PM
by
MaciejNeumann
Hi,
I am trying to push the metrics related to the availability of an external webservice to Dynatrace.
I created a custom metric with unit type 'State' (as in: ServiceState)
However, when trying to post a metric, I always get a parsing error
{ "error": { "code": 400, "message": "Could not map JSON at 'series[0].dataPoints' near line 6 column 43" }
}
{
"series": [
{
"dataPoints":[[
1561122995985,
1
]],
"timeseriesId": "custom:edo.webservice.monitor"
}
],
"tags": [
"Mon_Test_AanvraagA1_ACC"
],
"displayName": "Test Webservice Monitor",
"hostNames": [
"brusrvjen03.test.be"
],
"type": "Test-Status-Services"
}
Can someone help me out with the correct values for the dataPoints?
Kind regards,
Jan
Solved! Go to Solution.
21 Jun 2019 06:06 PM
It looks like state needs different value than integer. I’m not sure what value, but dynatrace is trying to parse this place as something (not number). Maybe try true false or something like that? I’m not sure, just thinking.
Sebastian
24 Jun 2019 08:07 AM
Sorry, it seems I didn't react to your post.
Thanks for the suggestion but you'll find the results in my other post 😉
Jan
24 Jun 2019 08:05 AM
Hmm, didn't think of that.
However...
When trying $true or $false (I'm using powershell), the result is:
Invoke-RestMethod : {"error":{"code":400,"message":"Could not map JSON at 'series[0].dataPoints' near line 7 column 47"}}
At C:\Scripts_Dynatrace\develop\ng_mon_edo_webservices.ps1:128 char:15
+ $response = Invoke-RestMethod -ContentType application/json -Uri $dynaUrl -Met ...
Because it true and false should be converted to 1 or 0 (and than we get the payload from the first post):
Invoke-RestMethod : {"error":{"code":400,"message":"Constraints violated.","constraintViolations":[{"path":"series[0].dimensions","message":"Dimensions don't match
dimensions specified in configuration. Allowed extra dimensions from the configuration are: ServiceState","parameterLocation":"PAYLOAD_BODY","location":null}]}}
At C:\Scripts_Dynatrace\develop\ng_mon_edo_webservices.ps1:130 char:15
+ $response = Invoke-RestMethod -ContentType application/json -Uri $dynaUrl -Met ...
I could change the type to 'bit' (also true or false) but that's not as clear as a 'state'
Jan