cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Synthetic monitoring Availability - Metrics API response

Balamurugesh
Guide

Hi Team,

 

I am trying to get monthwise availaibity metrics of synthetics monitors using Synthetic API, but in response, am getting timestamps in UNIX format. Is there is way to get it in DD-MM-YY format or human understandable format?

10 REPLIES 10

Fin_Ubels
Dynatrace Champion
Dynatrace Champion

Hey Balamurugesh,


If you request the data in CSV format you will get get a date/time format as seen in my screenshot below.

Fin_Ubels_1-1657687700301.png

 

My example query looks like the following.

Fin_Ubels_2-1657687835770.png

 

 

The docs for querying metrics can be found below with an example for the CSV format at the bottom.
https://www.dynatrace.com/support/help/dynatrace-api/environment-api/metric-v2/get-data-points#tabgr...

 

Unfortunately I can't see a way to request the time in a date/time format when getting a response in json.

thanks for the details. When i query metrics API, am getting monitor Id's in response. Is there a way to get monitorName instead of monitorId in response?

If you have a look at the screenshots I posted you can get the name by adding :names to your metric query. As you can see in the CSV response for my query the name of my http monitor is Recipe API.

hi Fin, I have tied each synthetic monitor with respective application. Am looking for application name as well in response. Is there a way to get the tied Application name in response? 

Regards,Dingu

If you tied the application name to the synthetic with tags, as far as I can tell that isn't possible without making another request to get the details on the synthetic in question. Using the returned synthetic ID you can query the synthetic API to get all details including tags.
https://www.dynatrace.com/support/help/dynatrace-api/environment-api/synthetic/synthetic-monitors/ge...

 

Below is an example

Fin_Ubels_0-1658707438334.pngFin_Ubels_1-1658707481440.png

 

Is there any possibility to get the application details in metrics API call?

 

Not that I can find unfortunately unless you used a synthetic naming scheme that used the applications name since the synthetic name is provided in the query response.

hi Fin,

 

I am using below curl request to pull synthetic monitors availability metrics for a month.

curl -X GET "https://abc.dynatrace.com/api/v2/metrics/query?metricSelector=builtin%3Asynthetic.browser.availabili..." -H "accept: application/json; charset=utf-8" -H "Authorization: Api-Token apiKey"

 

When i run this query today, am getting data for march month. what should i update in the query to get previous month (FEb month)availability data?

 

Thanks,

bala

Hey Bala,
You need to modify the timeframe selector in your query. There is a cheat sheet for it in DT when you expand the selector input. I would suggest reading into the examples in there as well as looking into the docs as it's very useful for building out complex dashboards and reports relying on the API.

Fin_Ubels_0-1677711420470.png

What you're looking for is "&from=now-1M/M&to=now/M" which specifies from now minus 1 month, then rounding to the nearest month. Then it goes to now rounded to the nearest month. So it would round from the beginning of Feb to the beginning of March.

techean
Dynatrace Champion
Dynatrace Champion

No! currently there is no way you can get that response change from api. You can use a post processor script.

Also check this solution if helps

RFE in place RFE - Dynatrace API can specific timezone using relative timeframe parameters - Dynatrace Community

KG

Featured Posts