Repository navigation
feat(analytics): split kci-dev, scripts, and bots from dashboard traffic - #2154
Conversation
* Classify kci-dev, curl/wget/python-requests, and crawlers as their own client * Keep the kci-dev version on the browser label and read OS from the User-Agent * Add a client label to request and unique-visitor counters * Filter the Grafana analytics panels with a Client dropdown Part of kernelci#2144 Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
| browser=UNKNOWN, | ||
| os=UNKNOWN, | ||
| device=UNKNOWN, | ||
| client=Client.DASHBOARD, |
There was a problem hiding this comment.
Empty User-Agent is counted as dashboard. Those requests are not from the web app, so they inflate the dashboard visitors.
There was a problem hiding this comment.
Empty User-Agent is now client=unknown, along with any User-Agent that is not a recognized browser, kci-dev, curl, wget, python-requests, or a bot.
* Time /api/ requests on dashboard_backend_request_latency_seconds by endpoint and client * Keep /admin/ and /health/ on the Django view-latency histogram * Point total calls, average, p50, and p95 at those client series Built on kernelci#2154. Closes kernelci#2149 Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
| if os_family: | ||
| os = KCI_DEV_OS.get(os_family.strip().casefold(), UNKNOWN) | ||
| return ClientInfo( | ||
| browser=f"kci-dev/{version}" if version else "kci-dev", |
There was a problem hiding this comment.
I made a comment for this in another PR in the stack (#2156)
this would create a series for every release of kci-dev
There was a problem hiding this comment.
Awesome to see kci-dev versions!
* Keep the browser label at kci-dev * Count releases on dashboard_kci_dev_requests_by_version_total * Treat a missing or non-release token as unknown * Show versions on a donut filtered by the Client dropdown Part of kernelci#2144 Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
| r"^kci-dev(?:/([^\s/()]+))?(?:\s+\(([^)]+)\))?\s*$", | ||
| re.IGNORECASE, | ||
| ) | ||
| KCI_DEV_VERSION = re.compile(r"^\d+\.\d+\.\d+(?:[a-z0-9.]{0,16})?$", re.IGNORECASE) |
There was a problem hiding this comment.
just a note: I see this matches all the kci-dev versions on https://pypi.org/project/kci-dev/#history
but it is easy to have problems with any rc or non stable versions. eg. 0.1.3.dev1 matches with the regex. But 0.1.3.dev-1 does not. Depends on how the kci-dev decides its version labels
There was a problem hiding this comment.
kci-dev sends the PEP 440 version from Poetry. 0.1.3.dev1 already matches. 0.1.3.dev-1 is not valid PEP 440, so it stays unknown.
* Time /api/ requests on dashboard_backend_request_latency_seconds by endpoint and client * Keep /admin/ and /health/ on the Django view-latency histogram * Point total calls, average, p50, and p95 at those client series Built on kernelci#2154. Closes kernelci#2149 Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
* Time /api/ requests on dashboard_backend_request_latency_seconds by endpoint and client * Keep /admin/ and /health/ on the Django view-latency histogram * Point total calls, average, p50, and p95 at those client series Built on kernelci#2154. Closes kernelci#2149 Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
…2156) * feat(analytics): record API latency by endpoint and client * Time /api/ requests on dashboard_backend_request_latency_seconds by endpoint and client * Keep /admin/ and /health/ on the Django view-latency histogram * Point total calls, average, p50, and p95 at those client series Built on kernelci#2154. Closes kernelci#2149 Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi> * feat(analytics): show 4xx and 5xx by endpoint * Add a panel summed by endpoint and status_class, limited to 4xx and 5xx Part of kernelci#2150 Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi> * test(analytics): stop latency tests clobbering the Django histogram The latency tests replaced the process-wide Prometheus histogram and left it replaced, so the health-skip test saw no /api/ observation once both suites shared a worker. Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi> * fix(analytics): sort request metrics middleware imports Ruff I001 failed pre-commit because prometheus_client sat after the first-party import. Assisted-by: Cursor Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi> * fix(analytics): split API latency by HTTP method GET and POST to the same endpoint were recorded as one series. Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi> * fix(analytics): keep latency on the response and split methods Stop the histogram sample when the response returns, and group the dashboard sums by method so GET and POST stay apart. Assisted-by: Cursor Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi> --------- Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>




What it is
dashboard,kci-dev,script, orbotkci-dev/<version>as the browser, and Linux, macOS, or Windows from(OS)in the User-Agentclientlabel to request counts and daily unique visitorsNew
clientseries start at deploy. Older samples without that label stay in Prometheus until they age out of the selected range.Closes Count kci-dev as its own analytics client #2144
How to test
From
backend/:docker compose -f docker-compose.monitoring.yml up -dPROMETHEUS_METRICS_ENABLED=trueand metrics on port 8001.runserverneeds--noreload./api/requests:client="kci-dev",client="script",client="bot", andclient="dashboard". The kci-dev request series should showbrowser="kci-dev/0.1.11",os="Linux",device="cli".monitoring/dashboard.json. Set the range to the last 15 minutes.stay unchanged, because those series have no
clientlabel.