in our environment we have thousands of microservices, each with some endpoints (requests) , we want to obtain the number of calls to each endpoint, the maximum and average response time by minute/hour for each endpoint and microservice?
How can I get this information via API?
Regards, Josep Maria
Solved! Go to Solution.
This really depends on how your microservices are structured within Dynatrace's Service layer. Does each Dynatrace Service represent a microservice endpoint, or are they represented like Requests under a Service? This will allow you to understand what metrics you need to extract (i.e. at Service level or at Key Request level).
Once you understand that you can head over to the Metrics API endpoint which allows granular access to extracting the details you've mentioned. The metrics you'll be working with are:
Request-level (request must be marked as Key Request):
If you want to add additional aggregations to these you will have to specify them in brackets. This is all done in the metricSelector parameter. For example:
The calls to /api/v2/metrics/query by default will bring in results for all possible dimensions (in this example Services and/or Key Requests) that collect this metric. To focus just on your microservices, start working with the entity selector:
At a minimum you will have to provide type. But a good approach is to add tags on top of this that you can use to identify these microservices. If I had a tag with key "Layer" and value "Microservices" I would structure it like so:
The final bits are the timeframe and granularity. With the timeframe you will have to decide how frequently you're going to make these API calls. Whereas with granularity you mentioned you want it minute by minute. So if I wanted to grab the last 1hr of data minute-by-minute I would add the following parameters:
The final point to keep in mind is the pagination. Depending on how many of these entities you'll pull (you said you have thousands) - you will have to set the page size accordingly. So the pageSize parameter sets the maximum number of entities that will be retrieved per call out of the entire dataset (1 - 5000) - if your dataset is too large it will be paged and to retrieve the next page of results you will have to remove all other parameters (on subsequent calls) and instead just pass in the "nextPageKey" which will be give to you in the body of the response on all calls except the first.
I hope this info helps you out.