v1

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Overview

Package v1 contains all the types that are exported by the v1 API. Copyright © 2022 OpenSLO Team

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package v1 contains API Schema definitions for the slo v1 API group.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	KindAlertCondition          = "AlertCondition"
	KindAlertNotificationTarget = "AlertNotificationTarget"
	KindAlertPolicy             = "AlertPolicy"
	KindDataSource              = "DataSource"
	KindSLI                     = "SLI"
	KindSLO                     = "SLO"
	KindService                 = "Service"
)

Possible values of field kind for valid Objects.

View Source
const (
	APIVersion = "openslo/v1"
)

APIVersion is a value of valid apiVersions.

Variables

This section is empty.

Functions

func Parse

func Parse(fileContent []byte, m ObjectGeneric, filename, kind string) (manifest.OpenSLOKind, error)

Parse is responsible for parsing all structs in this apiVersion.

Types

type AlertCondition

type AlertCondition struct {
	ObjectHeader `yaml:",inline"`
	Spec         AlertConditionSpec `yaml:"spec"`
}

AlertCondition is a condition that is used to trigger an alert.

func (AlertCondition) Kind

func (AlertCondition) Kind() string

Kind returns the name of this type.

type AlertConditionInline

type AlertConditionInline struct {
	Kind     string             `yaml:"kind" validate:"required"`
	Metadata Metadata           `yaml:"metadata" validate:"required"`
	Spec     AlertConditionSpec `yaml:"spec" validate:"required"`
}

AlertConditionInline is used for inline definitions. It is slightly different from the AlertCondition type because it does not have an APIVersion.

type AlertConditionSpec

type AlertConditionSpec struct {
	Description string `` //nolint:lll
	/* 135-byte string literal not displayed */
	Severity  string        `yaml:"severity" validate:"required" example:"page"`
	Condition ConditionType `yaml:"condition" validate:"required"`
}

AlertConditionSpec is the specification of an alert condition.

type AlertNotificationTarget

type AlertNotificationTarget struct {
	ObjectHeader `yaml:",inline"`
	Spec         AlertNotificationTargetSpec `yaml:"spec"`
}

AlertNotificationTarget is a target for sending alerts.

func (AlertNotificationTarget) Kind

Kind returns the name of this type.

type AlertNotificationTargetSpec

type AlertNotificationTargetSpec struct {
	Target      string `yaml:"target" validate:"required" example:"slack"`
	Description string `yaml:"description,omitempty" validate:"max=1050,omitempty" example:"Sends P1 alert notifications to the slack channel"` //nolint:lll
}

AlertNotificationTargetSpec is the specification of an alert notification target.

type AlertPolicy

type AlertPolicy struct {
	ObjectHeader `yaml:",inline"`
	Spec         AlertPolicySpec `yaml:"spec"`
}

AlertPolicy is a policy for sending alerts.

func (AlertPolicy) Kind

func (AlertPolicy) Kind() string

Kind returns the name of this type.

type AlertPolicyCondition

type AlertPolicyCondition struct {
	*AlertPolicyConditionSpec `yaml:",inline,omitempty" validate:"required_without=AlertConditionInline"`
	*AlertConditionInline     `yaml:",inline,omitempty" validate:"required_without=AlertPolicyConditionSpec"`
}

AlertPolicyCondition is a condition that is used to trigger an alert in an alert policy. It can be either an inline condition or a reference to an alert condition.

type AlertPolicyConditionSpec

type AlertPolicyConditionSpec struct {
	ConditionRef string `yaml:"conditionRef" validate:"max=1050,required" example:"cpu-usage-breach"`
}

AlertPolicyConditionSpec is the specification of an alert policy condition. It is used to reference an AlertCondition.

type AlertPolicyNotificationTarget

type AlertPolicyNotificationTarget struct {
	TargetRef string `yaml:"targetRef" validate:"required" example:"OnCallDevopsMailNotification"`
}

AlertPolicyNotificationTarget is a reference to an AlertNotificationTarget.

type AlertPolicySpec

type AlertPolicySpec struct {
	Description string `` //nolint:lll
	/* 139-byte string literal not displayed */
	AlertWhenNoData     bool                            `yaml:"alertWhenNoData"`
	AlertWhenBreaching  bool                            `yaml:"alertWhenBreaching"`
	AlertWhenResolved   bool                            `yaml:"alertWhenResolved"`
	Conditions          []AlertPolicyCondition          `yaml:"conditions" validate:"required,len=1,dive"`
	NotificationTargets []AlertPolicyNotificationTarget `yaml:"notificationTargets" validate:"required,dive"`
}

