centminmod / cf-analytics

Cloudflare Zone Analytics API Script - query your zone's Analytics stats via Cloudflare API
21 stars 3 forks source link

Grafana Dashboards #2

Open ehnwebmaster opened 2 weeks ago

ehnwebmaster commented 2 weeks ago

Hello,

That's a nice script for querying graphQL API from CloudFlare, but it will be nice to visualize all this data in Grafana.

I have some templates If you are interested.

centminmod commented 2 weeks ago

Hi yes I realise Grafana etc would be easier though purpose is to not have to install anything and just run a script.

Wouldn't mind seeing the templates though. Do you have a repo I can check out?

Cheers

George

ehnwebmaster commented 2 weeks ago

Yes the script is quicker to install, but for example I'm using alerts based on Grafana Dashboards and are really usefuls

My templates are based on another script but I assume the variables will be most the same: https://github.com/MasterOfMalt/cloudflare-grafana

There ara two Grafana templates and bash script

The bash script querying the graphQL API from CloudFlare and exporting data to InfluxDB for later visualize with Grafana

Note that the script is using the old InfluxQL datasource and not the new Flux. So it's using db and not buckets, and user-password and not token. And it's not using API token from CloudFlare like you.

CloudFlare Analytics https://grafana.com/grafana/dashboards/22131-cloudflare-public-analytics-elhacker-net/

You can view online at: https://cloudflare.elhacker.net

Shows last 12 hours and updates every 5 minutes and it's using Pro plan from CloudFlare.

and CloudFlare Firewall https://grafana.com/grafana/dashboards/22154-cloudflare-firewall-analytics-influxql/

You can download the templates in JSON format.

I'm also using other Grafana templates based on CloudFlare Exporter using Prometheus: https://github.com/lablabs/cloudflare-exporter

But the project seems not active because they forget to add some important metrics like firewall

centminmod commented 2 weeks ago

Thanks @ehnwebmaster for the info and direction. Definitely something to work towards setting up 👍

centminmod commented 2 weeks ago

@ehnwebmaster just like to thank you for nudging me to revisit this. I found more up to date cloudflare-exporter at https://hub.docker.com/r/cyb3rjak3/cloudflare-exporter though don't have any Grafana dashboards I like so manually building a custom set.

I already had a older Grafana/Prometheus/InfluxDB/Telegraf for k6 benchmarks that used InfluxDB databases. So updated it with Cloudflare Exporter and new InfluxDB buckets. Means I have to redo most dashboards though. Been a long time I had to do that part!

docker exec k6-support-cloudflare-exporter curl -s localhost:8080/metrics | grep HELP
# HELP cloudflare_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which the cloudflare_exporter was built.
# HELP cloudflare_logpush_failed_jobs_zone_count Number of failed logpush jobs on the zone level
# HELP cloudflare_r2_operation_count Number of operations performed by R2
# HELP cloudflare_r2_storage_bytes Storage used by R2
# HELP cloudflare_worker_cpu_time CPU time quantiles by script name
# HELP cloudflare_worker_duration Duration quantiles by script name (GB*s)
# HELP cloudflare_worker_errors_count Number of errors by script name
# HELP cloudflare_worker_requests_count Number of requests sent to worker by script name
# HELP cloudflare_zone_bandwidth_cached Cached bandwidth per zone in bytes
# HELP cloudflare_zone_bandwidth_content_type Bandwidth per zone per content type
# HELP cloudflare_zone_bandwidth_country Bandwidth per country per zone
# HELP cloudflare_zone_bandwidth_ssl_encrypted Encrypted bandwidth per zone in bytes
# HELP cloudflare_zone_bandwidth_total Total bandwidth per zone in bytes
# HELP cloudflare_zone_colocation_edge_response_bytes Edge response bytes per colocation
# HELP cloudflare_zone_colocation_requests_total Total requests per colocation
# HELP cloudflare_zone_colocation_visits Total visits per colocation
# HELP cloudflare_zone_firewall_events_count Count of Firewall events
# HELP cloudflare_zone_health_check_events_origin_count Number of Heath check events per region per origin
# HELP cloudflare_zone_pageviews_total Pageviews per zone
# HELP cloudflare_zone_pool_health_status Reports the health of a pool, 1 for healthy, 0 for unhealthy.
# HELP cloudflare_zone_pool_requests_total Requests per pool
# HELP cloudflare_zone_requests_browser_map_page_views_count Number of successful requests for HTML pages per zone
# HELP cloudflare_zone_requests_cached Number of cached requests for zone
# HELP cloudflare_zone_requests_content_type Number of request for zone per content type
# HELP cloudflare_zone_requests_country Number of request for zone per country
# HELP cloudflare_zone_requests_origin_status_country_host Count of not cached requests for zone per origin HTTP status per country per host
# HELP cloudflare_zone_requests_ssl_encrypted Number of encrypted requests for zone
# HELP cloudflare_zone_requests_status Number of request for zone per HTTP status
# HELP cloudflare_zone_requests_status_country_host Count of requests for zone per edge HTTP status per country per host
# HELP cloudflare_zone_requests_total Number of requests for zone
# HELP cloudflare_zone_threats_country Threats per zone per country
# HELP cloudflare_zone_threats_total Threats per zone
# HELP cloudflare_zone_threats_type Threats per zone per type
# HELP cloudflare_zone_uniques_total Uniques per zone
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# HELP go_goroutines Number of goroutines that currently exist.
# HELP go_info Information about the Go environment.
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
# HELP go_memstats_frees_total Total number of frees.
# HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
# HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.
# HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
# HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
# HELP go_memstats_heap_objects Number of allocated objects.
# HELP go_memstats_heap_released_bytes Number of heap bytes released to OS.
# HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.
# HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.
# HELP go_memstats_lookups_total Total number of pointer lookups.
# HELP go_memstats_mallocs_total Total number of mallocs.
# HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.
# HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.
# HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.
# HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.
# HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.
# HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.
# HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.
# HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# HELP go_threads Number of OS threads created.
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.