Monitoring APIs with Grafana

DreamFactory, Prometheus, Docker, and Grafana
DreamFactory, Prometheus, Docker, and Grafana
Now that we have explored monitoring apis with Prometheus, lets take a look at monitoring our APIs with Grafana. You may have noticed from the previous blog that Prometheus is awesome, but takes some time to fully flesh out and their dashboards aren’t the best. Good thing Grafana specializes in data visualization. We will not even have to configure all our Prometheus queries, so let’s get started.

Monitoring APIs with Grafana

We first need to confirm everything is running, if so your output should look similar to the above image. If you are not familiar with getting everything up and running please reference our previous blog. By navigating to 127.0.0.1:3000 you should see the Grafana home page. If you are not familiar with Grafana you may be wondering where the dashboards are. They are all located in the top left dropdown where we will see 4 pre-configured dashboards. Let’s review each of them to understand what each of them does.

Docker Host Dashboard

The Docker Host Dashboard shows metrics for monitoring the usage of the server. Thanks to dockerprom(link github repo) for pre-configuring all this we can now see:
  • Server uptime, CPU idle percent, number of CPU cores, available memory, swap and storage.
  • System load average graph, running and blocked by IO processes graph, interrupts graph.
  • CPU usage graph by mode (guest, idle, iowait, irq, nice, softirq, steal, system, user).
  • Memory usage graph by distribution (used, free, buffers, cached).
  • IO usage graph (read Bps, read Bps and IO time).
  • Network usage graph by device (inbound Bps, Outbound Bps).
  • Swap usage and activity graphs.
Monitoring APIs with Grafana

Docker Containers Dashboard

The Docker Containers Dashboard shows key metrics for monitoring running containers:
  • Total containers CPU load, memory and storage usage.
  • Running containers graph, system load graph, IO usage graph.
  • Container CPU usage graph.
  • Memory usage graph.
  • Cached memory usage graph.
  • Network inbound usage graph.
  • Container network outbound usage graph.
Monitoring APIs with Grafana

Monitor Services Dashboard

The Monitor Services Dashboard shows key metrics for monitoring the containers that make up the monitoring stack:
  • Prometheus container uptime, monitoring stack total memory usage, Prometheus local storage memory chunks and series.
  • Container CPU usage graph.
  • Memory usage graph.
  • Prometheus chunks to persist and persistence urgency graphs.
  • Chunks ops and checkpoint duration graphs.
  • Samples ingested rate, target scrapes and scrape duration graphs.
  • Alerts graph.
Monitoring APIs with Grafana

Conclusion

We now have a fully functioning monitoring tool with no code. Isn’t that awesome? A no code API tool and a no code data visualization tool, it can’t get much better than this. This post has only scratched the surface with regards to what you can accomplish with these tools. If you are interested in this for a Ruby application, check out our friends over at Scout who wrote a blog about doing exactly that. If you like what you see, sign up for a free trial today or contact us for more information!

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

Creating a Microsoft SQL Server API in Less Than 5 minutes with DreamFactory

DreamFactory and Microsoft SQL Server
DreamFactory and Microsoft SQL Server
Do you have a ton of data sources and do not know how to expose them? Do you know you need a SQL Server API but don’t know where to begin to build it? Look no further, DreamFactory can take any database and generate a fully documented and secure REST API faster than making a sandwich. All you need is your database credentials and DreamFactory will handle the rest, instantly generating Swagger documentation and securing your API by way of API keys. Follow along with the blog or our video below!

Installing DreamFactory

In order to get started you must install DreamFactory, which is Open Source and gives you the ability to try out a numerous amount of popular databases. To spin up your own hosted environment for free click here.

Generating the SQL Server API

Now the fun part. Once you have DreamFactory up and running you will be on the Admin panel. From there you will navigate to the Services tab to connect your database for your API. For example I have selected a Microsoft SQL Server database but it is nearly identical for any database you will be connecting to. Connecting your database typically only requires filling out these 5 fields as shown below.

SQL Server API

Upon saving there will be a success window pop-up saying “Service saved successfully”. What it doesn’t tell you is all the magic it just did behind the scenes. In just that short amount of time, it generated your REST API. So now if you navigate to the API Docs tab you can see your new documentation for the API and actually interact with it via the “Try it out” button.

SQL Server API

Securing and Interacting with the API

I can end it here now that you have generated your API, but where is the fun in that? Now let’s actually see the API in action! First things first, let’s generate an API key to be paired with the API for security purposes. DreamFactory does not allow access to the API without being authenticated. Let’s navigate to the Roles tab and create a Role for our API. This Role with correspond with the API key so different users can have different privileges based off different keys.

SQL Server API

For my Role I have pointed it to the SQL Server Service we just created and told it to only allow GET calls on the endpoints. This will ensure anyone using this API key will not be able to, for example delete data from the database. We must now link this Role to an API key. If we now go to the Apps tab we can create a new API key with the corresponding Role.

SQL Server API

Once we hit save we are able to see the API key generated for our use. Just to show how it works I will be using Insomnia, a popular HTTP service, to call our DreamFactory API. I will call the customers table, passing the API key in the headers for authentication.

SQL Server API

Conclusion

As you can see I have access to our new API and how much time did that take? Way less time than building this API yourself! If you would like to find out exactly how much time and money DreamFactory can save you, check out our API calculator. Otherwise what are you waiting for? Go build your next application using DreamFactory already! If you have any questions about the platform, or just APIs in general, we’d love to hear from you! Contact us.

API Calculator: Understanding the costs behind building an API-based application

Do you want to save money, deploy projects faster, and spend more time on developing application experiences that enthrall users? Then it’s practically a certainty APIs will play a critical role in your software development process. Accordingly, you’ll want to obtain a fairly accurate understanding of the cost and time required to building an API. But it’s important to understand that there’s much more to an API than just coding an interface to some data source such as a database. Whether you are planning on hiring a contractor or assign a new project to your team, an API calculator can help you understand the time and cost required to develop a mission-critical part of your next project. Continue reading “API Calculator: Understanding the costs behind building an API-based application”

Learning About The Bitnami System Database

Database Code Lines

The Elusive Bitnami System Database

If you want to spin up a fast API solution, DreamFactory is a great way to do that with a Bitnami install. Within minutes you can have a fully documented and secure REST API to utilize. Just like any program bundle, there are lots of features to learn and interact with.  Outside of a Docker Swarm or AWS ELB setup, it is pretty hard to find a way to spin up a DreamFactory instance faster. We are going to dive in a bit further to find out how to interact with the system database. Continue reading “Learning About The Bitnami System Database”