首页 > 解决方案 > Grafana:更改现有用户的角色

问题描述

我使用curl命令创建了几个 Grafana 用户。这是我使用的命令。

curl -XPOST -H "Content-Type: application/json" -d '{
  "name":"user1@graf.com",
  "email":"user1@graf.com",
  "password":"userpassword",
  "role": "Admin"
}' http://admin:admin@grafana01.default.svc.cluster.local:3000/api/admin/users

现在我想将角色从 更改AdminViewer。我怎样才能做到这一点?。还有其他方法可以尝试吗?任何帮助表示赞赏?

标签: prometheusgrafanagrafana-variablegrafana-api

解决方案


例如,要将角色更新为查看器,您可以执行以下操作:

curl -XPATCH -H "Content-Type: application/json" -d '{
  "role":"Viewer"
}' http://admin:admin@grafana01.default.svc.cluster.local:3000/api/orgs/:orgId/users/:userId

请务必使用正确的 orgId 和 userId

看看 https://github.com/grafana/grafana/issues/11945

编辑:我编辑了我以前的(和错误的)答案。


推荐阅读