|
| 1 | +# Cloudflare mixin |
| 2 | +The Cloudflare mixin is a set of configurable Grafana dashboards and alerts. |
| 3 | + |
| 4 | +The metrics analyzed here are a part of `Cloudflare Analytics - account and zone analytics` found [here](https://developers.cloudflare.com/analytics/account-and-zone-analytics/). Pool and worker metrics will not appear until your Cloudflare instance has been configured to utilize them. |
| 5 | + |
| 6 | +The Cloudflare mixin contains the following dashboards: |
| 7 | + |
| 8 | +- Cloudflare zone overview |
| 9 | +- Cloudflare GeoMap overview |
| 10 | +- Cloudflare worker overview |
| 11 | + |
| 12 | +and the following alerts: |
| 13 | + |
| 14 | +- CloudflareHighThreatCount |
| 15 | +- CloudflareHighRequestRate |
| 16 | +- CloudflareHighHTTPErrorCodes |
| 17 | +- CloudflareUnhealthyPools |
| 18 | +- CloudflareMetricsDown |
| 19 | + |
| 20 | +## Cloudflare zone overview |
| 21 | +The Cloudflare zone overview dashboard provides a detailed look into the performance of the zones in your Cloudflare account. Metrics analyzed include requests, cached requests, various bandwidth numbers, page views, request status, colocations, and pool status. |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +## Cloudflare Geomap overview |
| 27 | +The Cloudflare Geomap overview dashboard utilizes a GeoMap panel to visualize specific metrics on a global map. The metrics utilized here are requests, bandwidth, threats, non-cached requests, and edge requests. |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +## Cloudflare worker overview |
| 32 | +The Cloudflare worker overview dashboard provides a look into Cloudflare Worker performance on a per script basis. Metrics include CPU time quantiles, script duration quantiles, requests, and errors. |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | +## Alerts overview |
| 37 | + |
| 38 | +- CloudflareHighThreatCount: There are detected threats targeting the zone. |
| 39 | +- CloudflareHighRequestRate: A high spike in requests is occurring which may indicate an attack or unexpected load. |
| 40 | +- CloudflareHighHTTPErrorCodes: A high number of 4xx or 5xx HTTP status codes are occurring. |
| 41 | +- CloudflareUnhealthyPools: There are unhealthy pools. |
| 42 | +- CloudflareMetricsDown: Cloudflare metrics are down. |
| 43 | + |
| 44 | +Be sure to set `alertsMetricsDownJobName` to match your environment if using a different `Job` label than the default. |
| 45 | + |
| 46 | +Default thresholds can be configured in `config.libsonnet`. |
| 47 | +```js |
| 48 | +{ |
| 49 | + _config+:: { |
| 50 | + dashboardTags: ['cloudflare-mixin'], |
| 51 | + dashboardPeriod: 'now-30m', |
| 52 | + dashboardTimezone: 'default', |
| 53 | + dashboardRefresh: '1m', |
| 54 | + |
| 55 | + // CloudflareMetricsDown alert filter variable |
| 56 | + alertsMetricsDownJobName: 'integrations/cloudflare', |
| 57 | + |
| 58 | + // alerts thresholds |
| 59 | + alertsHighThreatCount: 3, // count |
| 60 | + alertsHighRequestRate: 150, // percentage |
| 61 | + alertsHighHTTPErrorCodeCount: 100, // count |
| 62 | + }, |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +## Install tools |
| 67 | + |
| 68 | +```bash |
| 69 | +go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest |
| 70 | +go install github.com/monitoring-mixins/mixtool/cmd/mixtool@latest |
| 71 | +``` |
| 72 | + |
| 73 | +For linting and formatting, you would also need `jsonnetfmt` installed. If you |
| 74 | +have a working Go development environment, it's easiest to run the following: |
| 75 | + |
| 76 | +```bash |
| 77 | +go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest |
| 78 | +``` |
| 79 | + |
| 80 | +The files in `dashboards_out` need to be imported |
| 81 | +into your Grafana server. The exact details will be depending on your environment. |
| 82 | + |
| 83 | +`prometheus_alerts.yaml` needs to be imported into Prometheus. |
| 84 | + |
| 85 | +## Generate dashboards and alerts |
| 86 | + |
| 87 | +Edit `config.libsonnet` if required and then build JSON dashboard files for Grafana: |
| 88 | + |
| 89 | +```bash |
| 90 | +make |
| 91 | +``` |
| 92 | + |
| 93 | +For more advanced uses of mixins, see |
| 94 | +https://github.com/monitoring-mixins/docs. |
0 commit comments