11 May 2022 01:42 PM - last edited on 21 Aug 2024 08:52 AM by Michal_Gebacki
I need to be able to GET the apdex score of a specific application/entity, but can't figure out how to do it via api. In Postman I'm using the following, which I found online:
https://[HOST]/e/[ID]/api/v1/timeseries?relativeTime=hour&aggregationType=count×eriesId=com.dynatrace.builtin:app.apdex&queryMode=total
and it's returning a lot (everything?) including what I believe is the apdex score I'm looking for (please correct me if I'm wrong?).
Ex (0.57 and 0.95😞
Solved! Go to Solution.
11 May 2022 02:48 PM - edited 11 May 2022 02:50 PM
I recommend using the Metrics v2 API instead as it is much more powerful.
To retrieve Apdex all applications application you can query the metric:
builtin:apps.web.apdex.userType
For example - fetching it for last 1 week timeframe, including the entity names:
curl -X GET "<your_environment>/api/v2/metrics/query?metricSelector=builtin%3Aapps.web.apdex.userType%3AsplitBy%28%22dt.entity.application%22%29%3Anames%3Aavg%3Aauto&from=now-1w" -H "accept: application/json; charset=utf-8" -H "Authorization: Api-Token <your_api_token>"
The Metrics API uses metric selectors to describe the metric queries, in the example we used:
builtin:apps.web.apdex.userType:splitBy("dt.entity.application"):names:avg:auto
This will retrieve the metric, split it by the application (so you have numbers for each app) and it uses the :name transformation to add the entity (application) name in the result. The data points in a bucket are average.
There are plenty of metric selector transformations you can use.
To filter it for a specific entity, you can use the either the entitySelector query parameter for the API or the :filter parameter in the metric selector. For example the entitySelector in your case will be :
entityId("APPLICATION-2104433A851141A1")
11 May 2022 03:35 PM
Thank you for the reply. The curl statement returns much, but I'm not sure how I'd format the uri for use with Postman, and subsequently the api call in the external app's interface. Can you please provide a full example? of both the curl and Postman GET including the entityId entitySelector you mention - I've tried using entityId before, but it always errors out, so where/how to use it isn't clear to me.
Thank you.
11 May 2022 08:12 PM
The entitySelector is just another parameter for the API call. In the example above the cURL command will be changed to:
curl -X GET "<your_environment>/api/v2/metrics/query?metricSelector=builtin%3Aapps.web.apdex.userType%3AsplitBy%28%22dt.entity.application%22%29%3Anames%3Aavg%3Aauto&from=now-1w&entityId%28%22APPLICATION-2104433A851141A1%22%29" -H "accept: application/json; charset=utf-8" -H "Authorization: Api-Token <your_api_token>"
I don't use Postman at all, so I won't navigate you how to do that in postman. Maybe will find the preconfigured collections by @Patrick_Hofman1 useful.
11 May 2022 09:41 PM
Thanks, again. that latest curl statement still seems to be pulling everything, for every APPLICATION-*.
I have been able to get a little closer using Postman using your suggestions, it's still retrieving every APPLICATION, but the format's a little easier to read, and the apdex I'm looking for appears to be the 1st value in a list of dozens/hundreds. Just need to pare that down a bit.
The Patrick Hofman collections look promising, but there seems to be lorem ipsum throughout, and I don't know what to replace with what.
I'll keep digging - thank you again for your help.
12 May 2022 08:00 AM
No, it will definitely filter out only the application you need. But it will receive datapoints for the interval specified.
If you need a single value, then you need to apply the :fold(avg) transformation to the metric selector:
builtin:apps.web.apdex.userType:splitBy("dt.entity.application"):names:avg:auto:fold(avg)
Then you will see only a single value (appdex average for the interval).