09 Jan 2023 06:23 PM - last edited on 01 Aug 2023 08:18 PM by ghaydtner
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.
Solved! Go to Solution.
09 Jan 2023 07:18 PM
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
09 Jan 2023 07:48 PM
Thanks Julius. abovee solution worked.
09 Jan 2023 07:52 PM
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"?
09 Jan 2023 09:07 PM
API works with epoch timestamps. There is no way it returns a different format, maybe the tool which converts that epoch for you already?
01 Mar 2023 03:06 PM - last edited on 01 Aug 2023 08:19 PM by ghaydtner
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
01 Mar 2023 02:54 PM
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
01 Mar 2023 03:16 PM
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
01 Mar 2023 03:20 PM
hi Daniel, Is there a way to get previous month availability data without using timestamp?
01 Mar 2023 03:22 PM
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ő