Referencing query metric object in panel title

This question is regarding the object below, which can be seen in the Query Inspector.

"result": [
          "metric": {
            "environment": "myenv",
            "instance": "",
            "instance_id": "i-1234abcdef5678",
            "job": "my-job-name",
            "microservice": "microservice-name",
            "pid": "12345"
          "value": [

I am using a SingleStat panel to display the status of a running process.
I have labelled each metric with both the PID (process ID which is unique per process) and the instance ID. I am repeating the panel per PID but I would also like to include the instance ID in the panel title.

I would like to reference the instance_id label in the query object above, in the panel title, for example: {{instance_id}}. Is there a way to do this?

I’ve tried all sorts of templating combinations but I run into trouble trying to tie multiple templated labels together. I end up referencing an instance ID variable in my PID variable label_values query which causes problems when I try to select ‘All’ in the instance ID variable. What I want doesn’t seem like it should require a templated instance_id variable. The PID variable is for the templating, I simple want to display another label for each templated panel instance, in the title.

Is there any way to reference the metric object in the query object in my panel title, as opposed to creating a variable?

Thanks in advance.

I’ve found something of a workaround after looking at this post.

I can create a second, parallel repeating row of singlestat panels and set Vizualisation > Show to Name. This way, the panel text displays the query Legend value, which I can set to {{instance_id}}.

However, this isn’t ideal because, once my singlestat panels repeat on to a new line, the corresponding instance ID panels won’t appear next to them. This solution only works where I have one line of repeated panels which won’t always be the case.

It seem like __series.labels. should allow me to accomplish this but the documentation implies that it only works for URLs, where I can’t seem to get it working anyway.

In the end I’ve used a bar graph. This has both the value mapping feature (so I can turn my whole number metric into a word representing the process status) and can effectively be templated within the query using “count by (labels)(query)”. Crucially, it allows me to map string values to the metric but also annotate the individual bar with it’s respective instance ID and process ID.