Skip to content

[Feature] Additional Policy State Metrics & Configurable Enforce Metric Granularity #5

@Rynzie02

Description

@Rynzie02

This proposal adds two observability improvements to casbin-prometheus-logger:

  1. Expose current policy counts by type ( p, g, g1, g2 , g3 )
  2. Allow optional labels for enforce metrics

Currently, the prometheusLogger focuses on policy operation events (Add / Remove / Load / Save), but lacks visibility into policy state. There is no metric showing how many policy rules are loaded by type, making it hard to monitor permission growth.

In addition, the Enforce metrics are too coarse. casbin_enforce_total only includes allowed and domain (prometheus_logger.go)

enforceTotal: prometheus.NewCounterVec(
			prometheus.CounterOpts{
				Name: "casbin_enforce_total",
				Help: "Total number of enforce requests",
			},
			[]string{"allowed", "domain"},
		),

This makes it difficult to identify high-traffic subjects or debug subject-specific authorization issues.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions