Recently I found myself in need of a simple dash-boarding solution. After looking at solutions like Geckoboard, Freeboard, and Charted, I decided to build my own. Since I work primarily with Docker containers I figured I might as well learn something about Grafana, as it is commonly used on top of monitoring tools such as Prometheus.

My requirements are pretty simple, I need:

  • To visualize realtime data against a static set of expected data.
  • To display several graphs on the same page.
  • The data to be persistent.
  • The dashboard to be available to my coworkers.
  • To be able to easily insert data both by hand and programmatically.

Based on these requirements, I need a graphing and dashboard solution (Grafana) and a persistence mechanism (MariaDB). Grafana has beta support for MySQL data stores, so you won’t want to use this setup in production. Note: I didn’t choose a more traditional timeseries DB as I wanted to try out Grafana’s support for MySQL. Additionally, I wanted to be able to easily insert data for testing and my “expected” values.

DockerHub has prebuilt Grafana and MariaDB images and a pretty decent Readme on how to get them up and running. I was able to docker run these images and get things to work. However, when I added volumes and secrets, things got more complicated. Therefore, I’ve created a public application in Yipee.io, titled GrafanaMaraidb, you can download (after creating a free account) and run which provides a fully functional installation with very little setup on your part. See the Readme in the Application Info area within Yipee.io for additional setup required to run in Docker Stack.

 

Once you download the GrafanaMariadb application and have it running, use the Adminer service (should be localhost:8080) to create a new database, a user with select only permissions, and a table with 3 columns : timestamp of type timestamp, value of type double, and metric of type varchar(20) (see the Readme for example create table). This table will hold your data. Using Adminer, you can insert some sample data. The metric column will hold the name of the metric which gets graphed. I had two metrics: expected and actual.

Next, go into Grafana (should be localhost:3000) and add a data source pointing to your MariaDB instance. I’ve added an alias in the GrafanaMariadb application for the database called ‘db’. You can use ‘db:3006’ as your MySQL host and the user and password need to match what you setup in Adminer. When you click Save, it will test the connection and show a success message.

Finally, add your dashboard in Grafana. I started with a simple graph component. To configure the graph, click the title which gives you an edit option. First set the Panel Data Source to your MySQL datasource. You will be given an example SQL query with place holders for the the column names. Just replace all those with your column names. Once you have done that, click the eye icon on the right side of the query box. You should see your data graphed above. If you don’t, you many have to adjust the time window being viewed depending on the timestamps of your data. Here is a picture of my first dashboard item with expected and actual data points.

I’m not going to walk through the rest, but the next steps would be to build a NodeJS service that queries my other data sources and inserts into the MariaDB database making my dashboard come to life. Hope you find this helpful!


Interested in learning more about Yipee.io? Sign up for free to see how Yipee.io can help your team streamline their development process.