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.
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.
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.
Index ¶
- Constants
- func Parse(fileContent []byte, m ObjectGeneric, filename string) (manifest.OpenSLOKind, error)
- type AlertCondition
- type AlertConditionInline
- type AlertConditionSpec
- type AlertConditionType
- type AlertNotificationTarget
- type AlertNotificationTargetSpec
- type AlertPolicy
- type AlertPolicyCondition
- type AlertPolicyConditionSpec
- type AlertPolicyNotificationTarget
- type AlertPolicySpec
- type Annotations
- type Calendar
- type ConditionType
- type DataSource
- type DataSourceSpec
- type Labels
- type Metadata
- type MetadataHolder
- type MetricSource
- type MetricSourceHolder
- type MetricSourceSpec
- type ObjectGeneric
- type ObjectHeader
- type Objective
- type ObjectiveBase
- type RatioMetric
- type SLI
- type SLIInline
- type SLISpec
- type SLO
- type SLOSpec
- type Service
- type ServiceSpec
- type TimeWindow
Constants ¶
const ( KindAlertCondition = "AlertCondition" KindAlertNotificationTarget = "AlertNotificationTarget" KindAlertPolicy = "AlertPolicy" KindDataSource = "DataSource" KindSLI = "SLI" KindSLO = "SLO" KindService = "Service" )
Possible values of field kind for valid Objects.
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 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 AlertConditionType ¶
type AlertConditionType string
AlertConditionType is the type of an alert condition.
const ( // AlertConditionTypeBurnRate is the type of a burn rate alert condition. AlertConditionTypeBurnRate AlertConditionType = "burnrate" )
type AlertNotificationTarget ¶
type AlertNotificationTarget struct { ObjectHeader `yaml:",inline"` Spec AlertNotificationTargetSpec `yaml:"spec"` }
AlertNotificationTarget is a target for sending alerts.
func (AlertNotificationTarget) Kind ¶
func (AlertNotificationTarget) Kind() string
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.
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 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 *AlertConditionType `yaml:"kind" validate:"required,oneof=burnrate" example:"burnrate"` Threshold int `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.
type DataSourceSpec ¶
type DataSourceSpec struct { Type string `yaml:"type" validate:"required"` ConnectionDetails map[string]string `yaml:"connectionDetails"` }
DataSourceSpec defines the data source specification.
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.
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.
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.
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.
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.