If I have matrics like this
my_metric{deployTime="1603284798",foo='bar'}
my_metric{deployTime="1603284799",foo='bar2'}
my_metric{deployTime="1603284800",foo='bar3'}
And I want to get only the metrics where the timestamp is greater than some value, how can I do it?
I was thinking of:
count by (deployTime, foo) (my_metric{deployTime > "1603284799", foo=~".*"})
but of course, this doesn't work as labels are strings. So what are my options to filter by label value if I want to use the greater than operator?
This can be done with label_value() function from MetricsQL:
MetricsQL also supports now() function, which can simplify calculations for timestamp relative to the current time. For example, the following query would filter out time series with
deployTime
values older than one hour from now: