DQL
Questions about Dynatrace Query Language
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get a list of all dimensions for a metric in Grail?

36Krazyfists
Advisor

Basically, I'm looking for something synonymous to the "describe" command, but for metrics.  Does anything like that currently exist?

Yes, in DQL you get the auto-complete pop-ups when you type "by:" in the "timeseries" command and using the Metrics browser you can use the split-by to get a list of available dimensions, but I'm working on something more dynamic and need to find a way to get a list of all available dimensions for any specific metric.

Is there any programmatic way to do this right now?  In the Classic API v2 there is an endpoint that will return this data, but how would I do that in DQL or using the newer Grail API's (I'd prefer to be able to do it solely in DQL, but if that isn't possible, I could settle with an API call if necessary).

 

Thanks!

2 REPLIES 2

Emm4nuel
Dynatrace Helper
Dynatrace Helper

DQL does not currently support retrieving dimensions for a metric directly. 

You could use the Metrics API on a code tile:

  • You can use the Metrics API v2 to query metadata for a specific metric, including its available dimensions.
  • Endpoint: GET /api/v2/metrics/{metricKey}
  • Replace {metricKey} with the key of the metric you want to query (e.g., builtin:host.cpu.load15m).
  • The response will include details about the metric, including its dimensions (dimensionDefinitions)
    Check this link to see the properties you would get from this API call : 

Isaac
Observer

To expand on this, you can actually see the available dimensions, but it's a bit inconvenient and not really a list of dimensions but a list of series. Lets assume your looking for the dimensions on the dt.host.cpu.usage metric in Grail. If you run the following DQL query you will get all series for that metric

fetch metric.series
| filter metric.key == "dt.host.cpu.usage"

 As I said, this isn't a list of dimensions, but each row represents a different series and the columns are the dimensions on that series. As the dimensions are dynamic and DQL doesn't support an unpivot command, the only real way to use this to get a list of dimensions would be to get the full list of series, export to csv, and then extract just the header row to get the dimension list. I'm currently looking for more information on how dimensions are added to metrics myself, for example with host centric metrics, the host custom metadata seems to be added as dimensions.

 

Alternatively, you can pull the auto complete suggestions programmatically via the DQL autocomplete endpoint (/platform/storage/query/v1/query:autocomplete) but I have never done so and don't know how effective it is. It is the underlying logic used by the metric browser I believe.

Featured Posts