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

Metrics API to query values

ErwinB
Visitor

Hi Dynatrace community,

As I'm om my mission to get the most out of Dynatrace apps, I'm now also exploring the Dynatrace API.

My use case is around Kong API Gateway, we have hundreds of services deployed and each month I want a list of not-used services. From Kong all the logs, with meta-data, are sent to Dynatrace. In Dynatrace I use the openPipeline to generate metrics from the logs, for example metric kong.log.status has a dimension service.name.
The report is scheduled in Gitlab and here I want to query the metrics if a certain service.name datapoint exists in the last month.

The full query will be api/v2/metrics/query?metricSelector=log.kong.status, is it possible to filter on service.name?
It's part of the response:
{
"dimensions": [
...,
"ASW_Europe_MyService",
...
],
"dimensionMap": {
...,
"service.name": "ASW_Europe_MyService",
...
},

 

The response from the default last 2 hours is already 10MB, so querying for the last month and parsing the response should not be the right way 🤣

Also, if someone already managed to query similar metrics using grail for example please share an example, might be an option as well although it's asynchronous versus metrics are synchronous.

1 REPLY 1

ErwinB
Visitor

Found it, this time the answer was actually in the documentation 🤣

This does the trick: api/v2/metrics/query?metricSelector=log.kong.status:filter(eq("service.name","ASW_Europe_MyService")):fold(sum)&from=now-1M

Featured Posts