Skip to content

pokertour/Cloudflare-Grafana

Repository files navigation

Cloudflare-Grafana

Grafana Dashboard that shows Cloudflare Overviews and Analytics from the RESTful API

Configuration Cloudflare

The preferered authentication method is to use API Tokens.

On your Cloudflare Profile go inside API Tokens menu.

Create a new Token using the Read analytics and logs template: image image

Leave all the field by default. You can add a IP Filtering if you want and a TTL aswell.

Continue to summary and you should have this permissions : image

Create the token and place it in the script on the setting : cloudflareapitoken

Configuration Script

Place the script where you want, there is no importance.

change the Configuration section within your details :

##
# Configurations
##
# Endpoint URL for InfluxDB
InfluxDBURL="YOURINFLUXSERVERIP" #Your InfluxDB Server, http://FQDN or https://FQDN if using SSL
InfluxDBPort="8086" #Default Port
InfluxBucket="YOURINFLUXBUCKETNAME" #Default Database
InfluxOrg="YOURINFLUXORG"
InfluxToken="YOURINFLUXTOKEN"

# Endpoint URL for login action
cloudflareauthmethod="TOKEN/APIKEY" #Choose Authentication method. Either TOKEN (single token with specific rights) or APIKEY (Global API KEY with Email)
cloudflareapikey="YOURAPIKEY" # Used in APIKEY Mode
cloudflareemail="YOUREMAIL" # Used in APIKEY Mode
cloudflarezone="YOURZONEID" # Used in both Mode
cloudflareapitoken="YOURTOKEN" # Used in TOKEN Mode

Once the changes are done, make the script executable with chmod:

chmod +x cloudflare-analytics.sh

The output of the command should be something like the next, without errors:

HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: b084ba16-8622-11ea-8dbc-0050569002da
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.7.10
X-Request-Id: b084ba16-8622-11ea-8dbc-0050569002da
Date: Fri, 24 Apr 2020 11:56:53 GMT

If so, please now add this script to your crontab, like for example everyday at 9am:

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

Configuration InfluxDb

You should create a specific bucket with a specific token with read/write permission on the bucket.

Configuration Grafana

You must add a Data Sources to the influxDB bucket. You must set the Query language to Flux.

You can import the dashboard from Grafana website : https://grafana.com/grafana/dashboards/20682-cloudflare-analytics-and-overview/ ID : 20682

Planned Features

  • Possibility to have multizone

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages