Files
Charon/backend/internal/metrics/metrics.go
T
GitHub Actions 34347b1ff5 Refactor uptime service and tests; add WAF configuration UI and e2e tests
- Refactored `SyncMonitors` method in `uptime_service.go` for better readability.
- Updated unit tests for `UptimeService` to ensure proper functionality.
- Introduced Playwright configuration for end-to-end testing.
- Added e2e tests for WAF blocking and monitoring functionality.
- Enhanced the Security page to include WAF mode and rule set selection.
- Implemented tests for WAF configuration changes and validation.
- Created a `.last-run.json` file to store test results.
2025-12-02 02:51:50 +00:00

35 lines
1.1 KiB
Go

package metrics
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
wafRequestsTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: "charon_waf_requests_total",
Help: "Total number of requests evaluated by WAF",
})
wafBlockedTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: "charon_waf_blocked_total",
Help: "Total number of requests blocked by WAF",
})
wafMonitoredTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: "charon_waf_monitored_total",
Help: "Total number of requests monitored (not blocked) by WAF",
})
)
// Register registers Prometheus collectors. Call once at startup.
func Register(registry *prometheus.Registry) {
registry.MustRegister(wafRequestsTotal, wafBlockedTotal, wafMonitoredTotal)
}
// IncWAFRequest increments the evaluated requests counter.
func IncWAFRequest() { wafRequestsTotal.Inc() }
// IncWAFBlocked increments the blocked requests counter.
func IncWAFBlocked() { wafBlockedTotal.Inc() }
// IncWAFMonitored increments the monitored requests counter.
func IncWAFMonitored() { wafMonitoredTotal.Inc() }