简体   繁体   English

如何将用户和团队导入 grafana?

[英]How can I import users and teams to grafana?

I am provisioning grafana and running it without a database.我正在配置 grafana 并在没有数据库的情况下运行它。 I am using Terraform and Helm to do this.我正在使用 Terraform 和 Helm 来做到这一点。 I already know that I can store my dashboard files, put them in the values.yaml file for the grafana helm chart, and provision them that way.我已经知道我可以存储我的仪表板文件,将它们放在 grafana helm chart 的 values.yaml 文件中,并以这种方式配置它们。

It's good that the dashboards persist between releases, but users and teams do not.仪表板在版本之间持续存在很好,但用户和团队不会。 I cannot find where I can upload or store some sort of JSON file containing this information.我找不到可以上传或存储包含此信息的某种 JSON 文件的位置。

For more information, I am using Google Oauth.有关更多信息,我正在使用 Google Oauth。

How can I provision users and teams' information?如何供应用户和团队的信息? This does not have to be helm specific.这不必是特定于掌舵的。 If it's some sort of volume-mount thing, that would work too.如果它是某种卷挂载的东西,那也行。

We just use the Grafana API via Ansible (using uri module), maybe it helps you or pushes you in the right direction.我们只是通过 Ansible(使用 uri 模块)使用Grafana API ,也许它可以帮助您或将您推向正确的方向。

- name: create users
  uri:
    url: "https://{{ grafana_url }}/api/admin/users"
    user: admin
    password: "{{ admin_password }}"
    force_basic_auth: yes
    method: POST
    headers:
      Accept: application/json
      Content-Type: application/json
    body:
      name: "{{ item.name }}"
      email: "{{ item.email }}"
      login: "{{ item.email }}"
      password: "{{ pass }}"
    body_format: json
  with_items: "{{ admin_list }}"

Then the list is a simple yaml.那么列表就是一个简单的yaml。

admin_list:
  - name: "Mrs. X"
    login: "x@gmail.com"
  - name: "Ms. Y"
    login: "y@gmail.com"

And on a second note, you can define users in Terraform (never used it myself).其次,您可以在 Terraform 中定义用户(我自己从未使用过)。

resource "grafana_organization" "org" {
    name         = "Grafana Organization"
    admin_user   = "admin"
    create_users = true
    admins       = [
        "admin@example.com"
    ]
    editors      = [
        "editor-01@example.com",
        "editor-02@example.com"
    ]
    viewers      = [
        "viewer-01@example.com",
        "viewer-02@example.com"
    ]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM