wizzy icon indicating copy to clipboard operation
wizzy copied to clipboard

using grafana api key

Open t3h2mas opened this issue 7 years ago • 19 comments

I set up grafana w/ google login, so I'm trying to use an API key to connect wizzy to the dashboards.

I see that 'grafana:api_key' is an entry in validConfigs from config.js L:21.

EDIT: Using something like

{
  "config": {
    "grafana": {
      "url": "[URL]",
      "api_key": "[KEY]"
    }
  }
}

in the wizzy.json appeared to work. Maybe it should be a documented option.

t3h2mas avatar Jun 05 '18 14:06 t3h2mas

Thank you for bringing attention to this. Created a api key in grafana with editor role and copied the api key

To get connected I only used: wizzy set grafana url http://grafanaip:3000 wizzy set grafana api_key averylongapikey

john-arvid avatar Mar 03 '19 08:03 john-arvid

This is indeed possible, I will add the documentation

Sytten avatar Aug 09 '19 17:08 Sytten

Complementary question: I have a similar setup of Grafana w/ Google OAuth, are you able to export dashboards using api_key config? I can list and import dashboards using this configuration but I am having a difficult time exporting dashboards. Maybe I'm missing something here.

>> wizzy export dashboards                                                                                                     
Output:
{"message":"Unauthorized"}
✘ Dashboard thanos-alerts export failed.
✘ 1 dashboards export failed.
>> node -v                                                                                                                
v12.9.0
>> npm -v                                                                                                                 
6.10.3
>> wizzy version                                                                                          
0.6.0
>> wizzy conf                                                                                         
Output:
{
  "grafana": {
    "envs": {
      "tst": {
        "url": "https://grafana.tst.net",
        "api_key": "blah"
      },
      "prod": {
        "api_key": "blah",
        "url": "https://grafana.prod.net"
      }
    }
  },
  "context": {
    "grafana": "tst"
  }
}

kepai91 avatar Aug 26 '19 16:08 kepai91

Ha yes, the commands ending in s are currently broken (I will try to push a fix the repo this week). Basically the authentication is not passed correctly. You should be able to do it one by one. I am still waiting on npm permissions to push a new version though.

Sytten avatar Aug 26 '19 17:08 Sytten

Ah! Gotcha. Doing it one at a time worked. Thanks.

kepai91 avatar Aug 26 '19 17:08 kepai91

@Sytten could you point me to the documentation for token based auth? I can't find it.

I'm wondering what scopes the token needs to do various imports. In this case, the scope options are the roles viewer, editor, and admin.

dideler avatar Sep 14 '19 13:09 dideler

Tried all the scopes and this is the result.

Token scope Import dashboards Import datasources Import orgs
viewer yes (but broken*) no no
editor yes no no
admin yes yes no

* Using token auth with viewer scope does not work for import dashboards. The text Importing N dashboards: will appear but it's a no-op with no additional feedback. Switching to basic auth (user/pass) does work to import dashboards with viewer scope.

dideler avatar Sep 14 '19 13:09 dideler

@dideler Thanks for the report, we need to fix the documentation (https://github.com/grafana-wizzy/wizzy-site). If you want to do it, I would appreciate!

Sytten avatar Sep 15 '19 16:09 Sytten

Ha yes, the commands ending in s are currently broken (I will try to push a fix the repo this week). Basically the authentication is not passed correctly. You should be able to do it one by one. I am still waiting on npm permissions to push a new version though.

Did this change get pushed? I'm seeing issues with response.statusCode undefined.

jfreeland avatar Sep 16 '19 19:09 jfreeland

Its pushed on master yes, not on npm

Sytten avatar Sep 16 '19 19:09 Sytten

I think I have the latest build, but getting the below error trying to list dashboards. My Grafana instance is using generic Oauth for SSO.

[root@ip-10-0-8-250 grafana]# wizzy conf
Output:
{
  "grafana": {
    "envs": {
      "staging": {
        "url": "https://dashboard-dev.url.com",
        "api_key": "long api key"
      }
    }
  },
  "context": {
    "grafana": "staging"
  }
}
[root@ip-10-0-8-250 grafana]# wizzy list dashboards
Output:
No Grafana API response
Error: unable to verify the first certificate
✘ Dashboards list display failed

ttownsend78 avatar Oct 02 '19 15:10 ttownsend78

It seems like you have a problem with https certificates.

Sytten avatar Oct 02 '19 17:10 Sytten

Its pushed on master yes, not on npm

Will there be a new mpm release soon? It looks like there hasn't been a release in quite some time?

jfreeland avatar Oct 07 '19 01:10 jfreeland

Yeah I am caught up in a lot of stuff currently, I want to make one next weekend.

Sytten avatar Oct 07 '19 17:10 Sytten

Did you had the time to look at this? I did an install from npm and have the same issue when trying to export to grafana.

nunofernandes avatar Nov 04 '19 17:11 nunofernandes

Would love to see a new release soon.

jfreeland avatar Nov 17 '19 23:11 jfreeland

New release is out, let me know if you still have issues. I will publish an update to the documentation shortly.

Sytten avatar Nov 18 '19 04:11 Sytten

@Sytten Problem in new release -
Grafana Version - v7.0.3 wizzy version - 0.6.0

$ wizzy list dashboards                                                                                     
Output:
Grafana API response status code = 401
No error body from Grafana API.
✘ Dashboards list display failed

Tikam02 avatar Jun 18 '20 07:06 Tikam02

Hi,

Grafana Version - v7.0.5 wizzy version - 0.6.0

I confirm that it doesn't works:

$ npm install -g wizzy
$ wizzy set grafana url http://.....
$ wizzy set grafana api_key key (with admin rights)
$ wizzy import dashboards
Importing 1 dashboards:
✔ Dashboard status imported successfully.
✔ 1 dashboards imported successfully.

Only public dashboard is imported. Please note that github auth is used by default.

Best regards,

anthosz avatar Jul 09 '20 07:07 anthosz