微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

仅使用一个特定变量授予对仪表板的访问权限

如何解决仅使用一个特定变量授予对仪表板的访问权限

我有一个仪表板,其中包含一些变量(在本例中:类别和 URL):

{
  "templating": {
    "list": [
      {
        "allValue": null,"current": {
          "selected": false,"text": "default","value": "default"
        },"datasource": "Influx-SP","deFinition": "","error": null,"hide": 0,"includeAll": false,"label": null,"multi": false,"name": "category","options": [],"query": "SHOW TAG VALUES WITH KEY = \"category\"","refresh": 1,"regex": "","skipUrlSync": false,"sort": 0,"tagValuesQuery": "","tags": [],"tagsQuery": "","type": "query","useTags": false
      },{
        "allValue": null,"label": "group","name": "group","query": "SHOW TAG VALUES WITH KEY = \"group\" WHERE \"category\" =~ /$category/","text": "_","value": "_"
        },"name": "page","query": "SHOW TAG VALUES WITH KEY = \"page\" WHERE \"group\" =~ /$group/ AND \"category\" =~ /$category/","text": "chrome","value": "chrome"
        },"name": "browser","query": "SHOW TAG VALUES WITH KEY = \"browser\" WHERE \"group\" =~ /$group/ AND \"page\"  =~ /$page/ AND \"category\" =~ /$category/","text": "native","value": "native"
        },"name": "connectivity","query": "SHOW TAG VALUES WITH KEY = \"connectivity\" WHERE \"group\" =~ /$group/ AND \"page\"  =~ /$page/ AND \"browser\" =~ /$browser/ AND \"category\" =~ /$category/","useTags": false
      }
    ]
  }
}

现在我想允许用户查看特定网址的测量值。目前,字段 group 显示所有 URL,用户可以看到所有 URL 的列表,无论他是否应该看到它(当然,这是因为查询 SHOW TAG VALUES WITH KEY = \"group\" WHERE \"category\" =~ /$category/ 返回所有条目)。

所以我想获得一些最佳实践来解决这个问题。不幸的是,文档没有帮助我:-(

解决方法

Grafana 不提供此类功能。 我们实现这种情况的方法是在某些数据源(例如 SQL)中为每个实体配置用户访问权限,然后查询它以显示用户特定的类别/url/等。

可以根据用户的电子邮件/登录名/ID 进行此配置,您只能在 Grafana v7.1+ 中将其“抓取”为变量:

  • ${__user.id} 是当前用户的 ID
  • ${__user.login} 是当前用户的登录句柄
  • ${__user.email} 是当前用户的邮箱

参考: https://grafana.com/docs/grafana/latest/variables/variable-types/global-variables/#__user

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。