• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
The Blog of Jorge de la Cruz

The Blog of Jorge de la Cruz

Everything about VMware, Veeam, InfluxData, Grafana, Zimbra, etc.

  • Home
  • VMWARE
  • VEEAM
    • Veeam Content Recap 2021
    • Veeam v11a
      • Veeam Backup and Replication v11a
    • Veeam Backup for AWS
      • Veeam Backup for AWS v4
    • Veeam Backup for Azure
      • Veeam Backup for Azure v3
    • VeeamON 2021
      • Veeam Announces Support for Red Hat Enterprise Virtualization (RHEV/KVM)
      • Veeam announces enhancements for new versions of Veeam Backup for AWS v4/Azure v3/GVP v2
      • VBO v6 – Self-Service Portal and Native Integration with Azure Archive and AWS S3 Glacier
  • Grafana
    • Part I (Installing InfluxDB, Telegraf and Grafana on Ubuntu 20.04 LTS)
    • Part VIII (Monitoring Veeam using Veeam Enterprise Manager)
    • Part XII (Native Telegraf Plugin for vSphere)
    • Part XIII – Veeam Backup for Microsoft Office 365 v4
    • Part XIV – Veeam Availability Console
    • Part XV – IPMI Monitoring of our ESXi Hosts
    • Part XVI – Performance and Advanced Security of Veeam Backup for Microsoft Office 365
    • Part XVII – Showing Dashboards on Two Monitors Using Raspberry Pi 4
    • Part XIX (Monitoring Veeam with Enterprise Manager) Shell Script
    • Part XXII (Monitoring Cloudflare, include beautiful Maps)
    • Part XXIII (Monitoring WordPress with Jetpack RESTful API)
    • Part XXIV (Monitoring Veeam Backup for Microsoft Azure)
    • Part XXV (Monitoring Power Consumption)
    • Part XXVI (Monitoring Veeam Backup for Nutanix)
    • Part XXVII (Monitoring ReFS and XFS (block-cloning and reflink)
    • Part XXVIII (Monitoring HPE StoreOnce)
    • Part XXIX (Monitoring Pi-hole)
    • Part XXXI (Monitoring Unifi Protect)
    • Part XXXII (Monitoring Veeam ONE – experimental)
    • Part XXXIII (Monitoring NetApp ONTAP)
    • Part XXXIV (Monitoring Runecast)
  • Nutanix
  • ZIMBRA
  • PRTG
  • LINUX
  • MICROSOFT

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

24th April 2020 - Written in: opensource

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: As the API has been deprecated. Cloudflare now publishes everything by GraphQL, I have corrected the whole script to make it work smoothly.

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:

  • https://raw.githubusercontent.com/jorgedlcruz/cloudflare-grafana/master/cloudflare-analytics.sh

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.

Take the Global API Key

Inside Cloudflare, we will go to the top menu, click on our account: Once there, we’ll go to API Tokens – Global API Key, view

With this, we’ll have our API Key. I have not found any other way of working for now.

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:

chmod +x cloudflare-analytics.sh

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

sudo apt-get install jq

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

HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: 53d8ecec-8611-11ea-bc44-0050569002da
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.7.10
X-Request-Id: 53d8ecec-8611-11ea-bc44-0050569002da
Date: Fri, 24 Apr 2020 07:00:00 GMT

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

crontab -e
0 9 * * * /home/oper/cloudflare-analytics.sh >> /var/log/cloudflare.log 2>&1

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:

grafana-cli plugins install grafana-worldmap-panel

And restart Grafana’s service:

service grafana-server restart

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:

  • Grafana Dashboard for Cloudflare Analytics, and Overview

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:

  • https://grafana.com/grafana/dashboards/12167/

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:

  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte I (Instalando InfluxDB, Telegraf y Grafana)
  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte II (Instalar agente Telegraf en Nodos remotos Linux)
  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte III Integración con PRTG
  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte IV (Instalar agente Telegraf en Nodos remotos Windows)
  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte V (Activar inputs específicos, Red, MySQL/MariaDB, Nginx)
  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte VI (Monitorizando Veeam)
  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte VII (Monitorizar vSphere)
  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte VIII (Monitorizando Veeam con Enterprise Manager)
  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte IX (Monitorizando Zimbra Collaboration)
  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte X (Grafana Plugins)
  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte XI
  • Looking for the Perfect Dashboard: InfluxDB, Telegraf and Grafana – Part XII (Native Telegraf Plugin for vSphere)
  • Looking for the Perfect Dashboard: InfluxDB, Telegraf and Grafana – Part XIII (Veeam Backup for Microsoft Office 365 v4)
  • Looking for the Perfect Dashboard: InfluxDB, Telegraf and Grafana – Part XIV – Veeam Availability Console
  • Looking for the Perfect Dashboard: InfluxDB, Telegraf and Grafana – Part XV (IPMI Monitoring of our ESXi Hosts)
  • Looking for Perfect Dashboard: InfluxDB, Telegraf and Grafana – Part XVI (Performance and Advanced Security of Veeam Backup for Microsoft Office 365)
  • Looking for the Perfect Dashboard: InfluxDB, Telegraf and Grafana – Part XVII (Showing Dashboards on Two Monitors Using Raspberry Pi 4)
  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte XVIII – Monitorizar temperatura y estado de Raspberry Pi 4
  • Looking for the Perfect Dashboard: InfluxDB, Telegraf and Grafana – Part XIX (Monitoring Veeam with Enterprise Manager) Shell Script
  • Looking for the perfect Dashboard: InfluxDB, Telegraf, and Grafana – Part XX (Monitoring SSL Certificates x.509)
  • En busca del Dashboard perfecto: InfluxDB, Telegraf y Grafana – Parte XXI (Monitorizando HTTP Responses)
  • Looking for the Perfect Dashboard: InfluxDB, Telegraf, and Grafana – Part XXII (Monitoring Cloudflare, include beautiful Maps)

Filed Under: opensource Tagged With: blog cloudflare, blog stats, grafana, grafana cloudflare, grafana worldmap, influxdb grafana

Reader Interactions

Comments

  1. Michael Fitz says

    10th May 2020 at 4:02 am

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

  2. Michael Fitz says

    10th May 2020 at 4:11 am

    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?

  3. Rubens says

    11th March 2021 at 7:37 am

    is this still working? its not storing data for me anymore…

  4. jorgeuk says

    11th March 2021 at 9:51 am

    Hello, let me try, that API was EOL, so not sure if they removed it, they want you to pay 🙁

  5. Rubens says

    11th March 2021 at 10:10 am

    have it working since a couple of weeks, dunno if its a db problem on my side cause requests seems to work just fine…

  6. fsennj46e7ed4363 says

    23rd May 2021 at 2:44 pm

    sudo sh cloudflare-analytics.sh
    cloudflare-analytics.sh: 38: let: not found
    date: invalid date ‘@’
    cloudflare-analytics.sh: 111: declare: not found
    jq: error (at :1): Cannot iterate over null (null)

  7. jorgeuk says

    23rd May 2021 at 3:53 pm

    Hello,
    Are you using the latest script? And which OS you running? Can you try ./ instead of sh?

  8. Franz Senn says

    23rd May 2021 at 7:22 pm

    Hi Jorge – thank you with ./ it worked just fine, Just a general question if dont state a zone ID in the script would it be possible then to pick all data from all zones i have in Cloudflare?

    – also generally spoken thank you for your fantastic work! your instructions saved me many days of trial and error and keep inspiring me to try out new things…

  9. jorgeuk says

    24th May 2021 at 10:12 am

    Hello Franz,
    I guess that can be programmed to look at all the zones, but at the moment I am not sure, as the Graph is quite strict to select Zone ID, etc. MY bet is that before you run the other graph calls, you first list all the zones you have access to, and then do a loop of the graphql and all the code, per zone, that should work.

    I am really glad to see that this work helped you!

    Best regards

  10. medeirosjrm says

    5th February 2022 at 1:13 pm

    sudo sh cloudflare-analytics.sh
    cloudflare-analytics.sh: 38: let: date not found
    : invalid date ‘@’

    ./cloudflare-analytics.sh
    it doesn’t bring an error but it doesn’t load any graphics in grafana, it’s possible to have some log for debug

  11. jorgeuk says

    5th February 2022 at 5:29 pm

    Hello, yes, of course, you can try grabbing some of the queries and use them in the console itself.

    Give them a try and let me know.

  12. achizalulhaq says

    24th July 2022 at 2:40 pm

    Hii, i got error on latest script “jq: error (at :1): Cannot iterate over null (null)”

  13. jorgeuk says

    8th August 2022 at 10:03 am

    Hello,
    Are you using the latest version of the script, and you copied/paste correctly all the ids, etc? I need to give it another try soon.

  14. DuckieTM says

    4th September 2022 at 2:15 pm

    Sinds the latest update of InfluxDB 2.0 the script won’t work anymore 🙁

    {“code”:”unauthorized”,”message”:”Unauthorized”}Writing stats for day 2022-09-02
    Writing Zone data per Country to InfluxDB cloudflare_analytics_country
    HTTP/1.1 401 Unauthorized
    Content-Type: application/json; charset=utf-8
    X-Influxdb-Build: OSS
    X-Influxdb-Version: v2.4.0
    X-Platform-Error-Code: unauthorized
    Date: Sun, 04 Sep 2022 11:59:06 GMT
    Content-Length: 48

  15. snnkzr says

    14th August 2023 at 9:22 am

    Since this is the only cloudflare dashboard that makes sense and you are the grafana guru here my questions:

    I think this got together with user password combo for database. Telegraf is not using this anymore. It uses the api key. Can we make it work with api key for the database?

    Thanks in advance,

  16. jorgeuk says

    14th August 2023 at 4:51 pm

    Hello,
    What have you tried, and what is not working exactly?

  17. snnkzr says

    16th August 2023 at 10:45 am

    I don’t have user & and password combo for telegraf database and tried with influx admin user and password without success. I only have telegraf bucket and it’s api key. Couldn’t find any user & pass combo. Beyond this I think cloudflare is using updated API but this will be another subject i think.

  18. snnkzr says

    16th August 2023 at 11:23 am

    Forgot to mention:
    Influx 2.7.1
    Grafana v10.0.3
    And latest version of telegraf

  19. jorgeuk says

    16th August 2023 at 5:53 pm

    Yes, what is happening is that this dashboard have not been updated to Flux, hence the old way of doing it.

    Will see if I find time to update it.

  20. snnkzr says

    18th August 2023 at 6:45 am

    I will happliy wait patiently as usual mate, take your time. Thank you

  21. snnkzr says

    9th October 2023 at 6:37 am

    Hello again, any updates on flux migration? Did you have any time to spare to us 😀

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Primary Sidebar

  • E-mail
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • YouTube

Posts Calendar

April 2020
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar   May »

Disclaimer

All opinions expressed on this site are my own and do not represent the opinions of any company I have worked with, am working with, or will be working with.

Copyright © 2025 · The Blog of Jorge de la Cruz