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

如何对Grafana表格图表的链接进行HTML格式化?解决可用性问题

Absolutely! You can spruce up those table links in Grafana with HTML formatting so they’re obvious at a glance, not just when someone hovers over them. Here’s how to pull it off:

Step 1: Enable HTML Rendering in the Table Panel

First, you need to let Grafana render HTML instead of escaping it:

  • Open your table panel’s edit mode.
  • Switch to the Options tab.
  • Look for the Sanitize HTML setting and uncheck it (this is critical—if it’s checked, your HTML will get turned into plain text).

Next, modify your link column’s configuration to use a styled <a> tag:

  • Go to the Fields tab in the panel editor.
  • Find the column you’ve set up as a link.
  • In the Link section, instead of just entering a URL, use an HTML anchor tag with inline styles. For example:
    <a href="${__value}" style="color: #2196F3; text-decoration: underline; font-weight: 600;">${__value_text}</a>
    
    • ${__value} pulls in the actual URL from your data.
    • ${__value_text} uses the display text you’ve set for the column.
    • Tweak the style attributes to match your needs—adjust color, add underlines, make text bold, or whatever makes the links stand out in your dashboard.

Alternative: Return HTML Directly from Your Data Source

If you’re pulling data from a SQL database or similar, you can also build the styled link directly in your query. For example, in a PostgreSQL query:

SELECT
  id,
  CONCAT('<a href="https://your-app.com/details/', id, '" style="color: #2196F3; text-decoration: underline;">', name, '</a>') AS details_link
FROM your_table;

Then, in Grafana’s Fields tab for that column, set the Type to Text (not Link) and ensure HTML rendering is enabled (as in Step 1).

Important Note

Disabling Sanitize HTML means Grafana will render any HTML in your data. Make sure the content coming into this column is trusted—avoid user-generated content here to prevent potential XSS vulnerabilities.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 09:24:46