# use metric dimension as a value in a timeseries query

**URL:** <https://community.dynatrace.com/t/use-metric-dimension-as-a-value-in-a-timeseries-query/56959>\
**Category:** DQL\
**Tags:** dql, dynatrace-managed, prometheus\
**Created:** [September 16, 2026, 11:47pm UTC](https://community.dynatrace.com/t/use-metric-dimension-as-a-value-in-a-timeseries-query/56959 "2026-09-16T23:47:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dougwillis](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@dougwillis](https://community.dynatrace.com/u/dougwillis)\
**Post date:** [September 16, 2026, 11:47pm UTC](https://community.dynatrace.com/t/use-metric-dimension-as-a-value-in-a-timeseries-query/56959/1 "2026-09-16T23:47:37Z")

</div>

I have some metrics coming into Dynatrace from a Prometheus scrape.  
The metric shows up as pg\_meta\_info and has a static value of 1 but many values setup as dimensions. One of these dimesnsions is version\_num which contains an integer representation of the PGSQL engine version.

Is there a way to use the dimension value, which is in the format&nbsp;140023,&nbsp;160014,&nbsp;160015, to show the dates that the postgresql database was upgraded?

I can see the changes of version using the query  
timeseries { avg(pg\_meta\_info), value.A = avg(pg\_meta\_info, scalar: true) }, by: { ins, ver\_num }  
but that does not show the actual dates the database version changes as the metric value is always 1.

---

<div class="post-metadata">

**Author:** ![Mohamed\_Hamdy](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@Mohamed\_Hamdy](https://community.dynatrace.com/u/Mohamed_Hamdy)\
**Post date:** [September 17, 2026, 6:08am UTC](https://community.dynatrace.com/t/use-metric-dimension-as-a-value-in-a-timeseries-query/56959/2 "2026-09-17T06:08:16Z")

</div>

You can derive this from the first time each PostgreSQL version (ver\_num) is observed for each instance (ins).

For example:

timeseries {  
A = avg(pg\_meta\_info),  
timestamp = start()  
},  
by: { ins, ver\_num },  
interval: 1h  
| fieldsAdd first\_seen =  
arrayFirst(iCollectArray(if(isNotNull(A[]), timestamp[])))  
| fields ins, ver\_num, first\_seen  
| sort ins asc, first\_seen asc

Since ver\_num is a dimension, each PostgreSQL version creates a separate time series. The query finds the first non-null datapoint for each version and returns its timestamp.

first\_seen should therefore indicate when Dynatrace first observed that PostgreSQL version.

Just keep in mind that this is the first observation within the selected timeframe, so the timeframe needs to start before the upgrade. The accuracy will also depend on the selected interval/scrape frequency.
