Skip to content

feat(analytics): publish visitors by request-count band - #2155

Merged
alanpeixinho merged 2 commits into
kernelci:mainfrom
profusion:feat/analytics-visitors-by-request-count
Oct 7, 2026
Merged

alanpeixinho merged 2 commits into
kernelci:mainfrom
profusion:feat/analytics-visitors-by-request-count

Conversation

@alanpeixinho

Copy link
Copy Markdown
Contributor

What it is

Publishes one Prometheus sample per visitor for each finished UTC day, bucketed by how many /api/ requests they made (1-5 through 1000+). The 00:15 UTC job is publish_visitor_requests. Today is refused so a manual run cannot lock visitors out of that job.

Built on top of #2154. Merge that first.

Made with Cursor.

How to test

  • cd backend && poetry run pytest kernelCI_app/tests/unitTests/middleware/backendRequestMetricsMiddleware_test.py -m unit
  • Import monitoring/dashboard.json and open Visitors by request count. Bars run 1-5, 6-10, 11-20, 21-50, 51-100, 101-500, 501-999, 1000+.
  • cd backend && poetry run python manage.py publish_visitor_requests --date YYYY-MM-DD for a finished UTC day. Omit --date for yesterday. Today's date exits with an error.
  • Set HEALTHCHECK_ID_PUBLISH_VISITOR_REQUESTS if the 00:15 job should ping healthcheck.io.

Part of #2151

Made with Cursor

Comment thread monitoring/dashboard.json Outdated
"uid": "prometheus"
},
"editorMode": "code",
"expr": "round(sum(dashboard_visitors_by_request_count_total{client=~\"$client\", band=\"1-5\"}))",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sum is the total since the counter was created, so the time range does nothing. A backend restart also deletes the metric files and the bars go back to zero. Please use increase() over the selected range, same for the other bands.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use increase now.

@alanpeixinho

Copy link
Copy Markdown
Contributor Author
request-by-visitors

@alanpeixinho
alanpeixinho force-pushed the feat/analytics-visitors-by-request-count branch from 2dfe0b8 to 438ba70 Compare October 6, 2026 21:13
* Store each visitor's /api/ request count for the UTC day, capped at 1000
* Refresh that key's TTL on later hits so the 00:15 job still sees it
* Publish one Prometheus sample per visitor into bands from 1-5 through 1000+
* Claim the publish marker before the increment and drop it if the increment fails
* Refuse to publish the current UTC day
* Add the Visitors by request count Grafana bar gauge and cron command

Part of kernelci#2151

Assisted-by: Cursor
Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
@alanpeixinho
alanpeixinho force-pushed the feat/analytics-visitors-by-request-count branch from 438ba70 to affd34a Compare October 7, 2026 17:59
@alanpeixinho
alanpeixinho added this pull request to the merge queue Oct 7, 2026
Merged via the queue into kernelci:main with commit 03bdc5e Oct 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants