mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-06 10:21:05 +02:00
identity: record metric for last refresh (#1936)
This commit is contained in:
parent
218acc001b
commit
138df5ae24
2 changed files with 27 additions and 1 deletions
|
@ -20,6 +20,7 @@ import (
|
||||||
"github.com/pomerium/pomerium/internal/identity/identity"
|
"github.com/pomerium/pomerium/internal/identity/identity"
|
||||||
"github.com/pomerium/pomerium/internal/log"
|
"github.com/pomerium/pomerium/internal/log"
|
||||||
"github.com/pomerium/pomerium/internal/scheduler"
|
"github.com/pomerium/pomerium/internal/scheduler"
|
||||||
|
"github.com/pomerium/pomerium/internal/telemetry/metrics"
|
||||||
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
||||||
"github.com/pomerium/pomerium/pkg/grpc/session"
|
"github.com/pomerium/pomerium/pkg/grpc/session"
|
||||||
"github.com/pomerium/pomerium/pkg/grpc/user"
|
"github.com/pomerium/pomerium/pkg/grpc/user"
|
||||||
|
@ -213,6 +214,8 @@ func (mgr *Manager) refreshDirectoryUserGroups(ctx context.Context) {
|
||||||
|
|
||||||
mgr.mergeGroups(ctx, directoryGroups)
|
mgr.mergeGroups(ctx, directoryGroups)
|
||||||
mgr.mergeUsers(ctx, directoryUsers)
|
mgr.mergeUsers(ctx, directoryUsers)
|
||||||
|
|
||||||
|
metrics.RecordIdentityManagerLastRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mgr *Manager) mergeGroups(ctx context.Context, directoryGroups []*directory.Group) {
|
func (mgr *Manager) mergeGroups(ctx context.Context, directoryGroups []*directory.Group) {
|
||||||
|
|
|
@ -15,7 +15,11 @@ import (
|
||||||
var (
|
var (
|
||||||
// InfoViews contains opencensus views for informational metrics about
|
// InfoViews contains opencensus views for informational metrics about
|
||||||
// pomerium itself.
|
// pomerium itself.
|
||||||
InfoViews = []*view.View{ConfigLastReloadView, ConfigLastReloadSuccessView}
|
InfoViews = []*view.View{
|
||||||
|
ConfigLastReloadView,
|
||||||
|
ConfigLastReloadSuccessView,
|
||||||
|
IdentityManagerLastRefreshView,
|
||||||
|
}
|
||||||
|
|
||||||
configLastReload = stats.Int64(
|
configLastReload = stats.Int64(
|
||||||
"config_last_reload_success_timestamp",
|
"config_last_reload_success_timestamp",
|
||||||
|
@ -25,6 +29,11 @@ var (
|
||||||
"config_last_reload_success",
|
"config_last_reload_success",
|
||||||
"Returns 1 if last reload was successful",
|
"Returns 1 if last reload was successful",
|
||||||
"1")
|
"1")
|
||||||
|
identityManagerLastRefresh = stats.Int64(
|
||||||
|
"identity_manager_last_refresh_timestamp",
|
||||||
|
"Timestamp of last directory refresh",
|
||||||
|
"seconds",
|
||||||
|
)
|
||||||
|
|
||||||
// ConfigLastReloadView contains the timestamp the configuration was last
|
// ConfigLastReloadView contains the timestamp the configuration was last
|
||||||
// reloaded, labeled by service.
|
// reloaded, labeled by service.
|
||||||
|
@ -45,8 +54,22 @@ var (
|
||||||
TagKeys: []tag.Key{TagKeyService},
|
TagKeys: []tag.Key{TagKeyService},
|
||||||
Aggregation: view.LastValue(),
|
Aggregation: view.LastValue(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IdentityManagerLastRefreshView contains the timestamp the identity manager
|
||||||
|
// was last refreshed, labeled by service.
|
||||||
|
IdentityManagerLastRefreshView = &view.View{
|
||||||
|
Name: identityManagerLastRefresh.Name(),
|
||||||
|
Description: identityManagerLastRefresh.Description(),
|
||||||
|
Measure: identityManagerLastRefresh,
|
||||||
|
Aggregation: view.LastValue(),
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// RecordIdentityManagerLastRefresh records that the identity manager refreshed users and groups.
|
||||||
|
func RecordIdentityManagerLastRefresh() {
|
||||||
|
stats.Record(context.Background(), identityManagerLastRefresh.M(time.Now().Unix()))
|
||||||
|
}
|
||||||
|
|
||||||
// SetConfigInfo records the status, checksum and timestamp of a configuration
|
// SetConfigInfo records the status, checksum and timestamp of a configuration
|
||||||
// reload. You must register InfoViews or the related config views before calling
|
// reload. You must register InfoViews or the related config views before calling
|
||||||
func SetConfigInfo(service string, success bool) {
|
func SetConfigInfo(service string, success bool) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue