Skip to content

PMM-15228 Enrich AuthServer with performance metrics#5658

Draft
maxkondr wants to merge 14 commits into
mainfrom
PMM-15228-pmm-server-performance
Draft

PMM-15228 Enrich AuthServer with performance metrics#5658
maxkondr wants to merge 14 commits into
mainfrom
PMM-15228-pmm-server-performance

Conversation

@maxkondr

@maxkondr maxkondr commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Ticket number: PMM-15228

Percona-Lab/pmm-submodules#4481

This pull request introduces comprehensive Prometheus metrics to the AuthServer in the Grafana authentication service, enabling detailed monitoring of authentication requests, cache performance, and latency. The changes include metric definitions, collection, and registration, as well as instrumentation of key code paths to increment relevant counters and histograms.

Prometheus Metrics Integration:

  • Added Prometheus metric fields and descriptors to the AuthServer struct, including counters for authentication requests, cache hits/misses, in-flight requests, and latency histograms. Implemented the prom.Collector interface with Describe and Collect methods. [1] [2]

  • Instrumented the main authentication flow (ServeHTTP, getLBACFilters, getAuthUser, retrieveRole) to increment metrics for request counts, cache hits/misses, in-flight requests, and operation durations. [1] [2] [3] [4] [5] [6] [7]

Application Integration:

  • Registered the AuthServer as a Prometheus collector in the main application entrypoint to ensure metrics are exposed.

Dependency and Import Updates:

  • Added imports for Prometheus client, atomic operations, and other standard library packages needed for metrics and concurrency.

Other Minor Improvements:

  • Improved code comments and logging level checks for better maintainability and debugging.

These enhancements provide greater observability into authentication performance and reliability, supporting future troubleshooting and scaling efforts.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 54.71698% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.44%. Comparing base (31318c7) to head (54d3d8a).
⚠️ Report is 39 commits behind head on main.

Files with missing lines Patch % Lines
managed/services/grafana/auth_server.go 55.23% 47 Missing ⚠️
managed/cmd/pmm-managed/main.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5658      +/-   ##
==========================================
- Coverage   43.59%   42.44%   -1.15%     
==========================================
  Files         415      431      +16     
  Lines       43134    34925    -8209     
  Branches        0      591     +591     
==========================================
- Hits        18804    14824    -3980     
+ Misses      22454    18675    -3779     
+ Partials     1876     1426     -450     
Flag Coverage Δ
admin 34.96% <ø> (+0.17%) ⬆️
agent ?
managed 43.83% <54.71%> (+0.85%) ⬆️
unittests 41.29% <ø> (?)
vmproxy ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Prometheus observability to the Grafana AuthServer in pmm-managed, exposing request/cache/latency metrics and wiring the server into the Prometheus registry, plus updating the PMM Health Grafana dashboard to visualize the new signals.

Changes:

  • Implemented a custom Prometheus collector in AuthServer with counters/gauges/histograms for auth requests, Grafana calls, cache behavior, in-flight requests, and latencies.
  • Registered the AuthServer collector during pmm-managed startup so metrics are exposed automatically.
  • Updated the PMM Health dashboard to include panels for the new auth metrics and additional runtime/health visualizations.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 9 comments.

File Description
managed/services/grafana/auth_server.go Adds Prometheus metric descriptors/state, implements prometheus.Collector, and instruments key auth/cache/DB/Grafana code paths.
managed/cmd/pmm-managed/main.go Registers the AuthServer as a Prometheus collector at startup.
dashboards/dashboards/PMM Health/PMM_Health.json Adds/adjusts dashboard panels and queries to surface new auth metrics and runtime health info.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread managed/services/grafana/auth_server.go Outdated
Comment thread managed/services/grafana/auth_server.go Outdated
Comment thread managed/services/grafana/auth_server.go Outdated
Comment thread managed/services/grafana/auth_server.go
Comment thread managed/services/grafana/auth_server.go
Comment thread dashboards/dashboards/PMM Health/PMM_Health.json Outdated
Comment thread dashboards/dashboards/PMM Health/PMM_Health.json Outdated
Comment thread dashboards/dashboards/PMM Health/PMM_Health.json Outdated
Comment thread dashboards/dashboards/PMM Health/PMM_Health.json Outdated
maxkondr and others added 10 commits July 16, 2026 19:28
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

Comment thread managed/services/grafana/auth_server.go
Comment thread managed/services/grafana/auth_server.go
Comment thread managed/services/grafana/auth_server.go
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