Add Grafana dashboard and wp-prometheus integration (v0.7.5)
All checks were successful
Create Release Package / build-release (push) Successful in 1m9s

- Add example Grafana dashboard with 24 panels for license metrics
- Register dashboard with wp-prometheus via hook
- Add dashboard documentation with PromQL examples and alerting rules
- Update README with monitoring section

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-03 11:29:14 +01:00
parent cfd34c9329
commit 57e1b838cc
7 changed files with 2082 additions and 2 deletions

View File

@@ -2031,3 +2031,39 @@ Added Prometheus metrics integration to expose license and API metrics for monit
- Static methods allow increment from API controllers without dependency injection
- Counter values persist across requests via `wclp_prometheus_counters` option
- Gauges query database on each metric collection (uses existing statistics methods)
### 2026-02-03 - Grafana Dashboard & WP Prometheus Integration
**Overview:**
Added example Grafana dashboard JSON and integrated with wp-prometheus dashboard registration system.
**New files:**
- `docs/grafana-dashboard.json` - Complete Grafana dashboard with 24 panels
- `docs/grafana-dashboard.md` - Installation and usage documentation
**Dashboard panels:**
- License Overview: Total, Active, Lifetime, Expiring Soon, Expired, Revoked stats + pie chart + time series
- Downloads & Versions: Total downloads, active versions, download trends
- API Metrics: Request rates by endpoint/result, pie chart breakdown, top requests table
- Errors & Rate Limiting: Rate limit events, validation errors by type over time
**WP Prometheus integration:**
- Dashboard automatically registered via `wp_prometheus_register_dashboards` hook
- Appears in Settings > WP Prometheus > Dashboards tab when metrics are enabled
- Uses file-based registration with metadata (title, description, icon, plugin attribution)
**Modified files:**
- `src/Metrics/PrometheusController.php` - Added `registerDashboard()` method and hook registration
- `docs/grafana-dashboard.md` - Added wp-prometheus installation option as recommended method
- `README.md` - Added "Monitoring with Prometheus & Grafana" section linking to dashboard docs
**Technical notes:**
- Dashboard registration only occurs when metrics are enabled (same condition as metric collection)
- Uses `dashicons-admin-network` icon for dashboard list
- File path uses `WC_LICENSED_PRODUCT_PLUGIN_DIR` constant for reliable path resolution