Documentation
¶
Overview ¶
Package postgres provides PostgreSQL storage for audit logs.
Index ¶
- type Config
- type Store
- func (s *Store) Breakdown(ctx context.Context, filter audit.BreakdownFilter) ([]audit.BreakdownEntry, error)
- func (s *Store) Cleanup(ctx context.Context) error
- func (s *Store) Close() error
- func (s *Store) Count(ctx context.Context, filter audit.QueryFilter) (int, error)
- func (s *Store) Distinct(ctx context.Context, column string, startTime, endTime *time.Time) ([]string, error)
- func (s *Store) Log(ctx context.Context, event audit.Event) error
- func (s *Store) Overview(ctx context.Context, startTime, endTime *time.Time) (*audit.Overview, error)
- func (s *Store) Performance(ctx context.Context, startTime, endTime *time.Time) (*audit.PerformanceStats, error)
- func (s *Store) Query(ctx context.Context, filter audit.QueryFilter) ([]audit.Event, error)
- func (s *Store) StartCleanupRoutine(interval time.Duration)
- func (s *Store) Timeseries(ctx context.Context, filter audit.TimeseriesFilter) ([]audit.TimeseriesBucket, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
RetentionDays int
}
Config configures the PostgreSQL audit store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements audit.Logger using PostgreSQL.
func (*Store) Breakdown ¶ added in v0.17.1
func (s *Store) Breakdown(ctx context.Context, filter audit.BreakdownFilter) ([]audit.BreakdownEntry, error)
Breakdown returns audit event counts grouped by a dimension.
func (*Store) Close ¶
Close cancels the cleanup goroutine and waits for it to exit. It is safe to call Close even if StartCleanupRoutine was never called.
func (*Store) Count ¶ added in v0.17.0
Count returns the number of audit events matching the filter.
func (*Store) Distinct ¶ added in v0.17.1
func (s *Store) Distinct(ctx context.Context, column string, startTime, endTime *time.Time) ([]string, error)
Distinct returns sorted unique values for the given column, scoped by optional time range.
func (*Store) Overview ¶ added in v0.17.1
func (s *Store) Overview(ctx context.Context, startTime, endTime *time.Time) (*audit.Overview, error)
Overview returns aggregate statistics for the given time range.
func (*Store) Performance ¶ added in v0.17.1
func (s *Store) Performance(ctx context.Context, startTime, endTime *time.Time) (*audit.PerformanceStats, error)
Performance returns latency percentile statistics for the given time range.
func (*Store) StartCleanupRoutine ¶
StartCleanupRoutine starts a background goroutine that periodically deletes old audit logs. The goroutine is stopped when Close is called.
func (*Store) Timeseries ¶ added in v0.17.1
func (s *Store) Timeseries(ctx context.Context, filter audit.TimeseriesFilter) ([]audit.TimeseriesBucket, error)
Timeseries returns audit event counts bucketed by the given resolution.