You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Grafana中Influx模板查询:含$的标签键如何转义避免变量插值

How to Escape $ in Grafana Template Queries for InfluxDB (When $ Is Part of the Tag Key)

Got it, I’ve run into this exact headache before—dealing with InfluxDB tag keys that include dollar signs when using Grafana’s templating. The fix is straightforward once you know Grafana’s escape syntax for literal dollar signs.

Grafana’s template engine treats a single $ as the start of a variable interpolation. To tell it to treat the $ as a literal character (part of your tag key, not a variable), you just need to double the dollar sign ($$).

Modified Query

Here’s your adjusted query that will preserve the $owner part of the tag key instead of trying to interpolate it:

SHOW TAG VALUES FROM "exdemon-analysis" WITH KEY = "analyzed_metric.attributes.$$owner"

Why This Works

Grafana’s templating parser will replace $$ with a single literal $ when sending the query to InfluxDB. So the final query that hits your InfluxDB instance will be exactly what you need:

SHOW TAG VALUES FROM "exdemon-analysis" WITH KEY = "analyzed_metric.attributes.$owner"

This trick works for any scenario where you need a literal $ in your query without Grafana trying to substitute a variable. Just replace every single $ you want to keep with $$.

内容的提问来源于stack exchange,提问作者DLanza

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 03:42:11