metrics

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

package metrics is a common package for audito maldito's metrics.

Index

Constants

View Source
const (
	// MetricsNamespace is the namespace for all metrics. This name is
	// prepended to all metrics.
	MetricsNamespace = "audito_maldito"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorType

type ErrorType string
const (
	// ErrorTypeJournaldWait is the error type for errors waiting for journald.
	ErrorTypeJournaldWait ErrorType = "journald_wait"
)

type LoginType

type LoginType string

LoginType is the type of login.

const (
	// SSHLogin is the login type for SSH logins.
	SSHCertLogin LoginType = "ssh-cert"
	// SSHKeyLogin is the login type for SSH key logins.
	SSHKeyLogin LoginType = "ssh-key"
	// SSHCertLogin is the login type for SSH certificate logins.
	PasswordLogin LoginType = "password"
	// PasswordLogin is the login type for password logins.
	UnknownLogin LoginType = "unknown"
)

type OutcomeType

type OutcomeType string
const (
	// Success is the outcome type for successful logins.
	Success OutcomeType = "success"
	// Failure is the outcome type for failed logins.
	Failure OutcomeType = "failure"
)

type PrometheusMetricsProvider

type PrometheusMetricsProvider struct {
	// contains filtered or unexported fields
}

PrometheusMetricsProvider is a metrics provider that uses Prometheus.

func NewPrometheusMetricsProvider

func NewPrometheusMetricsProvider() *PrometheusMetricsProvider

NewPrometheusMetricsProvider returns a new PrometheusMetricsProvider.

func NewPrometheusMetricsProviderForRegisterer

func NewPrometheusMetricsProviderForRegisterer(r prometheus.Registerer) *PrometheusMetricsProvider

NewPrometheusMetricsProviderForRegisterer returns a new PrometheusMetricsProvider that uses the given prometheus.Registerer. The following metrics are registered: - remote_logins_total (counter) - The total number of remote logins.

  • Labels: method, outcome
  • For more information about the labels, see the `LoginType` and `OutcomeType`

- errors_total (counter) - The total number of errors.

  • Labels: type
  • For more information about the labels, see the `ErrorType`

func (*PrometheusMetricsProvider) IncErrors

func (p *PrometheusMetricsProvider) IncErrors(errorType ErrorType)

IncErrors increments the number of errors by the given type.

func (*PrometheusMetricsProvider) IncLogins

func (p *PrometheusMetricsProvider) IncLogins(loginType LoginType, outcome OutcomeType)

IncLogins increments the number of logins by the given type.

func (*PrometheusMetricsProvider) SetAuditLogCheck added in v0.3.0

func (p *PrometheusMetricsProvider) SetAuditLogCheck(result float64, threshold string)

SetAuditCheck sets status of audit.log writes. 0 for negative, 1 for positive.

func (*PrometheusMetricsProvider) SetAuditLogModifyTime added in v0.3.0

func (p *PrometheusMetricsProvider) SetAuditLogModifyTime(result float64)

SetAuditLogModifyTime sets last modify time in seconds.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL