diff --git a/cloudflare-workers-mixin/.lint b/cloudflare-workers-mixin/.lint new file mode 100644 index 000000000..90ef57967 --- /dev/null +++ b/cloudflare-workers-mixin/.lint @@ -0,0 +1,7 @@ +exclusions: + panel-title-description-rule: + reason: Removed panel title for visual appearance for top stats panels + template-datasource-rule: + reason: Better for CLoudflare users to use trace and logs datasource + target-logql-auto-rule: + reason: panel 'traces table' is using logql query check diff --git a/cloudflare-workers-mixin/Makefile b/cloudflare-workers-mixin/Makefile new file mode 100644 index 000000000..b4fdca560 --- /dev/null +++ b/cloudflare-workers-mixin/Makefile @@ -0,0 +1 @@ +include ../Makefile_mixin diff --git a/cloudflare-workers-mixin/README.md b/cloudflare-workers-mixin/README.md new file mode 100644 index 000000000..e26a6b26b --- /dev/null +++ b/cloudflare-workers-mixin/README.md @@ -0,0 +1,60 @@ +# Cloudflare Workers Mixin + +The Cloudflare Workers mixin is a set of configurable Grafana dashboards for monitoring Cloudflare Workers using structured logs from Cloudflare Workers Observability. + +The Cloudflare Workers mixin contains the following dashboard: + +- Cloudflare Workers + +## Cloudflare Workers Dashboard Overview +The Cloudflare Workers dashboard provides comprehensive observability into your serverless functions deployed on Cloudflare's edge network. +It leverages the rich structured metadata from Cloudflare Workers logs to deliver insights across multiple dimensions: + +### Key Metrics & Statistics +- Request Volume: Total requests, request rate (req/sec), and unique request tracking via Ray IDs +Log Severity: Breakdown of info, warning, and error logs with color-coded indicators +Geographic Distribution: Unique countries, colos (edge locations), and FaaS execution regions +- Client Insights: Browser types, device vendors, and unique client diversity metrics + +### Request Analytics +- HTTP Methods: Distribution and trends of GET, POST, and other HTTP verbs +- URL Paths: Endpoint-level request analysis showing which routes receive traffic +- Network Protocols: HTTPS vs HTTP usage monitoring +- Request Triggers: FaaS trigger type analysis (http, scheduled, etc.) + +### Geographic & Network Intelligence +- World Map: Interactive geomap showing request distribution by country +- Edge Location Analysis: Cloudflare colo distribution with heatmaps and charts +- Continental Distribution: Traffic breakdown by continent (AS, EU, NA, etc.) +- Timezone Analysis: Request patterns across different time zones +- ISP Tracking: Autonomous System Number (ASN) distribution for network analysis +- City & Region: State/province and city-level geographic breakdown + +### Client & Browser Analytics +- Browser Distribution: Usage across Chrome, Firefox, Safari, Edge, etc. +- Browser Versions: Detailed version tracking for compatibility monitoring +- Rendering Engines: Blink, Gecko, WebKit distribution +- Operating Systems: macOS, Windows, Linux, mobile OS breakdown +- Device Vendors: Apple, Samsung, and other device manufacturer tracking +- Language Preferences: Accept-Language header analysis for internationalization insights +- Performance & Operations +- Log Volume Trends: Time series showing log patterns by severity level +- Request Rate Analysis: Temporal patterns by method, path, region, and colo +- Regional Performance: FaaS execution region distribution and rates +- Request Heatmaps: Time-based patterns across edge locations + +## Tools +To use them, you need to have `mixtool` and `jsonnetfmt` installed. If you have a working Go development environment, it's easiest to run the following: + +```bash +$ go get github.com/monitoring-mixins/mixtool/cmd/mixtool +$ go get github.com/google/go-jsonnet/cmd/jsonnetfmt +``` + +You can then build a directory `dashboard_out` with the JSON dashboard files for Grafana: + +```bash +$ make build +``` + +For more advanced uses of mixins, see [Prometheus Monitoring Mixins docs](https://github.com/monitoring-mixins/docs). diff --git a/cloudflare-workers-mixin/dashboards/cloudflare-workers.json b/cloudflare-workers-mixin/dashboards/cloudflare-workers.json new file mode 100644 index 000000000..4b2658fdb --- /dev/null +++ b/cloudflare-workers-mixin/dashboards/cloudflare-workers.json @@ -0,0 +1,1796 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "This dashboard monitors Cloudflare Workers applications through log-based analytics, tracking request patterns, geographic distribution, client demographics, and edge network performance.", + "editable": false, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": 0, + "links": [], + "panels": [ + { + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 2, + "x": 0, + "y": 0 + }, + "id": 4, + "options": { + "code": { + "language": "plaintext", + "showLineNumbers": false, + "showMiniMap": false + }, + "content": "![](https://storage.googleapis.com/grafanalabs-integration-logos/cloudflare-workers.png)", + "mode": "markdown" + }, + "pluginVersion": "12.3.0-18686767985", + "title": "", + "transparent": true, + "type": "text" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "Total requests", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic-by-name" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 12, + "x": 2, + "y": 0 + }, + "id": 9, + "options": { + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "showPercentChange": true, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum(count_over_time({service_name=~\"$service_name\"} [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "Total number of events", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "", + "transparent": true, + "type": "stat" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "Current request rate to the Cloudflare Worker", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "yellow", + "value": 1 + }, + { + "color": "red", + "value": 10 + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 5, + "x": 14, + "y": 0 + }, + "id": 10, + "options": { + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": true, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum(rate({service_name=~\"$service_name\"} [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "Request rate", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "", + "transparent": true, + "type": "stat" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "Number of unique countries accessing the worker", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-BlPu" + }, + "mappings": [], + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 5, + "x": 19, + "y": 0 + }, + "id": 16, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": true, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "count(count by(geo_country_code) (count_over_time({service_name=~\"$service_name\"} [$__auto])))", + "hide": false, + "instant": false, + "legendFormat": "Unique countries", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "", + "transparent": true, + "type": "stat" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "Total count of info level logs from the Cloudflare Worker", + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "green", + "mode": "shades" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": 0 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 2, + "y": 2 + }, + "id": 11, + "options": { + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "showPercentChange": true, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum(count_over_time({service_name=~\"$service_name\"} | detected_level=\"info\" [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "INFO logs", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "", + "transparent": true, + "type": "stat" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "Total count of warning level logs from the Cloudflare Worker", + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "yellow", + "mode": "shades" + }, + "mappings": [], + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "orange", + "value": 0 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 6, + "y": 2 + }, + "id": 13, + "options": { + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "showPercentChange": true, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum(count_over_time({service_name=~\"$service_name\"} | detected_level=\"warn\" [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "WARN logs", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "", + "transparent": true, + "type": "stat" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "Total count of error level logs from the Cloudflare Worker", + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "red", + "mode": "shades" + }, + "mappings": [], + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": 0 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 10, + "y": 2 + }, + "id": 12, + "options": { + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "showPercentChange": true, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum(count_over_time({service_name=~\"$service_name\"} | detected_level=\"error\" [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "Error logs", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "", + "transparent": true, + "type": "stat" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "URL path rate trends over time", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "hue", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 3, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "showValues": false, + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 12, + "x": 0, + "y": 4 + }, + "id": 23, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum by(url_path) (rate({service_name=~\"$service_name\"} [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "{{url_path}}", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "Request rate by URL path", + "transparent": true, + "type": "timeseries" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "Requests by URL path/endpoint", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-YlBl" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 4 + }, + "id": 22, + "options": { + "displayMode": "lcd", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "maxVizHeight": 300, + "minVizHeight": 16, + "minVizWidth": 8, + "namePlacement": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "sizing": "auto", + "valueMode": "color" + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum by(url_path) (count_over_time({service_name=~\"$service_name\"} [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "{{url_path}}", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "Requests by URL path", + "transparent": true, + "type": "bargauge" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "HTTP method rate trends over time", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 90, + "gradientMode": "hue", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "showValues": false, + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 12, + "x": 0, + "y": 9 + }, + "id": 24, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum by(http_request_method) (rate({service_name=~\"$service_name\"} [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "{{http_request_method}}", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "Request rate by method", + "transparent": true, + "type": "timeseries" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "World map showing geographic distribution of requests by country", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "yellow", + "value": 10 + }, + { + "color": "orange", + "value": 50 + }, + { + "color": "red", + "value": 100 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 16, + "w": 12, + "x": 12, + "y": 10 + }, + "id": 25, + "options": { + "basemap": { + "config": {}, + "name": "Default", + "noRepeat": false, + "type": "default" + }, + "controls": { + "mouseWheelZoom": false, + "showAttribution": true, + "showDebug": false, + "showMeasure": false, + "showScale": false, + "showZoom": true + }, + "layers": [ + { + "config": { + "showLegend": true, + "style": { + "color": { + "fixed": "blue" + }, + "opacity": 1, + "rotation": { + "field": "Value #A", + "fixed": 0, + "max": 360, + "min": -360, + "mode": "mod" + }, + "size": { + "field": "Value #A", + "fixed": 5, + "max": 15, + "min": 3 + }, + "symbol": { + "fixed": "img/icons/marker/circle.svg", + "mode": "fixed" + }, + "symbolAlign": { + "horizontal": "center", + "vertical": "center" + }, + "text": { + "field": "geo_country_code", + "fixed": "", + "mode": "fixed" + }, + "textConfig": { + "fontSize": 12, + "offsetX": 0, + "offsetY": 0, + "textAlign": "center", + "textBaseline": "middle" + } + } + }, + "filterData": { + "id": "byRefId", + "options": "A" + }, + "layer-tooltip": true, + "location": { + "gazetteer": "https://grafana-assets.grafana.net/grafana/12.3.0-18686767985/public/build/gazetteer/countries.json", + "lookup": "geo_country_code", + "mode": "lookup" + }, + "name": "Countries", + "opacity": 0.6, + "tooltip": true, + "type": "markers" + } + ], + "tooltip": { + "mode": "details" + }, + "view": { + "allLayers": true, + "id": "zero", + "lat": 20, + "lon": 0, + "noRepeat": false, + "shared": true, + "zoom": 2 + } + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum by(geo_country_code) (count_over_time({service_name=~\"$service_name\"} [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "{{geo_country_code}}", + "queryType": "instant", + "range": true, + "refId": "A" + } + ], + "title": "", + "transparent": true, + "type": "geomap" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "Requests by Operating System", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [], + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 6, + "x": 0, + "y": 14 + }, + "id": 26, + "options": { + "displayLabels": [], + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true, + "values": [ + "percent" + ] + }, + "pieType": "donut", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "sort": "desc", + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum by(user_agent_os_name) (count_over_time({service_name=~\"$service_name\"} [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "{{user_agent_device_vendor}}", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "Requests by OS", + "transparent": true, + "type": "piechart" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "Distribution of requests by browser", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [], + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 6, + "x": 6, + "y": 14 + }, + "id": 20, + "options": { + "displayLabels": [ + "percent" + ], + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true, + "values": [ + "percent" + ] + }, + "pieType": "donut", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "sort": "desc", + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum by(user_agent_browser_name) (count_over_time({service_name=~\"$service_name\"} [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "{{user_agent_browser_name}}", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "Requests by browser", + "transparent": true, + "type": "piechart" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "Distribution of requests across Cloudflare edge locations", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [], + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 6, + "x": 0, + "y": 20 + }, + "id": 18, + "options": { + "displayLabels": [], + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true, + "values": [ + "percent" + ] + }, + "pieType": "donut", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "sort": "desc", + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum by(cloudflare_colo) (count_over_time({service_name=~\"$service_name\"} [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "{{cloudflare_colo}}", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "Requests by Cloudflare colo", + "transparent": true, + "type": "piechart" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "Distribution of HTTP methods (GET, POST, etc.)", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [], + "unit": "short" + } + }, + "gridPos": { + "h": 6, + "w": 6, + "x": 6, + "y": 20 + }, + "id": 21, + "options": { + "displayLabels": [], + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true, + "values": [ + "percent" + ] + }, + "pieType": "donut", + "reduceOptions": { + "calcs": [ + "sum" + ], + "fields": "", + "values": false + }, + "sort": "desc", + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum by(http_request_method) (count_over_time({service_name=~\"$service_name\"} [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "{{http_request_method}}", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "HTTP methods", + "transparent": true, + "type": "piechart" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 26 + }, + "id": 15, + "panels": [], + "title": "Logs", + "type": "row" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "description": "Log volume over time grouped by severity level", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic-by-name" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "Logs", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": 3600000, + "lineInterpolation": "smooth", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 4, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "showValues": false, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "error" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "warn" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "info" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 27 + }, + "id": 14, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "sum by (detected_level) (count_over_time({service_name=~\"$service_name\"} [$__auto]))", + "hide": false, + "instant": false, + "legendFormat": "{{detected_level}}", + "queryType": "range", + "range": true, + "refId": "A" + } + ], + "title": "Logs volume", + "type": "timeseries" + }, + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 12, + "w": 24, + "x": 0, + "y": 33 + }, + "id": 1, + "options": { + "dedupStrategy": "none", + "detailsMode": "sidebar", + "enableInfiniteScrolling": false, + "enableLogDetails": true, + "fontSize": "default", + "prettifyLogMessage": false, + "showControls": false, + "showLabels": false, + "showTime": false, + "sortOrder": "Descending", + "syntaxHighlighting": false, + "wrapLogMessage": true + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "${logsDatasource}" + }, + "direction": "backward", + "editorMode": "code", + "expr": "{service_name=~\"$service_name\"}", + "queryType": "range", + "refId": "A" + } + ], + "title": "", + "type": "logs" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 45 + }, + "id": 8, + "panels": [], + "title": "Traces", + "type": "row" + }, + { + "datasource": { + "type": "tempo", + "uid": "${traceDatasource}" + }, + "description": "This panel shows detailed trace information for requests, including trace IDs, service names, operation names, and durations. Click on trace IDs to view detailed trace analysis and understand request flow through your system.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "footer": { + "reducers": [] + }, + "inspect": false, + "wrapHeaderText": false + }, + "links": [ + { + "title": "Traces Link", + "url": "/d/is55kkp/cloudflare-workers?orgId=1&var-traceId=${__data.fields[\"traceID\"]}" + } + ], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Trace ID" + }, + "properties": [ + { + "id": "custom.width", + "value": 301 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Start time" + }, + "properties": [ + { + "id": "custom.width", + "value": 160 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Service" + }, + "properties": [ + { + "id": "custom.width", + "value": 95 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Name" + }, + "properties": [ + { + "id": "custom.width", + "value": 167 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Duration" + }, + "properties": [ + { + "id": "custom.width", + "value": 73 + } + ] + } + ] + }, + "gridPos": { + "h": 18, + "w": 12, + "x": 0, + "y": 46 + }, + "id": 5, + "options": { + "cellHeight": "sm", + "frameIndex": 0, + "showHeader": true, + "sortBy": [ + { + "desc": false, + "displayName": "Name" + } + ] + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "tempo", + "uid": "${traceDatasource}" + }, + "filters": [ + { + "id": "2855f0af", + "operator": "=", + "scope": "span" + }, + { + "id": "service-name", + "isCustomValue": false, + "operator": "=", + "scope": "resource", + "tag": "service.name", + "value": [ + "$service_name" + ], + "valueType": "string" + } + ], + "limit": 20, + "metricsQueryType": "range", + "query": "{resource.service.name=\"$service_name\"}", + "queryType": "traceql", + "refId": "A", + "serviceMapUseNativeHistograms": false, + "tableType": "traces" + } + ], + "title": "", + "transparent": true, + "type": "table" + }, + { + "description": "Instructions for viewing detailed trace information. Click on trace IDs in the traces table, then click the traces link, and refresh the dashboard to see the complete trace visualization with span details.", + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 12, + "x": 12, + "y": 46 + }, + "id": 7, + "options": { + "code": { + "language": "plaintext", + "showLineNumbers": false, + "showMiniMap": false + }, + "content": "> To View Traces:\n> 1. Click the **Trace ID** on the left table .\n> 2. Click **Traces link**.\n> 1. Refresh the dashboard.", + "mode": "markdown" + }, + "pluginVersion": "12.3.0-18686767985", + "title": "", + "type": "text" + }, + { + "datasource": { + "type": "tempo", + "uid": "${traceDatasource}" + }, + "description": "This panel displays the selected trace visualization. Use the trace ID variable or click on traces in the table above to view detailed span information, timing, and request flow through your services.", + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 15, + "w": 12, + "x": 12, + "y": 49 + }, + "id": 6, + "options": { + "spanFilters": { + "criticalPathOnly": false, + "matchesOnly": false, + "serviceNameOperator": "=", + "spanNameOperator": "=", + "tags": [ + { + "id": "233b1122-9ee", + "operator": "=" + } + ] + } + }, + "pluginVersion": "12.3.0-18686767985", + "targets": [ + { + "datasource": { + "type": "tempo", + "uid": "${traceDatasource}" + }, + "limit": 20, + "metricsQueryType": "range", + "query": "${traceId}", + "queryType": "traceql", + "refId": "A", + "serviceMapUseNativeHistograms": false, + "tableType": "traces" + } + ], + "title": "", + "transparent": true, + "type": "traces" + } + ], + "preload": false, + "schemaVersion": 42, + "tags": [ + "cloudflare" + ], + "templating": { + "list": [ + { + "current": { + "text": "grafanacloud-cloudflareworkers-logs", + "value": "grafanacloud-logs" + }, + "label": "Logs data source", + "name": "logsDatasource", + "options": [], + "query": "loki", + "refresh": 1, + "regex": "(?!grafanacloud-usage|grafanacloud-ml-metrics|grafanacloud-demoinfra).+", + "type": "datasource" + }, + { + "current": { + "text": "grafanacloud-cloudflareworkers-traces", + "value": "grafanacloud-traces" + }, + "label": "Trace data source", + "name": "traceDatasource", + "options": [], + "query": "tempo", + "refresh": 1, + "regex": "(?!grafanacloud-demoinfra).+", + "type": "datasource" + }, + { + "current": { + "text": "All", + "value": [ + "$__all" + ] + }, + "datasource": { + "type": "loki", + "uid": "grafanacloud-logs" + }, + "definition": "", + "description": "", + "includeAll": true, + "label": "Service name", + "multi": true, + "name": "service_name", + "options": [], + "query": { + "label": "service_name", + "refId": "LokiVariableQueryEditor-VariableQuery", + "stream": "", + "type": 1 + }, + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": { + "text": "83d4d86f85b17b85086fac00e0cd90ec", + "value": "83d4d86f85b17b85086fac00e0cd90ec" + }, + "label": "Trace ID", + "name": "traceId", + "options": [], + "query": "", + "type": "custom" + } + ] + }, + "time": { + "from": "now-3h", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Cloudflare Workers", + "uid": "is55kkp", + "version": 11 +} \ No newline at end of file diff --git a/cloudflare-workers-mixin/mixin.libsonnet b/cloudflare-workers-mixin/mixin.libsonnet new file mode 100644 index 000000000..9b54b8b43 --- /dev/null +++ b/cloudflare-workers-mixin/mixin.libsonnet @@ -0,0 +1,7 @@ +local meta = import '../metadata.json'; + +{ + grafanaDashboards+:: { + 'cloudflare-workers.json': (import 'dashboards/cloudflare-workers.json'), + }, +}