k8sprometheus

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 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 added in v0.2.0

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

func NewCRSpecLoader added in v0.3.0

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

func (CRSpecLoader) LoadSpec added in v0.3.0

type DryRunKubernetesService added in v0.6.0

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

func NewKubernetesServiceDryRun added in v0.6.0

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 added in v0.6.0

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

func (DryRunKubernetesService) EnsurePrometheusServiceLevelStatus added in v0.6.0

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

func (DryRunKubernetesService) ListPrometheusServiceLevels added in v0.6.0

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

func (DryRunKubernetesService) WatchPrometheusServiceLevels added in v0.6.0

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

type FakeKubernetesService added in v0.6.0

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

func NewKubernetesServiceFake added in v0.6.0

func NewKubernetesServiceFake(logger log.Logger) FakeKubernetesService

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

func (FakeKubernetesService) EnsurePrometheusRule added in v0.6.0

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

func (FakeKubernetesService) EnsurePrometheusServiceLevelStatus added in v0.6.0

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

func (FakeKubernetesService) ListPrometheusServiceLevels added in v0.6.0

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

func (FakeKubernetesService) WatchPrometheusServiceLevels added in v0.6.0

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 added in v0.2.0

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

func NewKubernetesService added in v0.2.0

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

NewKubernetesService returns a new Kubernetes Service.

func (KubernetesService) EnsurePrometheusRule added in v0.2.0

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

func (KubernetesService) EnsurePrometheusServiceLevelStatus added in v0.2.0

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 added in v0.2.0

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

func (KubernetesService) WatchPrometheusServiceLevels added in v0.2.0

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

type PrometheusOperatorCRDRepo added in v0.2.0

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 added in v0.2.0

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

func (PrometheusOperatorCRDRepo) StoreSLOs added in v0.2.0

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

type PrometheusRulesEnsurer added in v0.2.0

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

type SLIPluginRepo added in v0.5.0

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 added in v0.3.0

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

NewYAMLSpecLoader returns a YAML spec loader.

func (YAMLSpecLoader) IsSpecType added in v0.6.0

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

func (YAMLSpecLoader) LoadSpec added in v0.3.0

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