Grafana 103: Customizing Login Screen for Grafana ! Playing with white- labels and many more ..

Grafana-103

Mohit Shrestha
5 min readApr 21, 2020

Hello Tech Maniacs ,

So till now , if you are with me on this Grafana series , then you must be able to install Grafana right from the scratch and able to create dashboards . Now lets go a step ahead and try to make this Grafana , “Your Own Grafana” . Well I mean, what if we can change the login screen, push the background image whatever we want, change the Main Title in every page and use our own company name instead , change the grafana logo and use our company logo instead. Yes , it would look like as in , we are not using Grafana anymore, rather we are using our Enterprise specific Grafana.

Well the Grafana login screen looks like this as of now :

So basically , what all can we customize to make this login page look our own , is the following :

→ Favicon

→ Main Title

→ Grafana Logo

→ Logo Wordmark

→ Background Image

So follow with me and find out how to do it , step by step . Before that, a important note if you are following me from my previous blogs ..

If you have installed grafana directly on your linux then you can skip this part, but if you are using docker then here is a important point to note. In my last blog we have installed grafana using alpine image and hence it wont provide the compatibility to install or change anything by your Grafana user, the default user by which the grafana docker will login is Grafana user (user id 472). Hence please dont forget to use the ubuntu image only if you want to customize the things out or install anything inside your docker, which is important for this demo . And the command goes like this

docker run -itd -p 3000:3000 grafana/grafana:latest-ubuntu 

HOW THINGS WILL WORK :

Now since we have our Grafana container running on port 3000 using the Grafana ubuntu image . Its time to land into the container and make the necessary changes at different location . As told before, if you exec directly inside your container direclty, it will default login with the Grafana user . So while exec in ,use the root user explicitly , as an option to login with the Root

docker exec -it -u root <container id> /bin/bash
root@c33b2283013e:/usr/share/grafana# id
uid=0(root) gid=0(root) groups=0(root)

Now since you are logged in with root , time to make our necessary changes .

IMPORTANT POINT:

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — Location /usr/share/grafana/public/img contains all the images including our {Favicon , grafana logo , background image,grafana-logo-wordmark} by the names {fav32.png , grafana_icon.svg , heatmap_bg_test.svg,grafana_typelogo.svg } respectively. You can directly drop your own images here and make the login page look yours. But I got a no. of complaints from the users that the changes took place properly in their localhost /server but when a remote user tried to access the same Grafana page, they can’t see these changes happening. So to avoid these bugs follow me in this blog . — — — — — — — — — — — — — — — — — — — — —

HERE WE GO STEP BY STEP :

  1. First save all your images (Favicon , grafana logo , background image, Logo wordmark ) at a remote location in the cloud , in my case I am saving it on AWS S3 and being public ally accessible .
  2. Once I saved it on AWS S3 , all my images will generate a unique url to access it anywhere on the internet , please keep all those urls handy .
  3. Changing Favicon and Title :

Go to /usr/share/grafana/public/views/index.html and change as stated

Change title by replacing [[.AppTitle]] and Paste your Favicon public url , in my case its aws s3 public url which I pasted here in place of [[.Favicon]] and after the change it looks like
Replaced Title by our company name and replcaed favicon by our favicon public url, In our case its aws s3 public url

So by now our Favicon and Title is successfully changed.

4. Changing Grafana-Logo and Background image :

Go to /usr/share/grafana/public/build/ and search for the file app.****.js

ls|grep app.****.js

and then search for the keyword “heatmap_bg_test.svg” and “grafana_icon.svg” in this file, whatever places you find this keyword in the file replace the complete “src” & “url” with your own “public url” of your background image and the grafana_icon. The file looks quite messy if you open it with vim editor !

grafana_icon.svg might be at several places in this file , dont forget to replace your url at every place

5. Changing Grafana-Logo-Wordmark :

Go to /usr/share/grafana/public/build/ and search for the file grafana.dark.****.css

ls|grep grafana.dark.****.css

and then search for the keyword “grafana_typelogo.svg” and replace the complete url by your own aws s3 logo word mark url ! Then restart your docker /server and kaboom ! The customized results looks awesome!

Our customized login screen looks like this now →

Grafana login screen looks like ours ! Favicon , title , logos , background everything changes and customized just like the way we want !

BONUS CUSTOMIZATION :

If you want to change the title in every screen , after you login to Grafana as well. Then go to /usr/share/grafana/public/build/DashboardPage.****.js and search for the keyword “document.title” and then change it like this document.title=r.title+” — <company name or anything you want >”.

Hope you liked this blog ! Follow me on this Grafana series to explore more about the service and if you are unaware about my last two blogs in this series then here are the links ! FYI , the next blog in the series will be on “AuthProxy” so stay tuned for that and many more awesome blogs !

Link to my blog Grafana-101 : https://medium.com/@mohitshrestha02/grafana-101-what-is-grafana-installing-grafana-on-linux-and-docker-744244084bd7Link to my blog Grafana-102 : https://medium.com/@mohitshrestha02/grafana-102-creating-our-first-dashboard-with-grafana-d0a49425f977

Cheers !

--

--