嵌套grafana——–开启匿名登录

发布于 2025-11-02 阅读 52 分类:技术文章
allow_embedding = true 是 Grafana 配置选项,用于允许通过 iframe嵌入内容。以下是具体配置方法和注意事项:

配置步骤

修改配置文件‌:找到 Grafana 的配置文件(通常为 grafana.ini),进入 [security] 配置块,将 allow_embedding 设置为 true。 ‌

text
Copy Code
[security]  
allow_embedding = true  


匿名访问设置‌:若需匿名用户通过 iframe 访问,需同时配置匿名登录。在 [auth.anonymous] 配置块中设置:

text
Copy Code
[auth.anonymous]  
enabled = true  
org_name = Main Org.  
org_role = Viewer  


匿名用户将默认以 Viewer 角色访问指定组织(如 Main Org.)。 ‌

重启服务‌:修改配置后,需重启 Grafana 服务使配置生效(如使用 systemctl restart grafana-server)。 ‌‌

注意事项
权限控制‌:匿名用户仅能查看数据,无法进行编辑或删除操作。 ‌
跨域访问‌:若嵌入到其他域名,需在配置中添加跨域访问权限(如设置 x_frame_options 为 "allow-from *")。 ‌‌
隐藏版本号‌:可通过 hide_version = false 避免显示 Grafana 版本信息。 ‌‌