Looking for the Perfect Dashboard: InfluxDB, Telegraf, and Grafana – Part XXII (Monitoring Cloudflare, include beautiful Maps)

Greetings friends, since 2016 I have been showing you how to get the Perfect Dashboard using Grafana, InfluxDB, and Telegraf, we have come a long way together, and we have seen how to monitor a myriad of critical components, such as SSL, web page responses, VMware vSphere, Veeam, and much, much more.

Today we return to the basics, exploring some of the more visually appealing plugins, and giving it a more personal touch, how it is to analyze Cloudflare’s statistics where we have our blog, personal website, e-commerce, etc. cached.

Note: There are some limitations with the Cloudflare RESTful API:

  • It doesn’t always give us the answer with the date we indicate
  • From May it will be legacy, but for now, it serves us
  • With the Free version, we can only consult in ranges of Last 24 hours, Last Week, and Last Month

Once you have finished this tutorial, you will have something similar to this, it is better to give it several days or weeks to see the full potential:

Telegraf, InfluxDB and Grafana topology monitoring Cloudflare

Although I have already shown you on some occasions the diagram of how the monitoring would be using Telegraf, Grafana, and InfluxDB, I leave you again the diagram, this time monitoring Cloudflare:

Download and configure the script cloudflare-analytics.sh

Let’s download the script that will make all this work, we will download the latest version from the Github repository:

This shell script can be downloaded and run from the telegraf server, or influxDB, or any other Linux. We will have to edit the configuration parameters:

We need two pieces of information from Cloudflare that we can find as follows.

Generate a new Cloudflare API Key

Inside Cloudflare, we will go to the top menu, click on our account:

Once there, we’ll go to API Tokens – Create Token: We’ll have to grant the following privileges to this token, so it can read the metrics, but nothing else, making it much safer:

With this, we’ll have our API Key.

Find our Cloudflare Zone ID

To find the Cloudflare Zone ID, from our panel, we’ll select the domain we want and from there if we scroll, we’ll see the Zone ID:

We already have our Zone ID too.

We will make the script executable with this simple step:

We will make sure we have jq installed, an apt-get install jq or yum install jq if we use CentOS:

And when we launch it, if everything went well, we’ll see what happens next:

Besides, it would be nice to put it in the cron to run every day at 9 a.m:

That’s it, we’re going to the next step.

Grafana Worldmap Panel

We will need to have installed the magnificent Worldmap Panel, as simple as from the Grafana server launch:

And restart Grafana’s service:

And you’re all set.

Grafana Dashboards

I created a Dashboard from scratch by selecting the best requests to the database, finishing off colors, thinking about graphics, and how to display them, and everything is automated so that it fits our environment without any problem and without having to edit anything manually. The Dashboard can be found here, once imported, you will see all the stats:

Import Grafana Dashboards easily

So that you don’t have to waste hours configuring a new Dashboard, and ingesting and debugging you want, I have already created four wonderful Dashboards with everything you need to monitor our environment in a very simple way, you will be like the image I showed you above.Select the name you want and enter the ID: 12167, which is the unique ID of the Dashboard, or the URL:

We’ll have everything popping up without any problem:

That’s all folks, if you want to follow the full Blog series about Grafana, InfluxDB, Telegraf, please click on the next links:

Author: jorgeuk

Father, writing in https://www.jorgedelacruz.es and https://jorgedelacruz.uk Blogger, Systems Engineer @veeam - vExpert 2014/2020 & NTC 2018/19

2 Thoughts

  1. As a heads up, your .sh file has the incorrect filename. You’re missing the second “L” in cloudflare-analytics.sh

  2. I’m getting an error after trying to load the Grafana dashboard:

    Failed create dashboard model
    undefined is not iterable (cannot read property Symbol(Symbol.iterator))

    Any idea what this is?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.