gnocchi API response 401 unauthorised

1000 views Asked by At

I have prepaired Gnocchi by documentation at https://gnocchi.xyz/stable_4.2/rest.html. I am using Keystone, but I am not able to make a request.

Sample:

GET http://<serverIP>:8041/v1/metric/0b5aa633-3ebf-49d5-99ad-e78302c41376 HTTP/1.1

Response:

date: Fri, 30 Mar 2018 20:24:26 GMT
server: Apache/2.4.18 (Ubuntu)
www-authenticate: Keystone uri='http://127.0.0.1/identity'
content-length: 114
connection: close
content-type: application/json

{
    "error": {
    "message": "The request you have made requires authentication.",
    "code": 401,
    "title": "Unauthorized"
    }
}

I have OpenStack Queens installed by DevStack script on my Ubuntu 16.

I have only admin credentials, how can i get X-Auth-Token required?

2

There are 2 answers

0
M. Pav On

Get token by using Openstack CLI:

openstack token issue

Output:

+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field      | Value                                                                                                                                                                                   |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires    | 2018-04-11T16:48:58+0000                                                                                                                                                                |
| id         | gAAAAABazi5qBuJ27ZJ_F_EbtE3kKTheImVW1nrazoB6_LKumLeRnacwavmmLdTThVLENQ0Idj4vm-L1OG1xnjvuRwqOQq1lFpSDP8N_Cazb-QGEIIgMaqflp9Z_NaScKkekrHmddnzRNM1-LHRHoAi5WMwMO2Yyf8CjR8331ME1G6KY1SHzGWo |
| project_id | 97335134c06949fea2caebb0c5baa11a                                                                                                                                                        |
| user_id    | 35b0022e29ee4e5588fca36d30e95afb                                                                                                                                                        |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

It is necessary to use X-Auth-Token header in request.

X-Auth-Token:   gAAAAABazi5qBuJ27ZJ_F_EbtE3kKTheImVW1nrazoB6_LKumLeRnacwavmmLdTThVLENQ0Idj4vm-L1OG1xnjvuRwqOQq1lFpSDP8N_Cazb-QGEIIgMaqflp9Z_NaScKkekrHmddnzRNM1-LHRHoAi5WMwMO2Yyf8CjR8331ME1G6KY1SHzGWo
0
mufty__py On

I already got the solution, I was about to post it..

Basically, after the gnocchi is installed on openstack, either real openstack or devstack, The gnocchi needs to be enabled and authenticated correctly,

The problem before was i was only authenticating the openstack admin, I need to autenticate gnocchi as seperate admin the the real openstack admin,

so here is what i did,

I kinda created a gnocchi-openrc with this

> export OS_PROJECT_DOMAIN_NAME=Default export
> OS_USER_DOMAIN_NAME=Default export OS_PROJECT_NAME=service export
> OS_USERNAME=gnocchi export OS_PASSWORD=********** export
> OS_AUTH_URL=http://20.3.39.13/identity/v3 export
> OS_IDENTITY_API_VERSION=3 export OS_IMAGE_API_VERSION=2 export
> OS_AUTH_TYPE=password

Then makes it permanent

sudo openstack role add --project service --user gnocchi admin

Then I tried to upgrade ceilometer with this

ceilometer-upgrade,

If there is no error with the ceilometer upgrade, then

We can now source the openstack admin rc file,

source admin-openrc.sh

The gnocchi will be enabled, and the metrics can then be exposed to OSM, Promethus and graffana then works automatically

I followed the problem here https://ask.openstack.org/en/question/110863/gnocchi-keystone-unable-to-validate-token/

https://bugzilla.redhat.com/show_bug.cgi?id=1434345 if there is error with ceilometer upgrade