当前位置: 代码迷 >> 综合 >> vue嵌套grafana展示监控数据Refused to display ‘http://127.0.0.1:3000/login‘
  详细解决方案

vue嵌套grafana展示监控数据Refused to display ‘http://127.0.0.1:3000/login‘

热度:75   发布时间:2023-11-24 02:21:21.0

控制台报错信息:
Refused to display ‘http://127.0.0.1:3000/login’ in a frame because it set ‘X-Frame-Options’ to ‘deny’.

嵌套grafana监控dashboard,只需要在web监控iframe中嵌进去:

<iframe src="http://192.168.0.1:3000/d/oidoT24Wk/apache-jmeter?refresh=5s&orgId=1" width="450" height="200" frfameborder="0"></iframe>

直接打开,会跳转到登录页面,所以会提示上面的报错信息,也就是想这么做的话,需要开启匿名登录,修改grafana配置文件:
vim /etc/grafana/grafana.ini,Windows环境下是在conf目录下的defaults文件里面
修改为:

[auth.anonymous]
# enable anonymous access
# 去掉注释,改为true,允许匿名访问
enabled = true
# specify organization name that should be used for unauthenticated users
# 匿名用户属于的组织
org_name = Main Org.
# specify role for unauthenticated users
# 匿名用户的角色/权限
org_role = Viewer

如果提示有in a frame because it set ‘X-Frame-Options’ to ‘deny’.报错

就把下面的改为true:
allow_embedding = true

在iframe的src最后加上kiosk=tv 可以隐藏去掉grafana大盘左侧工具条

  相关解决方案