k8sprometheus

package
v0.0.0-...-e8427ed Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoSLORules will be used when there are no rules to store. The upper layer
	// could ignore or handle the error in cases where there wasn't an output.
	ErrNoSLORules = fmt.Errorf("0 SLO Prometheus rules generated")
)

Functions

This section is empty.

Types

type CRSpecLoader

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

func NewCRSpecLoader

func NewCRSpecLoader(pluginsRepo SLIPluginRepo, windowPeriod time.Duration) CRSpecLoader

func (CRSpecLoader) LoadSpec

type DryRunKubernetesService

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

func NewKubernetesServiceDryRun

func NewKubernetesServiceDryRun(svc KubernetesService, logger log.Logger) DryRunKubernetesService

NewKubernetesServiceDryRun returns a new Kubernetes Service that will dry-run that will only do real ReadOnly operations.

func (DryRunKubernetesService) EnsurePrometheusRule

func (d DryRunKubernetesService) EnsurePrometheusRule(ctx context.Context, pr *monitoringv1.PrometheusRule) error

func (DryRunKubernetesService) EnsurePrometheusServiceLevelStatus

func (d DryRunKubernetesService) EnsurePrometheusServiceLevelStatus(ctx context.Context, slo *slothv1.PrometheusServiceLevel, err error) error

func (DryRunKubernetesService) ListPrometheusServiceLevels

func (d DryRunKubernetesService) ListPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (*slothv1.PrometheusServiceLevelList, error)

func (DryRunKubernetesService) WatchPrometheusServiceLevels

func (d DryRunKubernetesService) WatchPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (watch.Interface, error)

type FakeKubernetesService

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

func NewKubernetesServiceFake

func NewKubernetesServiceFake(logger log.Logger) FakeKubernetesService

NewKubernetesServiceFake returns a new Kubernetes Service that will fake Kubernetes operations using fake clients.

func (FakeKubernetesService) EnsurePrometheusRule

func (f FakeKubernetesService) EnsurePrometheusRule(ctx context.Context, pr *monitoringv1.PrometheusRule) error

func (FakeKubernetesService) EnsurePrometheusServiceLevelStatus

func (f FakeKubernetesService) EnsurePrometheusServiceLevelStatus(ctx context.Context, slo *slothv1.PrometheusServiceLevel, err error) error

func (FakeKubernetesService) ListPrometheusServiceLevels

func (f FakeKubernetesService) ListPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (*slothv1.PrometheusServiceLevelList, error)

func (FakeKubernetesService) WatchPrometheusServiceLevels

func (f FakeKubernetesService) WatchPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (watch.Interface, error)

type IOWriterPrometheusOperatorYAMLRepo

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

IOWriterPrometheusOperatorYAMLRepo knows to store all the SLO rules (recordings and alerts) grouped in an IOWriter in Kubernetes prometheus operator YAML format.

func NewIOWriterPrometheusOperatorYAMLRepo

func NewIOWriterPrometheusOperatorYAMLRepo(writer io.Writer, logger log.Logger) IOWriterPrometheusOperatorYAMLRepo

func (IOWriterPrometheusOperatorYAMLRepo) StoreSLOs

type K8sMeta

type K8sMeta struct {
	Kind        string `validate:"required"`
	APIVersion  string `validate:"required"`
	Name        string `validate:"required"`
	UID         string
	Namespace   string
	Annotations map[string]string
	Labels      map[string]string
}

K8sMeta is the Kubernetes metadata simplified.

type KubernetesService

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

func NewKubernetesService

func NewKubernetesService(slothCli slothclientset.Interface, monitoringCli monitoringclientset.Interface, logger log.Logger) KubernetesService

NewKubernetesService returns a new Kubernetes Service.

func (KubernetesService) EnsurePrometheusRule

func (k KubernetesService) EnsurePrometheusRule(ctx context.Context, pr *monitoringv1.PrometheusRule) error

func (KubernetesService) EnsurePrometheusServiceLevelStatus

func (k KubernetesService) EnsurePrometheusServiceLevelStatus(ctx context.Context, slo *slothv1.PrometheusServiceLevel, err error) error

EnsurePrometheusServiceLevelStatus updates the status of a PrometheusServiceLeve, be aware that updating an status will trigger a watch update event on a controller. In case of no error we will update "last correct Prometheus operation rules generated" TS so we can be in a infinite loop of handling, the handler should break this loop somehow (e.g: if ok and last generated < 5m, ignore).

func (KubernetesService) ListPrometheusServiceLevels

func (k KubernetesService) ListPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (*slothv1.PrometheusServiceLevelList, error)

func (KubernetesService) WatchPrometheusServiceLevels

func (k KubernetesService) WatchPrometheusServiceLevels(ctx context.Context, ns string, opts metav1.ListOptions) (watch.Interface, error)

type PrometheusOperatorCRDRepo

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

PrometheusOperatorCRDRepo knows to store all the SLO rules (recordings and alerts) grouped as a Kubernetes prometheus operator CR using Kubernetes API server.

func NewPrometheusOperatorCRDRepo

func NewPrometheusOperatorCRDRepo(ensurer PrometheusRulesEnsurer, logger log.Logger) PrometheusOperatorCRDRepo

func (PrometheusOperatorCRDRepo) StoreSLOs

func (p PrometheusOperatorCRDRepo) StoreSLOs(ctx context.Context, kmeta K8sMeta, slos []StorageSLO) error

type PrometheusRulesEnsurer

type PrometheusRulesEnsurer interface {
	EnsurePrometheusRule(ctx context.Context, pr *monitoringv1.PrometheusRule) error
}

type SLIPluginRepo

type SLIPluginRepo interface {
	GetSLIPlugin(ctx context.Context, id string) (*prometheus.SLIPlugin, error)
}

type SLOGroup

type SLOGroup struct {
	K8sMeta K8sMeta
	prometheus.SLOGroup
}

SLOGroup is a Kubernetes SLO group. Is created based on a regular Prometheus SLO model and Kubernetes data.

func (SLOGroup) Validate

func (s SLOGroup) Validate() error

Validate validates the SLO.

type StorageSLO

type StorageSLO struct {
	SLO   prometheus.SLO
	Rules prometheus.SLORules
}

type YAMLSpecLoader

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

YAMLSpecLoader knows how to load Kubernetes ServiceLevel YAML specs and converts them to a model.

func NewYAMLSpecLoader

func NewYAMLSpecLoader(pluginsRepo SLIPluginRepo, windowPeriod time.Duration) YAMLSpecLoader

NewYAMLSpecLoader returns a YAML spec loader.

func (YAMLSpecLoader) IsSpecType

func (y YAMLSpecLoader) IsSpecType(ctx context.Context, data []byte) bool

func (YAMLSpecLoader) LoadSpec

func (y YAMLSpecLoader) LoadSpec(ctx context.Context, data []byte) (*SLOGroup, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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