Wednesday, October 30, 2013

Graphite Logins, part of the story

There seems to be a lack of information, or rather, a disconnect of information regarding graphite and graphite logins. 

The problem, seems to me, is that graphite indicates that it has it's own logins, but doesn't seem to give the ability to create them. During installation, you do indeed create one superuser, and you can indeed log in with it, but, how do you create more logins for anyone other than the admin?

Enter Django. I knew graphite was built on top of Django, however, having no prior experience with Django, I had no idea how they were coupled and what Django brought to the table. Well it turns out that graphite, being a Django app, has an admin panel. You can find the panel located at:
http://www.example.com/graphite/admin/
or some variation on the above URL. The key part is the suffix of /admin/. To get into this panel for the first time, you can use the superuser you created at graphite installation time. From here it's just a few simple clicks to add groups and users. It's also give you handy access to saved dashboards in case you want to hand modify them.

If you've forgotten the master user/pass you created at installation time, no worries, we can create a new one. For this, though, we'll need to reach for the command line (If there is another way of doing this please let me know). First we need to locate the Django management script called manage.py. I'm not going to presume to know how you installed graphite, you could have installed it from source, or like me, from a repo. What I did was run the command:
locate manage.py
and picked out the manage.py that pertained to graphite. In my case:
/usr/lib/python2.6/site-packages/graphite/manage.py
 If you followed the default installation guide from the graphite docs it might be located at
/opt/graphite/webapp/graphite/manage.py
Now that we've found the correct manage.py we can go ahead and create a superuser via the command:
manage.py createsuperuser 
This will prompt you for username, email, and password. Once you are done, you'll have a new superuser that you can use to log into the graphite admin panel outlined above.


Further Reading:
The Django project has loads of good documentation and the most relevant to this post is the Django Authentication System where you can find out about creating users via the Python API, and a whole lot more.

No comments:

Post a Comment