仅使用一个特定变量授予对仪表板的访问权限 [英] Grant access to dashboard with only one specific variable

查看:49
本文介绍了仅使用一个特定变量授予对仪表板的访问权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I got a dashboard, which contains some variables (in this case: category and URLs):

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

现在,我希望允许用户查看特定URL的度量.目前, group 字段显示所有URL,并且用户可以看到所有URL的列表,无论是否应该看到它(当然,这是因为查询使用KEY = \"group \" WHERE \"category \" =〜/$ category/显示标签值返回所有条目).

Now I'd like to allow users to see measurements of specific urls. At the moment, the field group shows all URLs and the user can see a list of all urls, no matter if he is supposed to see it or not (of course, this is because the query SHOW TAG VALUES WITH KEY = \"group\" WHERE \"category\" =~ /$category/ returns all entries).

因此,我想获得一些最佳实践来解决此问题.不幸的是,文档并没有帮助我:-(

So I'd like to get some best practices to solve this issue. Unfortunately the docs did not help me out :-(

推荐答案

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

Grafana does not provide such functionality. The way we implement such cases is to configure user access per entity in some datasource (e.g. SQL) and then query it to show the user specific category/url/etc.

可以基于用户的电子邮件/登录名/id来进行此配置,您可以抓取"仅在Grafana v7.1 +中作为变量:

This configuration could be made based on user's email/login/id, which you can "grab" as a variable only in Grafana v7.1+:

  • $ {____ user.id}是当前用户的ID
  • $ {____ user.login}是当前用户的登录句柄
  • $ {__ user.email}是当前用户的电子邮件

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

这篇关于仅使用一个特定变量授予对仪表板的访问权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