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

Dynatrace Environment API 2.0/metrics/query

Balamurugesh
Guide

hi, I am trying to pull monthwise availability metrics of synthetic monitors from dynatrace using below query,

curl -X GET "https://abc.dynatrace.com/api/v2/metrics/query?metricSelector=builtin%3Asynthetic.browser.availability.location.total%3A%20splitBy%28%22dt.entity.synthetic_test%22%29%3Anames%3Alast%3A%20default%280%29&resolution=1M&from=now-1M&entitySelector=mzName%28%22mzName1%22%2C%20%22mzName2%22%29%2Ctype%28%22SYNTHETIC_TEST%22 " -H "accept: application/json; charset=utf-8" -H "Authorization: Api-Token apiKey"

Issue: When i run this query, am getting availability metrics for 2 months instead of a month. For instance, i ran the above query today and got availability details for Jan and december instead of december.  Need your inputs ni refactoring the above query to get monthwise data for a particular month.

9 REPLIES 9

Julius_Loman
DynaMight Legend
DynaMight Legend

If you want only a single value for the entire timespan, then you need either set the resolution to inf instead of 1M or use the :fold transformation in the metric selector

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Thanks Julius. abovee solution worked.

 

Also, in response am getting date format as "1/1/2023 12:00:00 AM".  Can i get it in different format like "23-Jan"?

API works with epoch timestamps. There is no way it returns a different format, maybe the tool which converts that epoch for you already?

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

hi,

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

Balamurugesh
Guide

hi Team,

 

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

Hi @Balamurugesh , you can use UTC time in the from and to clauses:

curl -X GET "https://abc.dynatrace.com/api/v2/metrics/query?metricSelector=builtin%253Asynthetic.browser.availability&from=1675220400&to=1677639540" -H "accept: application/json; charset=utf-8" -H "Authorization: Api-Token

 

The true delight is in the finding out rather than in the knowing.

hi Daniel, Is there a way to get previous month availability data without using timestamp? 

Mizső
DynaMight Guru
DynaMight Guru

Hi @Balamurugesh,

Or maybe try this of any case for the previous month "from=-1M%2FM%20to%20now%2FM".

(-1M/M to now/M).

Best regards,

Mizső

Dynatrace Community RockStar 2024, Certified Dynatrace Professional

Featured Posts