Monitoring APIs with Prometheus

DreamFactory, Prometheus, Docker, and Grafana
DreamFactory, Prometheus, Docker, and Grafana

Have you ever wanted a quick and easy way to monitor your Docker environment? Do you want to have an API monitor with minimal configuration? Well it looks like there has never been a better time to monitor your API as there is a plethora of awesome tools out there to help us such as Prometheus and Grafana.

If you would like to follow along with this blog start by downloading DreamFactory from our github repo, or if on-prem isn’t for you try our new hosted solution for free today!

Installing DreamFactory

To spin up your Docker instance fast start by cloning our Docker repository

git clone https://github.com/dreamfactorysoftware/df-docker.git
cd df-docker

You will then want to build the image

docker-compose build

Now that it is built lets start them up

docker-compose up -d

Once you go to 127.0.0.1 in your browser, it may take some time, you will be asked to create your first admin user.

For more installation options check out our README.

SQL Server API

Monitoring with Prometheus

If we navigate to http://127.0.0.1:9090, we will now see Prometheus. It is an open-source systems monitoring and alerting toolkit. To see what is happening, you have to run queries. To help give you an idea of what is happening, lets start with a basic query to see how many containers are running.

scalar(count(container_memory_usage_bytes{image!=""}) > 0)

Shows we have 10 containers running and give us a little graph.

SQL Server API An advantage of Prometheus is alerts. To get alerts we can run:

sum(ALERTS{alertstate="firing"}) by (alertname)

This will return any active alerts that are firing letting us know if we need to take action. In my case Jenkins is down so Prometheus is able to alert me and if anything else were to go down it can be found here.

SQL Server API

There are plenty of other queries that can be ran and I highly encourage you to explore Prometheus to see its true potential. Check out Prometheus queries yourself and create your own. If you are interested in configuring this for a Ruby application, check out our friends over at Scout who wrote a blog about doing exactly that.

Conclusion

Now we have DreamFactory and Prometheus communicating. Prometheus dashboards are not that impressive for the time being, so in the next blog we will be exploring how to make Prometheus and Grafana work together to build the best dashboards. Check back often for updates and the next blog: Monitoring APIs with Grafana



Get started with DreamFactory commercial edition by starting a free on-premise trial. Or, start a hosted trial now!