diff --git a/README.md b/README.md index f562048..4035eb2 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,10 @@ images to GHCR with SLSA provenance attestation on push to `main`/tags. Import it in Grafana (Dashboards → New → Import) by ID **[25832](https://grafana.com/grafana/dashboards/25832)**, or upload the JSON file, and pick your Prometheus data source. +### Adoption dashboard + +[`dashboards/github-repo-adoption.json`](dashboards/github-repo-adoption.json) charts the [adoption stats](#adoption-stats) of the repos in `ADOPTION_REPOS`: release downloads (total, per day, per release and asset), stars, forks, watchers, open issues, and repo traffic (views, clones, top referrers, popular paths). Pick the repo with the `Repo` variable. The "Traffic API" tile reads "no access" until the token has Administration (read). Import it the same way as the dashboard above. + ## Alerting [`alerts/github-actions-runner-exporter.rules.yml`](alerts/github-actions-runner-exporter.rules.yml) has ready-made Prometheus alerting rules. Add it under `rule_files:`, or paste its group into a `PrometheusRule`'s `spec.groups` on kube-prometheus-stack. diff --git a/dashboards/github-repo-adoption.json b/dashboards/github-repo-adoption.json new file mode 100644 index 0000000..9ce1cb1 --- /dev/null +++ b/dashboards/github-repo-adoption.json @@ -0,0 +1,1107 @@ +{ + "title": "GitHub Repo Adoption", + "uid": "github-repo-adoption", + "tags": [ + "github", + "adoption", + "prometheus" + ], + "description": "Adoption signals for GitHub repos tracked by github-actions-runner-exporter (ADOPTION_REPOS): release asset downloads, stars, forks, watchers, open issues and repo traffic (views, clones, referrers, popular paths). Traffic needs Administration (read) on the exporter token.", + "refresh": "1h", + "time": { + "from": "now-30d", + "to": "now" + }, + "schemaVersion": 39, + "timezone": "browser", + "editable": true, + "links": [], + "templating": { + "list": [ + { + "name": "datasource", + "label": "Prometheus", + "type": "datasource", + "query": "prometheus", + "current": {}, + "hide": 0, + "refresh": 1 + }, + { + "name": "repo", + "label": "Repo", + "type": "query", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "query": { + "query": "label_values(github_repo_stars, repo)", + "refId": "repo" + }, + "definition": "label_values(github_repo_stars, repo)", + "refresh": 2, + "multi": true, + "includeAll": true, + "allValue": ".*", + "current": {} + } + ] + }, + "panels": [ + { + "id": 1, + "type": "row", + "title": "Right now", + "collapsed": false, + "gridPos": { + "x": 0, + "y": 0, + "w": 24, + "h": 1 + }, + "panels": [] + }, + { + "id": 2, + "type": "stat", + "title": "Stars", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 0, + "y": 1, + "w": 4, + "h": 4 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(github_repo_stars{repo=~\"$repo\"})", + "instant": true, + "range": false + } + ], + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "none", + "graphMode": "area", + "textMode": "value" + }, + "fieldConfig": { + "defaults": { + "unit": "none", + "noValue": "-" + }, + "overrides": [] + } + }, + { + "id": 3, + "type": "stat", + "title": "Forks", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 4, + "y": 1, + "w": 4, + "h": 4 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(github_repo_forks{repo=~\"$repo\"})", + "instant": true, + "range": false + } + ], + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "none", + "graphMode": "area", + "textMode": "value" + }, + "fieldConfig": { + "defaults": { + "unit": "none", + "noValue": "-" + }, + "overrides": [] + } + }, + { + "id": 4, + "type": "stat", + "title": "Watchers", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 8, + "y": 1, + "w": 4, + "h": 4 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(github_repo_watchers{repo=~\"$repo\"})", + "instant": true, + "range": false + } + ], + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "none", + "graphMode": "area", + "textMode": "value" + }, + "fieldConfig": { + "defaults": { + "unit": "none", + "noValue": "-" + }, + "overrides": [] + } + }, + { + "id": 5, + "type": "stat", + "title": "Open issues", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 12, + "y": 1, + "w": 4, + "h": 4 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(github_repo_open_issues{repo=~\"$repo\"})", + "instant": true, + "range": false + } + ], + "description": "Excludes pull requests.", + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "none", + "graphMode": "area", + "textMode": "value" + }, + "fieldConfig": { + "defaults": { + "unit": "none", + "noValue": "-" + }, + "overrides": [] + } + }, + { + "id": 6, + "type": "stat", + "title": "Downloads (all time)", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 16, + "y": 1, + "w": 4, + "h": 4 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(github_release_asset_downloads{repo=~\"$repo\",asset!~\".*(checksums|\\\\.sbom|\\\\.sig|\\\\.pem|\\\\.json).*\"})", + "instant": true, + "range": false + } + ], + "description": "Binary archives and packages only (checksums, SBOMs and signatures excluded). Includes automated fetches such as the Homebrew cask's own installs and CI.", + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "none", + "graphMode": "area", + "textMode": "value" + }, + "fieldConfig": { + "defaults": { + "unit": "none", + "noValue": "-" + }, + "overrides": [] + } + }, + { + "id": 7, + "type": "stat", + "title": "Downloads (dashboard range)", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 20, + "y": 1, + "w": 4, + "h": 4 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(increase(github_release_asset_downloads{repo=~\"$repo\",asset!~\".*(checksums|\\\\.sbom|\\\\.sig|\\\\.pem|\\\\.json).*\"}[$__range]))", + "instant": true, + "range": false + } + ], + "description": "Increase over the selected time range. A release published inside the range counts from its first scrape, not from zero.", + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "none", + "graphMode": "area", + "textMode": "value" + }, + "fieldConfig": { + "defaults": { + "unit": "none", + "noValue": "-" + }, + "overrides": [] + } + }, + { + "id": 8, + "type": "row", + "title": "Downloads", + "collapsed": false, + "gridPos": { + "x": 0, + "y": 5, + "w": 24, + "h": 1 + }, + "panels": [] + }, + { + "id": 9, + "type": "timeseries", + "title": "Downloads per day by asset", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 0, + "y": 6, + "w": 16, + "h": 9 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (asset) (increase(github_release_asset_downloads{repo=~\"$repo\",asset!~\".*(checksums|\\\\.sbom|\\\\.sig|\\\\.pem|\\\\.json).*\"}[1d]))", + "legendFormat": "{{asset}}" + } + ], + "description": "Release asset download_count is cumulative; this is its daily increase. History starts when the exporter first scraped the repo.", + "fieldConfig": { + "defaults": { + "unit": "short", + "custom": { + "drawStyle": "bars", + "fillOpacity": 80, + "stacking": { + "mode": "normal" + } + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "id": 10, + "type": "table", + "title": "Downloads by release", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 16, + "y": 6, + "w": 8, + "h": 9 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (tag) (github_release_asset_downloads{repo=~\"$repo\",asset!~\".*(checksums|\\\\.sbom|\\\\.sig|\\\\.pem|\\\\.json).*\"})", + "instant": true, + "range": false, + "format": "table" + } + ], + "transformations": [ + { + "id": "merge", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true + }, + "renameByName": { + "tag": "release", + "Value": "downloads" + }, + "indexByName": { + "tag": 0, + "Value": 1 + } + } + }, + { + "id": "sortBy", + "options": { + "sort": [ + { + "field": "downloads", + "desc": true + } + ] + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "fieldConfig": { + "defaults": {}, + "overrides": [] + } + }, + { + "id": 11, + "type": "table", + "title": "Downloads by asset", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 0, + "y": 15, + "w": 24, + "h": 8 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (tag, asset) (github_release_asset_downloads{repo=~\"$repo\"})", + "instant": true, + "range": false, + "format": "table" + } + ], + "description": "Cumulative, every asset including checksums.", + "transformations": [ + { + "id": "merge", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true + }, + "renameByName": { + "tag": "release", + "asset": "asset", + "Value": "downloads" + }, + "indexByName": { + "tag": 0, + "asset": 1, + "Value": 2 + } + } + }, + { + "id": "sortBy", + "options": { + "sort": [ + { + "field": "downloads", + "desc": true + } + ] + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "fieldConfig": { + "defaults": {}, + "overrides": [] + } + }, + { + "id": 12, + "type": "row", + "title": "Community", + "collapsed": false, + "gridPos": { + "x": 0, + "y": 23, + "w": 24, + "h": 1 + }, + "panels": [] + }, + { + "id": 13, + "type": "timeseries", + "title": "Stars, forks, watchers", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 0, + "y": 24, + "w": 12, + "h": 8 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(github_repo_stars{repo=~\"$repo\"})", + "legendFormat": "stars" + }, + { + "refId": "B", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(github_repo_forks{repo=~\"$repo\"})", + "legendFormat": "forks" + }, + { + "refId": "C", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(github_repo_watchers{repo=~\"$repo\"})", + "legendFormat": "watchers" + } + ], + "fieldConfig": { + "defaults": { + "unit": "short", + "custom": { + "drawStyle": "line", + "fillOpacity": 10, + "lineWidth": 2, + "spanNulls": true + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "id": 14, + "type": "timeseries", + "title": "Open issues", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 12, + "y": 24, + "w": 12, + "h": 8 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(github_repo_open_issues{repo=~\"$repo\"})", + "legendFormat": "open issues" + }, + { + "refId": "B", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(github_repo_open_prs{repo=~\"$repo\"})", + "legendFormat": "open PRs" + } + ], + "description": "Open PRs come from the org-wide stats poll.", + "fieldConfig": { + "defaults": { + "unit": "short", + "custom": { + "drawStyle": "line", + "fillOpacity": 10, + "lineWidth": 2, + "spanNulls": true + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "id": 15, + "type": "row", + "title": "Repo traffic (GitHub keeps 14 days; Prometheus keeps the rest)", + "collapsed": false, + "gridPos": { + "x": 0, + "y": 32, + "w": 24, + "h": 1 + }, + "panels": [] + }, + { + "id": 16, + "type": "stat", + "title": "Traffic API", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 0, + "y": 33, + "w": 4, + "h": 4 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "min(github_repo_traffic_ok{repo=~\"$repo\"})", + "instant": true, + "range": false + } + ], + "description": "1 = reading traffic. 0 = the exporter token lacks Administration (read) on the repo, so the panels below stay empty.", + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "background", + "graphMode": "none", + "textMode": "value" + }, + "fieldConfig": { + "defaults": { + "unit": "none", + "noValue": "-", + "mappings": [ + { + "type": "value", + "options": { + "0": { + "text": "no access", + "color": "red" + }, + "1": { + "text": "ok", + "color": "green" + } + } + } + ] + }, + "overrides": [] + } + }, + { + "id": 17, + "type": "barchart", + "title": "Views per day", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 4, + "y": 33, + "w": 10, + "h": 9 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "max by (date) (max_over_time(github_repo_traffic_views_daily{repo=~\"$repo\"}[$__range]))", + "instant": true, + "range": false, + "format": "table" + }, + { + "refId": "B", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "max by (date) (max_over_time(github_repo_traffic_view_uniques_daily{repo=~\"$repo\"}[$__range]))", + "instant": true, + "range": false, + "format": "table" + } + ], + "description": "Repo page views. Today is partial (UTC).", + "transformations": [ + { + "id": "merge", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "repo": true + }, + "renameByName": { + "Value #A": "views", + "Value #B": "unique visitors" + }, + "indexByName": { + "date": 0 + } + } + }, + { + "id": "sortBy", + "options": { + "sort": [ + { + "field": "date" + } + ] + } + } + ], + "options": { + "xField": "date", + "orientation": "auto", + "legend": { + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi" + }, + "xTickLabelRotation": -45 + }, + "fieldConfig": { + "defaults": { + "custom": { + "fillOpacity": 80 + } + }, + "overrides": [] + } + }, + { + "id": 18, + "type": "barchart", + "title": "Clones per day", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 14, + "y": 33, + "w": 10, + "h": 9 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "max by (date) (max_over_time(github_repo_traffic_clones_daily{repo=~\"$repo\"}[$__range]))", + "instant": true, + "range": false, + "format": "table" + }, + { + "refId": "B", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "max by (date) (max_over_time(github_repo_traffic_clone_uniques_daily{repo=~\"$repo\"}[$__range]))", + "instant": true, + "range": false, + "format": "table" + } + ], + "description": "git clones, including CI and `go install` fetches.", + "transformations": [ + { + "id": "merge", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "repo": true + }, + "renameByName": { + "Value #A": "clones", + "Value #B": "unique cloners" + }, + "indexByName": { + "date": 0 + } + } + }, + { + "id": "sortBy", + "options": { + "sort": [ + { + "field": "date" + } + ] + } + } + ], + "options": { + "xField": "date", + "orientation": "auto", + "legend": { + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi" + }, + "xTickLabelRotation": -45 + }, + "fieldConfig": { + "defaults": { + "custom": { + "fillOpacity": 80 + } + }, + "overrides": [] + } + }, + { + "id": 19, + "type": "table", + "title": "Top referrers (last 14 days)", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 0, + "y": 42, + "w": 12, + "h": 8 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (referrer) (github_repo_traffic_referrer_views{repo=~\"$repo\"})", + "instant": true, + "range": false, + "format": "table" + }, + { + "refId": "B", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (referrer) (github_repo_traffic_referrer_uniques{repo=~\"$repo\"})", + "instant": true, + "range": false, + "format": "table" + } + ], + "transformations": [ + { + "id": "merge", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true + }, + "renameByName": { + "Value #A": "views", + "Value #B": "uniques" + }, + "indexByName": { + "referrer": 0, + "Value #A": 1, + "Value #B": 2 + } + } + }, + { + "id": "sortBy", + "options": { + "sort": [ + { + "field": "views", + "desc": true + } + ] + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "fieldConfig": { + "defaults": {}, + "overrides": [] + } + }, + { + "id": 20, + "type": "table", + "title": "Popular content (last 14 days)", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "x": 12, + "y": 42, + "w": 12, + "h": 8 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (path) (github_repo_traffic_path_views{repo=~\"$repo\"})", + "instant": true, + "range": false, + "format": "table" + }, + { + "refId": "B", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (path) (github_repo_traffic_path_uniques{repo=~\"$repo\"})", + "instant": true, + "range": false, + "format": "table" + } + ], + "transformations": [ + { + "id": "merge", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true + }, + "renameByName": { + "Value #A": "views", + "Value #B": "uniques" + }, + "indexByName": { + "path": 0, + "Value #A": 1, + "Value #B": 2 + } + } + }, + { + "id": "sortBy", + "options": { + "sort": [ + { + "field": "views", + "desc": true + } + ] + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "fieldConfig": { + "defaults": {}, + "overrides": [] + } + } + ] +}