如何设置 Grafana 以便无需密码即可查看仪表板

How to set up Grafana so that no password is necessary to view dashboards

尽管有这些设置,Grafana 仍然需要使用密码才能查看仪表板。有人可以帮我正确设置吗?

[auth.anonymous]
# enable anonymous access
enabled = true

[auth.basic]
enabled = false

我遇到了这个问题,但我的根本原因是一个小错误。 我检查了 grafana.log 文件,发现:

"2016/02/12 09:24:57 [middleware.go:62 initContextWithAnonymousUser()] [E] Anonymous access organization error: 'Anonymous Org.': Organization not found"

我更改了 grafana.ini 中的 org_name,在重新启动 Grafana 后,一切如我所愿。

我建议您检查 grafana.log 文件,看看您的配置有什么问题。

感谢@Donald Mok 的回答;我只是想让它尽可能清楚。在 Grafana 界面中,您可以创建一个组织。之后,您可以为该组织创建一些仪表板。所以,有一个问题,你需要为匿名用户指定组织。它应该是一个真正的组织(对于您的 Grafana)。匿名用户将只能看到来自该组织的仪表板。

#################################### Anonymous Auth ##########################
[auth.anonymous]
# enable anonymous access
enabled = true

# specify organization name that should be used for unauthenticated users
org_name = ORGANIZATION

首先,在grafana.ini中调整以下值:

[auth.anonymous]
# enable anonymous access
enabled = true

# specify organization name that should be used for unauthenticated users
org_name = YOUR_ORG_NAME_HERE

# specify role for unauthenticated users
org_role = SOME_USER_NAME_HERE # e.g. Anonymous

现在,在重新启动 Grafana 后,登录并确保有另一个用户不是 admin 创建的。如果没有,请创建一个。用户创建对话中的值实际上对完成任务并不重要。

最后,在 global orgs 下设置相同的组织名称以匹配您的 grafana.ini 值。另外,确保您创建的用户具有您在 grafana.ini 中设置的角色(在我的示例中,该角色为 "Anonymous")。

要为匿名用户设置登录,您需要在默认设置中进行这些小的配置更改。ini/grafana.ini 文件 (Grafana\conf)。

  1. 如果你想隐藏登录页面做这个配置:

    [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

  2. 启用匿名访问:

    [auth.anonymous]
    # enable anonymous access 
    enabled = true
    
  3. 指定组织:

    # specify organization name that should be used for unauthenticated users
    org_name = YOUR_ORG_NAME_HERE
    
  4. 重启Grafana,应该可以看到Grafana仪表盘了。如果不是,只需将您的组织角色从 Viewer 更改为 Editor:

    # specify role for unauthenticated users
    org_role = Editor
    

这是我为我的 Caddy 代理所做的,它已经使用 client-cert auth。请注意,此 still 会将您的数据源暴露给 public!请务必将 your@email.com 替换为您的电子邮件和 grafana.ini.

中的 Caddy 代理 ip

Caddyfile

grafana.****.***, gf.****.*** {
    tls your@email.com {
        clients /mnt/user/appdata/caddy/conf/ca.crt
    }

    proxy / http://10.0.1.39:3000 {
        transparent
        websocket
        insecure_skip_verify
        header_upstream X-WEBAUTH-USER "admin"
    }
}

gf-pub.****.*** {
    tls your@email.com

    proxy / http://10.0.1.39:3000 {
        transparent
        websocket
        insecure_skip_verify
        header_upstream X-WEBAUTH-USER "public"
    }
}

grafana.ini

[auth.proxy]
enabled = true
header_name = X-WEBAUTH-USER
header_property = username
enable_login_token = false
whitelist = 10.0.1.3 <-- Your Caddy IP

首先你的配置应该是这样的:

[auth.anonymous]
# enable anonymous access 
enabled = true

# specify organization name that should be used for unauthenticated users
org_name = ORGANIZATION

# specify role for unauthenticated users
org_role = Viewer

[auth]
# Set to true to disable (hide) the login form, useful if you use OAuth
disable_login_form = true

然后您需要在Grafana网站的Server Admin页面上创建一个组织,其名称与您在此处指定的名称完全相同: org_name = ORGANIZATION

如果您随后使用某些面板制作仪表板,您可以与 <iframe> 共享仪表板或特定面板,您可以找到更多信息 here