16 May 2022 04:56 PM - last edited on 17 May 2022 08:59 AM by MaciejNeumann
Hi Team,
I am looking for an API which will provide following detials,
1. Availability metrics Report for all monitors or applications configured in Dynatrace
2. Real User Metrics
Thanks,
Balamurugesh
Solved! Go to Solution.
17 May 2022 07:14 PM
There is no API for that type of reporting, the only 'report' focused API is for managing the configuration of report subscriptions: https://www.dynatrace.com/support/help/how-to-use-dynatrace/dashboards-and-charts/dashboards/subscri...
What you can make use of though is the Metrics V2 API to read metric data (all metrics chartable in Dynatrace are available) and feed that to a reporting tool or build reporting off of that some other way.
https://www.dynatrace.com/support/help/dynatrace-api/environment-api/metric-v2
18 May 2022 01:09 AM
hi James, I got to know that i will be able to get the synthetic monitors availability metrics using metric Query API. But i am not sure what values i have to pass in resolution and time frame. I am looking for availability metrics for all monitors in a particular week/month/year
18 May 2022 01:11 AM
it would be great if you can provide a sample curl command which will give synthetic monitors availability metrics for an week/month/year.
19 May 2022 03:02 PM
If you haven't used it before I would check out and get familiar with the API Explorer in the UI. It makes it easier to play with the endpoints and fields you send and especially nice is it will also show you what the formatted curl command will look like as an example.
As a simple metric selector in the metrics V2 query API:
builtin:synthetic.browser.availability.location.total:splitBy("dt.entity.synthetic_test","dt.entity.geolocation")
Place that in the metricSelector field:
Run it and at the bottom you should see the resulting json as well as the request that was sent and a curl example:
curl -X GET "https://<dynatrace_hostname>/api/v2/metrics/query?metricSelector=builtin%3Asynthetic.browser.availability.location.total%3AsplitBy%28%22dt.entity.synthetic_test%22%2C%22dt.entity.geolocation%22%29" -H "accept: application/json; charset=utf-8" -H "Authorization: Api-Token <token_with_proper_permissions>"
19 May 2022 03:53 PM
James, may i know why you are passing "AsplitBy%28%22dt.entity.synthetic_test%22%2C%22dt.entity.geolocation%22%2"
in metric selector? I am using below query to get availability metrics from a management zone,
curl --location --request GET
'https://dynatrace.com/e/abc/api/v2/metrics/query?metricSelector=%22builtin%3Asynthetic.http.availabi...' \
--header 'accept: application/json; charset=utf-8' \
is there a way to pass multiple managementzones and monitor types in a single request? Also i was asked to use merge transformation in query to get the exact metrics like it shows in dynatrace APP. can you explain how to pass merge transformers in above query as well?
20 May 2022 02:51 PM
I was just using a basic metric selector to show all test availability split by test name and location. You have a lot of control over how the data is filtered, organized, and aggregated using the metric selectors. I would read through their documentation to get familiar with what is possible. The API also has an entitySelector field where you can apply additional filters on top of the query to limit which entities (e.g. synthetic tests) are included when querying.
You can try these entity selectors first to test and make sure you get the data you want in the Data Explorer using the 'code' tab as well. Once you get it working you can plug the query into the API.
28 Oct 2022 07:15 PM
hi, I could get monthwise availability data for synthetic monitors using metrics API. is it possible to get the same for process group? if so, can you please share the sample curl request?
01 Mar 2023 02:56 PM
hello James,
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