Using metric variable in query

Hello,

we have an application exporting different restFull endpoint metrics to prometheus. They are all named with same prefix. For example “restmetrics_”. Because we do not want to change grafana dashboard for each new endpoint/methods added we would like to automate this.

I have create dashboard that generates variables by using metrics(restmetrics_) and than created rows for each variable name by using repeat functionality.

Now i want to add new query panel by executing query with variable that for that instance. If i use text panel i can use $some_variable and variable for that instance is displayed.

How can i now use this in a query for example:

restmetrics_users_list{instance=“localhost”}?

Greetings, Rok