Installing Grafana and connecting with a Postgres database
Create dashboards in Grafana using your Postgres database without any hassle
Grafana is a cutting-edge tool when it comes to monitoring your server, service, or database. It connects out-of-the-box with several data sources, it’s easily configurable even for novice users and surprisingly, it’s open-source so you can get in on the action for free if you want.
Postgres is one of the world’s most used databases, also open-source, free and provides great performance with scalability and support from the community. Those are some of the reasons why Postgres can be a great data source for your Grafana project, and this post shows in a very quick and objective way how you can connect those great tools to create a dashboard to visualize your data.
Obs: if you don’t have the need for a Grafana server in-house, check out a solution called Grafana Cloud, free for:
- 3 users
- 10k active metrics
- 50GB logs
- 14-day log retention
Getting right down to it, here’s how you connect your Postgres database in your instance of the Grafana Server:
First, download Grafana here and install it in your SO of choice. I’m going with Windows for this one.
The installation’s pretty straightforward, just hit Next and Finish all the way until it’s done. After that, type:
in your web browser of choice, and use login admin and password admin to access Grafana for the first time. Please remember to change that as soon as you’re able to login for the first time.
If all goes well, you’ll get this welcome screen:
Now for the magic part, click on “Add your first data source” and you’ll see a long list of data sources already implemented. Just type “Postgres” or scroll down until the end of the page to find it.
On the page that comes next, fill out your database info, like this:
If clicking on Save & Test you get a message like this:
Then you’re good to go.
Now it’s up to you to create your dashboards using the data sources you just added. When it’s time to create a “panel” as the visualizations are called on Grafana, you’ll see the data sources this way:
Now you can use your imagination and create the best possible visualizations be it to monitor your logs or doing anything else. A friendly reminder, though: Grafana may not be the best tool for visualization in general. There are better options for graphical representation of more common types of data, so try using R, Power BI and Tableau, for instance.
I don’t have any event log databases available right now, but you can easily draw some visualizations for other types of data such as this dashboard I built with information from countries and cities from all over the world.
Check out my dashboard here:
If you're seeing this Grafana has failed to load its application files 1. This could be caused by your reverse proxy…
Bonus tip: You can find here some sample Postgres DBs such as the one I used here on the following link: https://github.com/morenoh149/postgresDBSamples