Installing grafana and it is failing with resource_management.core.exceptions.Fail: Ambari Metrics Grafana data source creation failed. POST request status: 401 Unauthorized

  • 0

Installing grafana and it is failing with resource_management.core.exceptions.Fail: Ambari Metrics Grafana data source creation failed. POST request status: 401 Unauthorized

Category : Ambari

When we do fresh install for grafana in ambari 2.4 and when you start it then it may be fail with following error.

stderr:   /var/lib/ambari-agent/data/errors-14517.txt

Traceback (most recent call last):
  File "/var/lib/ambari-agent/cache/common-services/AMBARI_METRICS/0.1.0/package/scripts/
metrics_grafana.py", line 67, in <module>
    AmsGrafana().execute()
  File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/script.py", 
line 280, in execute method(env)
  File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/script.py",
 line 725, in restart self.start(env)
  File "/var/lib/ambari-agent/cache/common-services/AMBARI_METRICS/0.1.0/package/scripts/
metrics_grafana.py", line 49, in start   create_ams_datasource()
  File "/var/lib/ambari-agent/cache/common-services/AMBARI_METRICS/0.1.0/package/scripts
/metrics_grafana_util.py", line 261, in create_ams_datasource
    (response.status, response.reason, data))
resource_management.core.exceptions.Fail: Ambari Metrics Grafana data source creation failed. 
POST request status: 401 Unauthorized {"message":"Invalid username or password"}

Root Cause: It could be because first time it use default username and password (i.e admin, admin) 
and you may be used wrong username & password or something went wrong during installation. 

Resolutions: Grafana username and password is stored in a sqlite3 database. One of the way is to
reset the password back to admin first and then can be changed in Grafana Dashboard. To do the same, 
following steps could be used:

1. Logon to the node where Grafana is installed and invoke Grafana sqlite3 database as follows and 
sudo to ams user.

[s0998dnz@server1 ~]$ sudo su – ams

Last login: Thu Nov 24 04:11:25 EST 2016

[ams@server1 ~]$ sqlite3 /var/lib/ambari-metrics-grafana/grafana.db

SQLite version 3.6.20

Enter “.help” for instructions

Enter SQL statements terminated with a “;”

sqlite> select salt, password from user;

GZtvpYh3e0|56053ec1580b26a14b339f3c95c1e51117f7ce730c5400955c0288c650deba14a3dbeb70ba4a65464d822a9fa47fc7f7c6ba

sqlite> update user set password = ’59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6′, salt = ‘F3FAxVm33R’ where login = ‘admin’;

sqlite> .exit

2. Once done, edit Ambari Metrics Server-Configs and update Grafana Password to admin

3. Restart the Ambari Metrics Server

4. Access Grafana page using the Quick Links under Ambari Metric Server Dashboard

5. Click on the Grafana Symbol in the top left corner of the screen and Sign-in as admin user


Leave a Reply