AlertPolicySpec is the specification of an alert policy.

type Annotations

type Annotations map[string]string

Annotations is a map of annotations.

type Calendar

type Calendar struct {
	StartTime string `yaml:"startTime" validate:"required,dateWithTime" example:"2020-01-21 12:30:00"`
	TimeZone  string `yaml:"timeZone" validate:"required,timeZone" example:"America/New_York"`
}

Calendar struct represents calendar time window.

type ConditionType

type ConditionType struct {
	Kind           string  `yaml:"kind" validate:"required" example:"burnrate"`
	Threshold      float64 `yaml:"threshold" validate:"required" example:"2"`
	LookbackWindow string  `yaml:"lookbackWindow" validate:"required,validDuration" example:"1h"`
	AlertAfter     string  `yaml:"alertAfter" validate:"required,validDuration" example:"5m"`
}

ConditionType is the type of a condition to trigger an alert.

type DataSource

type DataSource struct {
	ObjectHeader `yaml:",inline"`
	Spec         DataSourceSpec `yaml:"spec" validate:"required"`
}

DataSource defines the data source for the SLI.

func (DataSource) Kind

func (DataSource) Kind() string

Kind returns the name of this type.

type DataSourceSpec

type DataSourceSpec struct {
	Type              string            `yaml:"type" validate:"required"`
	ConnectionDetails map[string]string `yaml:"connectionDetails"`
}

DataSourceSpec defines the data source specification.

type Label added in v0.10.0

type Label []string

func (*Label) UnmarshalYAML added in v0.10.0

func (a *Label) UnmarshalYAML(value *yaml.Node) error

type Labels

type Labels map[string]Label

type Metadata

type Metadata struct {
	Name        string      `yaml:"name" validate:"required" example:"name"`
	DisplayName string      `yaml:"displayName,omitempty" validate:"omitempty,min=0,max=63" example:"Prometheus Source"`
	Labels      Labels      `json:"labels,omitempty" validate:"omitempty"`
	Annotations Annotations `json:"annotations,omitempty" validate:"omitempty"`
}

Metadata represents part of object which is is common for all available Objects, for internal usage.

type MetadataHolder

type MetadataHolder struct {
	Metadata Metadata `yaml:"metadata"`
}

MetadataHolder is an intermediate structure that can provides metadata related field to other structures.

type MetricSource

type MetricSource struct {
	MetricSourceRef  string            `yaml:"metricSourceRef,omitempty" validate:"required_without=MetricSourceSpec"`
	Type             string            `yaml:"type,omitempty" validate:"required_without=MetricSourceRef"`
	MetricSourceSpec map[string]string `yaml:"spec" validate:"required_without=MetricSourceRef"`
}

MetricSource represents the metric source.

func (*MetricSource) UnmarshalYAML added in v0.7.0

func (m *MetricSource) UnmarshalYAML(value *yaml.Node) error

type MetricSourceHolder

type MetricSourceHolder struct {
	MetricSource MetricSource `yaml:"metricSource" validate:"required"`
}

MetricSourceHolder represents the metric source holder.

type MetricSourceSpec

type MetricSourceSpec struct {
	Source    string `yaml:"source" validate:"required,alpha"`
	QueryType string `yaml:"queryType" validate:"required,alpha"`
	Query     string `yaml:"query" validate:"required"`
}

MetricSourceSpec represents the metric source.

type ObjectGeneric

type ObjectGeneric struct {
	ObjectHeader `yaml:",inline"`
}

ObjectGeneric represents struct to which every Objects is parsable Specific types of Object have different structures as Spec.

type ObjectHeader

type ObjectHeader struct {
	manifest.ObjectHeader `yaml:",inline"`
	Kind                  string `` //nolint:lll
	/* 130-byte string literal not displayed */
	MetadataHolder `yaml:",inline"`
}

ObjectHeader represents Header which is common for all available Objects.

type Objective

type Objective struct {
	DisplayName     string  `yaml:"displayName,omitempty"`
	Op              string  `yaml:"op,omitempty" example:"lte"`
	Value           float64 `yaml:"value,omitempty" validate:"numeric,omitempty"`
	Target          float64 `yaml:"target" validate:"required,numeric,gte=0,lt=1" example:"0.9"`
	TimeSliceTarget float64 `yaml:"timeSliceTarget,omitempty" validate:"gte=0,lte=1,omitempty" example:"0.9"`
	TimeSliceWindow string  `yaml:"timeSliceWindow,omitempty" example:"5m"`
}

Objective represents single threshold for SLO, for internal usage.

type ObjectiveBase

type ObjectiveBase struct {
	DisplayName string  `yaml:"displayName" validate:"max=1050" example:"Good"`
	Value       float64 `yaml:"value" validate:"numeric" example:"100"`
}

ObjectiveBase base structure representing a threshold.

type RatioMetric

type RatioMetric struct {
	Counter bool                `yaml:"counter" example:"true"`
	Good    *MetricSourceHolder `yaml:"good,omitempty" validate:"required_without=Bad"`
	Bad     *MetricSourceHolder `yaml:"bad,omitempty" validate:"required_without=Good"`
	Total   MetricSourceHolder  `yaml:"total" validate:"required"`
}

RatioMetric represents the ratio metric.

type SLI

type SLI struct {
	ObjectHeader `yaml:",inline"`
	Spec         SLISpec `yaml:"spec" validate:"required"`
}

SLI represents the SLI.

func (SLI) Kind

func (SLI) Kind() string

Kind returns the name of this type.

type SLIInline

type SLIInline struct {
	Metadata Metadata `yaml:"metadata" validate:"required"`
	Spec     SLISpec  `yaml:"spec" validate:"required"`
}

SLIInline represents the SLI inline.

type SLISpec

type SLISpec struct {
	ThresholdMetric *MetricSourceHolder `yaml:"thresholdMetric,omitempty" validate:"required_without=RatioMetric"`
	RatioMetric     *RatioMetric        `yaml:"ratioMetric,omitempty" validate:"required_without=ThresholdMetric"`
}

SLISpec defines the SLI specification.

type SLO

type SLO struct {
	ObjectHeader `yaml:",inline"`
	Spec         SLOSpec `yaml:"spec" validate:"required"`
}

SLO struct which mapped one to one with kind: slo yaml definition, external usage.

func (SLO) Kind

func (SLO) Kind() string

Kind returns the name of this type.

type SLOSpec

type SLOSpec struct {
	Description     string       `yaml:"description,omitempty" validate:"max=1050,omitempty"`
	Service         string       `yaml:"service" validate:"required" example:"webapp-service"`
	Indicator       *SLIInline   `yaml:"indicator,omitempty" validate:"required_without=IndicatorRef"`
	IndicatorRef    *string      `yaml:"indicatorRef,omitempty"`
	BudgetingMethod string       `yaml:"budgetingMethod" validate:"required,oneof=Occurrences Timeslices" example:"Occurrences"` //nolint:lll
	TimeWindow      []TimeWindow `yaml:"timeWindow" validate:"required,len=1,dive"`
	Objectives      []Objective  `yaml:"objectives" validate:"required,dive"`
	// We don't make clear in the spec if this is a ref or inline.
	// We will make it a ref for now.
	// https://github.com/OpenSLO/OpenSLO/issues/133
	AlertPolicies []string `yaml:"alertPolicies" validate:"dive"`
}

SLOSpec struct which mapped one to one with kind: slo yaml definition, internal use.

type Service

type Service struct {
	ObjectHeader `yaml:",inline"`
	Spec         ServiceSpec `yaml:"spec"`
}

Service struct which mapped one to one with kind: service yaml definition.

func (Service) Kind

func (Service) Kind() string

Kind returns the name of this type.

type ServiceSpec

type ServiceSpec struct {
	Description string `yaml:"description" validate:"max=1050" example:"Bleeding edge web app"`
}

ServiceSpec represents content of Spec typical for Service Object.

type TimeWindow

type TimeWindow struct {
	Duration  string    `yaml:"duration" validate:"required,validDuration" example:"1h"`
	IsRolling bool      `yaml:"isRolling" example:"true"`
	Calendar  *Calendar `yaml:"calendar,omitempty" validate:"required_if=IsRolling false"`
}

TimeWindow represents content of time window.

Jump to

Keyboard shortcuts

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