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

Dynatrace V2 Metrics API - Metrics for Only One Tag

louis_gallo
Helper

Okay, my journey becoming acclimated to the V2 API continues.

 

How do I limit my entities returned to only one particular application tag? I only want the entities returned in "SomeApplication:SomeApp". The way I am doing it here works but it returns every entity it can find.

 

https://xxxxxxxx.live.dynatrace.com/api/v2/metrics/query?metricSelector=builtin:tech.jvm.memory.gc.suspensionTime:names:merge(1)&resolution=1m&from=now-1m&to=now&entityName("SomeApplication:SomeApp")  

 

Any help is appreciated.

 

Lou

2 REPLIES 2

Radu
Dynatrace Champion
Dynatrace Champion

Hi Lou,

 

If you have a tag called "SomeApplication" with value "SomeApp" you can add this using the tag entry of the entitySelector parameter.

 

Your query:

.../metrics/query?metricSelector=builtin:tech.jvm.memory.gc.suspensionTime:names:merge(1)&resolution=1m&from=now-1m&to=now&entityName(%22SomeApplication:SomeApp%22)

Is invalid, so I am surprised it works at all. entityName should be part of the entitySelector parameter, but will only work for matching entity names - however, in this case I think it is disregarded completely as it's not part of entitySelector query parameter. Also there is no need to specify "to" when the time is relative as that already implies it's to now.

 

What you need to use is the entitySelector parameter with the tag you want to filter by. Among other things, tag is an optional sub-component of it. However, you must also specify either enitity type or ID when using this parameter. For your chosen metric, the entity type is PROCESS_GROUP_INSTANCE (since it's collected per process).

 

Your query would work as such:

...metrics/query?resolution=1m&entitySelector=type(process_group_instance),tag(SomeApplication:SomeApp)&from=now-1m&metricSelector=builtin:tech.jvm.memory.gc.suspensionTime:names:merge(1)

 

Give this a try and let us know how it goes.

 

Best regards,

Radu

Radu, thanks so much!! That worked great! I just needed the kick start to get the hang of the API.

Featured Posts