Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need documentation for --labels #1991

Closed
slater0013 opened this issue Apr 25, 2023 · 4 comments · Fixed by #2032
Closed

Need documentation for --labels #1991

slater0013 opened this issue Apr 25, 2023 · 4 comments · Fixed by #2032
Labels
feature New feature or request

Comments

@slater0013
Copy link

Is your feature request related to a problem? Please describe.
--labels is included in grafana cmd tool but not (yet) documented on the new documentation website

Describe the solution you'd like
Is it related to "multi-tenancy" as described here ? https://github.com/NetApp/harvest/wiki/FAQ#harvest-authentication-and-permissions

Additional context
We would like to offer a multi organization Grafana server. Each organization have access to specific dashboards restricted to one specific SVM.

We used to create Orgs/Users/Datasources and restricted dashboards with Harvest 1.6 via Grafana API ! My goal here would be to use the grafana cmd tool to import specific dashboards (with --directory parameter) to a specific Organization (with --token parameter) with an organization specific datasource (with --datasource parameter)

Last interrogation is how to restrict the dashboard variables values to a specific SVM and could --labels parameter help ?

Thanks,
GS.

@slater0013 slater0013 added the feature New feature or request label Apr 25, 2023
@cgrinds
Copy link
Collaborator

cgrinds commented Apr 25, 2023

hi @slater0013

You're right, we can document this arg better. Let me describe it first and then we can talk about the multi-org Grafana server part second.

The grafana import --labels goes hand in hand with a poller's Labels section described here that offers a way to add additional key-value pairs to a poller's metrics.

the CLI args for bin/grafana import describe the argument like so:

bin/harvest grafana import --help

Truncated output

Flags:
  -a, --addr string           Address of Grafana server (IP, FQDN or hostname) (default "http://127.0.0.1:3000")
      --config string         harvest config file path (default "./harvest.yml")
  -s, --datasource string     Grafana datasource for the dashboards (default "Prometheus")
  -d, --directory string      When importing, import dashboards from this local directory.
                              When exporting, local directory to write dashboards to
  -h, --help                  help for import
  -S, --https                 Use HTTPS
  -k, --insecure              Allow insecure server connections when using SSL
      --labels strings        For each label, create a variable and add as chained query to other variables

When you run bin/harvest grafana import, you may optionally pass a set of labels like so:

bin/harvest grafana import --labels org --labels dept

This causes Harvest on dashboard import to:

  1. Parse each dashboard, and add a new variable for each label passed on the cmd line
  2. Modify existing dashboard variables to use the new label variable(s) in a chained query.

Here's an example:

bin/harvest grafana import --labels "org,dept"

Adds the Org and Dept variables like so and modifies the existing variables as shown here.

Results in

image

We used to create Orgs/Users/Datasources and restricted dashboards with Harvest 1.6 via Grafana API

If you had something that worked earlier, we should be able to help you find a solution for Harvest 2 also.

@slater0013
Copy link
Author

Ok ! I understand It better now ! Thanks for the explanation ! Could be interesting to create a multi-tenant based on clusters.

My previous workflow coded in Netapp Workflow Automation was to create for each "client" :

  • An org. in Grafana
  • A datasource (since each org. have to configure his own datasource)
  • A user account with the Viewer role in the freshly created org.
  • An apikey for the org.

Last action was to modify json dashboards on-the-fly (by changing SVM variable with a fixed value and not a query anymore) and import them into the Org using the apikey.

Result : client "ABC" have access to Grafana with "ABC" account and is able to browse a few dashboards filtered to his own SVM.

I know that "clever" users could use the Grafana API to get rid of the dashbaords variable filtering but this is acceptable in our context.

Regards,
GS

@slater0013
Copy link
Author

@cgrinds would you prefer another issue/case so we can talk about multi-tenancy ?

@cgrinds
Copy link
Collaborator

cgrinds commented May 2, 2023

Let's discuss it in #2030 and I'm going to leave this issue open until I get a chance to update the docs with the detail in #1991 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants