最近一直在搞grafana相关的内容,尝试将嵌入的grafana放入到自己项目中,其中涉及到了登录相关的事情,于是,在grafana 中开启 auth.anonymous 过程遇到的一些问题,再次记录一下
要为匿名用户设置登录,您需要在defult.ini / grafana.ini文件(Grafana \ conf)中进行这些小配置。
- 如果要隐藏登录页面,请执行此配置
[auth]
# Set to true to disable (hide) the login form, useful if you use OAuth
#disable_login_form = false
disable_login_form = true
更改disable_login_form到true
- 启用匿名访问
[auth.anonymous]
# enable anonymous access
enabled = true
3.指定组织
# specify organization name that should be used for unauthenticated users
org_name = YOUR_ORG_NAME_HERE
我是在这儿遇到的坑, 因为自定义的组织名称没有在项目中定义, 所以开始匿名登录之后一直需要登录
最后通过查看日志log文件看到有这么一句话,
msg="Anonymous access organization error: 'My org.': Organization not found"
原来是组织名称没有定义 ,
解决方案:
使用admin登录进去之后,修改了组织的名称, 保存,就OK了
- 重新启动grafana,你应该能够看到grafana(如果你没有看到dasboard,只需将你的组织角色Viewer改为Editor
# specify role for unauthenticated users
org_role = Editor
最后还要说一点,使用Google搜索,查到结果的优先级: 英文关键字 >> 中文关键字
参考链接:
How to setup Grafana so that no password is necessary to view dashboards