Pass result of one query into another while creating alert rules

Hi. I have a use case where I need to pass the result of one Query(A) into the next one as part of the input. Is that possible?
Use case:
Query ‘A’ is will return the state of objects, active/inactive. I only want to move forward with objects with Active states in the next set of queries/expressions.

How to do this?
Grafana version: 9.2.3 OSS

What is your data source?

Victoriametrics added as Prometheus data source.

Hi guys,
I have the same question.
Did you had any luck fixing it?

You probably want to use Recording Rules. I think it’s supported in VictoriaMetrics. You’ll want to check out their documentation for this.

If you want to filter all other queries by only Active objects, you can create a Grafana variable which will get instance/pod names, or whatever can be used as a filter. And then reuse that variable in all your queries.
For example:

Variable expression: $active_instances =  label_values(my_objects(state="active"), instance)

Then in your panels you can do the following:
QueryA: cpu_usage{instance=~"$active_instaces"}