Documentation ¶
Overview ¶
Package slo defines SLO object definitions.
Index ¶
- Constants
- Variables
- func WhenDelayedNames() []string
- type AmazonPrometheusMetric
- type AnomalyConfig
- type AnomalyConfigAlertMethod
- type AnomalyConfigNoData
- type AppDynamicsMetric
- type Attachment
- type AzureMonitorMetric
- type AzureMonitorMetricDimension
- type AzureMonitorMetricLogAnalyticsWorkspace
- type AzurePrometheusMetric
- type BigQueryMetric
- type BudgetingMethod
- type Calendar
- type CloudWatchMetric
- type CloudWatchMetricDimension
- type Components
- type Composite
- type CompositeBurnRateCondition
- type CompositeObjective
- type CompositeSpec
- type CompositeVersion
- type CountMetricsSpec
- type DatadogMetric
- type DynatraceMetric
- type ElasticsearchMetric
- type ErrorDetails
- type GCMMetric
- type GenericMetric
- type GrafanaLokiMetric
- type GraphiteMetric
- type HoneycombMetric
- type Indicator
- type InfluxDBMetric
- type InstanaApplicationMetricGroupBy
- type InstanaApplicationMetricType
- type InstanaInfrastructureMetricType
- type InstanaMetric
- type LightstepMetric
- type LogicMonitorMetric
- type Metadata
- type MetricSourceSpec
- type MetricSpec
- type NewRelicMetric
- type Objective
- type ObjectiveBase
- type ObjectiveIndicatorValidationStatus
- type OpenTSDBMetric
- type Period
- type PingdomMetric
- type ProcessStatus
- type PrometheusMetric
- type QueryValidationStatus
- type RawMetricSpec
- type RedshiftMetric
- type ReplayStatusdeprecated
- type SLO
- func (s SLO) GetKind() manifest.Kind
- func (s SLO) GetManifestSource() string
- func (s SLO) GetName() string
- func (s SLO) GetOrganization() string
- func (s SLO) GetProject() string
- func (s SLO) GetValidator() govy.Validator[SLO]
- func (s SLO) GetVersion() manifest.Version
- func (s SLO) SetManifestSource(src string) manifest.Object
- func (s SLO) SetOrganization(org string) manifest.Object
- func (s SLO) SetProject(project string) manifest.Object
- func (s SLO) Validate() error
- type Spec
- func (s *Spec) AllMetricSpecs() []*MetricSpec
- func (s *Spec) CountMetricPairs() []*CountMetricsSpec
- func (s *Spec) CountMetrics() []*MetricSpec
- func (s *Spec) CountMetricsCount() int
- func (s *Spec) GoodTotalCountMetrics() (good, total []*MetricSpec)
- func (s *Spec) HasCompositeObjectives() bool
- func (s *Spec) HasCountMetrics() bool
- func (s *Spec) HasRawMetric() bool
- func (s *Spec) IsComposite() bool
- func (s *Spec) ObjectivesRawMetricsCount() int
- func (s *Spec) RawMetrics() []*MetricSpec
- type SplunkMetric
- type SplunkObservabilityMetric
- type Status
- type SumoLogicMetric
- type TargetSloStatus
- type ThousandEyesMetric
- type TimeWindow
- type ValidationDetails
- type ValidationStatus
- type WhenDelayed
Examples ¶
Constants ¶
const ( AzureMonitorDataTypeMetrics = "metrics" AzureMonitorDataTypeLogs = "logs" )
const ( LightstepMetricDataType = "metric" LightstepLatencyDataType = "latency" LightstepErrorRateDataType = "error_rate" LightstepTotalCountDataType = "total" LightstepGoodCountDataType = "good" )
const ( PingdomTypeUptime = "uptime" PingdomTypeTransaction = "transaction" )
const ( ThousandEyesNetLatency = "net-latency" ThousandEyesNetLoss = "net-loss" ThousandEyesWebPageLoad = "web-page-load" ThousandEyesWebDOMLoad = "web-dom-load" ThousandEyesHTTPResponseTime = "http-response-time" ThousandEyesServerAvailability = "http-server-availability" ThousandEyesServerThroughput = "http-server-throughput" ThousandEyesServerTotalTime = "http-server-total-time" ThousandEyesDNSServerResolutionTime = "dns-server-resolution-time" ThousandEyesDNSSECValid = "dns-dnssec-valid" )
Variables ¶
var CountMetricsSpecValidation = govy.New[CountMetricsSpec]( govy.For(govy.GetSelf[CountMetricsSpec]()). Rules( rules.MutuallyExclusive(true, map[string]func(CountMetricsSpec) any{ "total": func(c CountMetricsSpec) any { return c.TotalMetric }, "goodTotal": func(c CountMetricsSpec) any { return c.GoodTotalMetric }, }), ), govy.For(govy.GetSelf[CountMetricsSpec]()). When(func(c CountMetricsSpec) bool { return c.TotalMetric != nil }). Rules( rules.MutuallyExclusive(true, map[string]func(CountMetricsSpec) any{ "good": func(c CountMetricsSpec) any { return c.GoodMetric }, "bad": func(c CountMetricsSpec) any { return c.BadMetric }, }), ). Include( azureMonitorCountMetricsLevelValidation, appDynamicsCountMetricsLevelValidation, lightstepCountMetricsLevelValidation, pingdomCountMetricsLevelValidation, sumoLogicCountMetricsLevelValidation, instanaCountMetricsLevelValidation, redshiftCountMetricsLevelValidation, bigQueryCountMetricsLevelValidation, gcmCountMetricsLevelValidation, ). Include( goodAndBadOverTotalMetricsValidation, ), govy.For(govy.GetSelf[CountMetricsSpec]()). When(func(c CountMetricsSpec) bool { return c.GoodTotalMetric != nil }). Include( goodTotalSingleQueryMetricsValidation, ), govy.ForPointer(func(c CountMetricsSpec) *bool { return c.Incremental }). WithName("incremental"). Required(), ). Cascade(govy.CascadeModeStop)
var ErrInvalidWhenDelayed = fmt.Errorf("not a valid WhenDelayed, try [%s]", strings.Join(_WhenDelayedNames, ", "))
var RawMetricsValidation = govy.New[RawMetricSpec]( govy.ForPointer(func(r RawMetricSpec) *MetricSpec { return r.MetricQuery }). WithName("query"). Required(). Include( metricSpecValidation, lightstepRawMetricValidation, pingdomRawMetricValidation, thousandEyesRawMetricValidation, instanaRawMetricValidation), )
Functions ¶
func WhenDelayedNames ¶ added in v0.79.0
func WhenDelayedNames() []string
WhenDelayedNames returns a list of possible string values of WhenDelayed.
Types ¶
type AmazonPrometheusMetric ¶
type AmazonPrometheusMetric struct {
PromQL *string `json:"promql"`
}
AmazonPrometheusMetric represents metric from Amazon Managed Prometheus
type AnomalyConfig ¶
type AnomalyConfig struct {
NoData *AnomalyConfigNoData `json:"noData"`
}
AnomalyConfig represents relationship between anomaly type and selected notification methods. This will be removed (moved into Anomaly Policy) in PC-8502
type AnomalyConfigAlertMethod ¶
type AnomalyConfigAlertMethod struct { Name string `json:"name"` Project string `json:"project,omitempty"` }
AnomalyConfigAlertMethod represents a single alert method used in AnomalyConfig defined by name and project.
type AnomalyConfigNoData ¶
type AnomalyConfigNoData struct {
AlertMethods []AnomalyConfigAlertMethod `json:"alertMethods"`
}
AnomalyConfigNoData contains alertMethods used for No Data anomaly type.
type AppDynamicsMetric ¶
type AppDynamicsMetric struct { ApplicationName *string `json:"applicationName"` MetricPath *string `json:"metricPath"` }
AppDynamicsMetric represents metric from AppDynamics
type Attachment ¶
type Attachment struct { URL string `json:"url"` DisplayName *string `json:"displayName,omitempty"` }
Attachment represents user defined URL attached to SLO.
type AzureMonitorMetric ¶
type AzureMonitorMetric struct { DataType string `json:"dataType"` ResourceID string `json:"resourceId,omitempty"` MetricName string `json:"metricName,omitempty"` Aggregation string `json:"aggregation,omitempty"` Dimensions []AzureMonitorMetricDimension `json:"dimensions,omitempty"` MetricNamespace string `json:"metricNamespace,omitempty"` Workspace *AzureMonitorMetricLogAnalyticsWorkspace `json:"workspace,omitempty"` KQLQuery string `json:"kqlQuery,omitempty"` }
AzureMonitorMetric represents metric from AzureMonitor
type AzureMonitorMetricDimension ¶
AzureMonitorMetricDimension represents name/value pair that is part of the identity of a metric.
type AzureMonitorMetricLogAnalyticsWorkspace ¶ added in v0.69.0
type AzureMonitorMetricLogAnalyticsWorkspace struct { SubscriptionID string `json:"subscriptionId"` ResourceGroup string `json:"resourceGroup"` WorkspaceID string `json:"workspaceId"` }
AzureMonitorMetricLogAnalyticsWorkspace represents Azure Log Analytics Workspace
type AzurePrometheusMetric ¶ added in v0.83.0
type AzurePrometheusMetric struct {
PromQL string `json:"promql"`
}
AzurePrometheusMetric represents metric from Azure Monitor managed service for Prometheus
type BigQueryMetric ¶
type BigQueryMetric struct { Query string `json:"query"` ProjectID string `json:"projectId"` Location string `json:"location"` }
BigQueryMetric represents metric from BigQuery
type BudgetingMethod ¶
type BudgetingMethod int
BudgetingMethod indicates algorithm to calculate error budget
const ( // BudgetingMethodOccurrences method uses ratio of counts of good events and total count of event BudgetingMethodOccurrences BudgetingMethod = iota + 1 // BudgetingMethodTimeslices method uses ratio of good time slices vs. total time slices in a budgeting period BudgetingMethodTimeslices )
func ParseBudgetingMethod ¶
func ParseBudgetingMethod(value string) (BudgetingMethod, error)
func (BudgetingMethod) String ¶
func (m BudgetingMethod) String() string
type CloudWatchMetric ¶
type CloudWatchMetric struct { Region *string `json:"region"` Namespace *string `json:"namespace,omitempty"` MetricName *string `json:"metricName,omitempty"` Stat *string `json:"stat,omitempty"` Dimensions []CloudWatchMetricDimension `json:"dimensions,omitempty"` AccountID *string `json:"accountId,omitempty"` SQL *string `json:"sql,omitempty"` JSON *string `json:"json,omitempty"` }
CloudWatchMetric represents metric from CloudWatch.
func (CloudWatchMetric) IsJSONConfiguration ¶
func (c CloudWatchMetric) IsJSONConfiguration() bool
IsJSONConfiguration returns true if the struct represents CloudWatch JSON configuration.
func (CloudWatchMetric) IsSQLConfiguration ¶
func (c CloudWatchMetric) IsSQLConfiguration() bool
IsSQLConfiguration returns true if the struct represents CloudWatch SQL configuration.
func (CloudWatchMetric) IsStandardConfiguration ¶
func (c CloudWatchMetric) IsStandardConfiguration() bool
IsStandardConfiguration returns true if the struct represents CloudWatch standard configuration.
type CloudWatchMetricDimension ¶
CloudWatchMetricDimension represents name/value pair that is part of the identity of a metric.
type Components ¶ added in v0.79.0
type Components struct {
Objectives []CompositeObjective `json:"objectives"`
}
type Composite ¶
type Composite struct { BudgetTarget *float64 `json:"target"` BurnRateCondition *CompositeBurnRateCondition `json:"burnRateCondition,omitempty"` }
Composite represents configuration for Composite SLO. Deprecated: this implementation of Composite will be removed and replaced with SLO.Spec.Objectives.Composite.
type CompositeBurnRateCondition ¶
CompositeBurnRateCondition represents configuration for Composite SLO with occurrences budgeting method.
type CompositeObjective ¶ added in v0.79.0
type CompositeObjective struct { Project string `json:"project"` SLO string `json:"slo"` Objective string `json:"objective"` Weight float64 `json:"weight"` WhenDelayed WhenDelayed `json:"whenDelayed"` }
type CompositeSpec ¶ added in v0.79.0
type CompositeSpec struct { MaxDelay string `json:"maxDelay"` Components `json:"components"` }
CompositeSpec represents a composite of SLOs and Composite SLOs.
type CompositeVersion ¶
CompositeVersion represents composite version history stored for restoring process.
type CountMetricsSpec ¶
type CountMetricsSpec struct { Incremental *bool `json:"incremental"` GoodMetric *MetricSpec `json:"good,omitempty"` BadMetric *MetricSpec `json:"bad,omitempty"` TotalMetric *MetricSpec `json:"total,omitempty"` // Experimental: Splunk and Honeycomb only. // Single query returning both good and total counts. GoodTotalMetric *MetricSpec `json:"goodTotal,omitempty"` }
CountMetricsSpec represents set of two time series of good and total counts
type DatadogMetric ¶
type DatadogMetric struct {
Query *string `json:"query"`
}
DatadogMetric represents metric from Datadog
type DynatraceMetric ¶
type DynatraceMetric struct {
MetricSelector *string `json:"metricSelector"`
}
DynatraceMetric represents metric from Dynatrace.
type ElasticsearchMetric ¶
ElasticsearchMetric represents metric from Elasticsearch.
type ErrorDetails ¶ added in v0.91.0
type GCMMetric ¶
type GCMMetric struct { Query string `json:"query,omitempty"` ProjectID string `json:"projectId"` PromQL string `json:"promql,omitempty"` }
GCMMetric represents metric from GCM
func (GCMMetric) IsMQLConfiguration ¶ added in v0.89.0
IsMQLConfiguration returns true if the metric is configured with MQL query.
func (GCMMetric) IsPromqlConfiguration ¶ added in v0.89.0
IsPromqlConfiguration returns true if the metric is configured with promql query.
type GenericMetric ¶
type GenericMetric struct {
Query *string `json:"query"`
}
type GrafanaLokiMetric ¶
type GrafanaLokiMetric struct {
Logql *string `json:"logql"`
}
GrafanaLokiMetric represents metric from GrafanaLokiMetric.
type GraphiteMetric ¶
type GraphiteMetric struct {
MetricPath *string `json:"metricPath"`
}
GraphiteMetric represents metric from Graphite.
type HoneycombMetric ¶
type HoneycombMetric struct { // Deprecated: Once Honeycomb good/bad over total and raw metrics support will be discontinued, // this property will be removed. Calculation string `json:"calculation,omitempty"` Attribute string `json:"attribute"` }
HoneycombMetric represents metric from Honeycomb.
type Indicator ¶
type Indicator struct { MetricSource MetricSourceSpec `json:"metricSource"` RawMetric *MetricSpec `json:"rawMetric,omitempty"` }
Indicator represents integration with metric source can be. e.g. Prometheus, Datadog, for internal usage.
type InfluxDBMetric ¶
type InfluxDBMetric struct {
Query *string `json:"query"`
}
InfluxDBMetric represents metric from InfluxDB
type InstanaApplicationMetricType ¶
type InstanaApplicationMetricType struct { MetricID string `json:"metricId"` Aggregation string `json:"aggregation"` GroupBy InstanaApplicationMetricGroupBy `json:"groupBy"` APIQuery string `json:"apiQuery"` IncludeInternal bool `json:"includeInternal,omitempty"` IncludeSynthetic bool `json:"includeSynthetic,omitempty"` }
type InstanaMetric ¶
type InstanaMetric struct { MetricType string `json:"metricType"` Infrastructure *InstanaInfrastructureMetricType `json:"infrastructure,omitempty"` Application *InstanaApplicationMetricType `json:"application,omitempty"` }
InstanaMetric represents metric from Redshift.
type LightstepMetric ¶
type LightstepMetric struct { StreamID *string `json:"streamId,omitempty"` TypeOfData *string `json:"typeOfData"` Percentile *float64 `json:"percentile,omitempty"` UQL *string `json:"uql,omitempty"` }
LightstepMetric represents metric from Lightstep
type LogicMonitorMetric ¶ added in v0.82.0
type LogicMonitorMetric struct { QueryType string `json:"queryType"` DeviceDataSourceInstanceID int `json:"deviceDataSourceInstanceId"` GraphID int `json:"graphId"` Line string `json:"line"` }
LogicMonitorMetric represents metric from LogicMonitor
type Metadata ¶
type Metadata struct { Name string `json:"name"` DisplayName string `json:"displayName,omitempty"` Project string `json:"project,omitempty"` Labels v1alpha.Labels `json:"labels,omitempty"` Annotations v1alpha.MetadataAnnotations `json:"annotations,omitempty"` }
Metadata provides identity information for SLO.
type MetricSourceSpec ¶
type MetricSpec ¶
type MetricSpec struct { Prometheus *PrometheusMetric `json:"prometheus,omitempty"` Datadog *DatadogMetric `json:"datadog,omitempty"` NewRelic *NewRelicMetric `json:"newRelic,omitempty"` AppDynamics *AppDynamicsMetric `json:"appDynamics,omitempty"` Splunk *SplunkMetric `json:"splunk,omitempty"` Lightstep *LightstepMetric `json:"lightstep,omitempty"` SplunkObservability *SplunkObservabilityMetric `json:"splunkObservability,omitempty"` Dynatrace *DynatraceMetric `json:"dynatrace,omitempty"` Elasticsearch *ElasticsearchMetric `json:"elasticsearch,omitempty"` ThousandEyes *ThousandEyesMetric `json:"thousandEyes,omitempty"` Graphite *GraphiteMetric `json:"graphite,omitempty"` BigQuery *BigQueryMetric `json:"bigQuery,omitempty"` OpenTSDB *OpenTSDBMetric `json:"opentsdb,omitempty"` GrafanaLoki *GrafanaLokiMetric `json:"grafanaLoki,omitempty"` CloudWatch *CloudWatchMetric `json:"cloudWatch,omitempty"` Pingdom *PingdomMetric `json:"pingdom,omitempty"` AmazonPrometheus *AmazonPrometheusMetric `json:"amazonPrometheus,omitempty"` Redshift *RedshiftMetric `json:"redshift,omitempty"` SumoLogic *SumoLogicMetric `json:"sumoLogic,omitempty"` Instana *InstanaMetric `json:"instana,omitempty"` InfluxDB *InfluxDBMetric `json:"influxdb,omitempty"` GCM *GCMMetric `json:"gcm,omitempty"` AzureMonitor *AzureMonitorMetric `json:"azureMonitor,omitempty"` Generic *GenericMetric `json:"generic,omitempty"` Honeycomb *HoneycombMetric `json:"honeycomb,omitempty"` LogicMonitor *LogicMonitorMetric `json:"logicMonitor,omitempty"` AzurePrometheus *AzurePrometheusMetric `json:"azurePrometheus,omitempty"` }
MetricSpec defines single time series obtained from data source
func (*MetricSpec) DataSourceType ¶
func (m *MetricSpec) DataSourceType() v1alpha.DataSourceType
DataSourceType returns a type of data source.
func (*MetricSpec) FormatQuery ¶ added in v0.91.0
func (m *MetricSpec) FormatQuery(query json.RawMessage) *string
func (*MetricSpec) Query ¶
func (m *MetricSpec) Query() interface{}
Query returns interface containing metric query for this MetricSpec.
type NewRelicMetric ¶
type NewRelicMetric struct {
NRQL *string `json:"nrql"`
}
NewRelicMetric represents metric from NewRelic
type Objective ¶
type Objective struct { ObjectiveBase `json:",inline"` // <!-- Go struct field and type names renaming budgetTarget to target has been postponed after GA as requested // in PC-1240. --> BudgetTarget *float64 `json:"target"` TimeSliceTarget *float64 `json:"timeSliceTarget,omitempty"` CountMetrics *CountMetricsSpec `json:"countMetrics,omitempty"` RawMetric *RawMetricSpec `json:"rawMetric,omitempty"` Composite *CompositeSpec `json:"composite,omitempty"` Operator *string `json:"op,omitempty"` // Primary is used to highlight the main (primary) objective of the [SLO]. Primary *bool `json:"primary,omitempty"` }
Objective represents single objective for SLO, for internal usage.
func (Objective) GetBudgetTarget ¶
func (Objective) HasCountMetrics ¶
HasCountMetrics returns true if Objective has count metrics.
func (Objective) HasRawMetricQuery ¶
HasRawMetricQuery returns true if Objective has raw metric with query set.
func (Objective) IsComposite ¶ added in v0.79.0
type ObjectiveBase ¶
type ObjectiveBase struct { DisplayName string `json:"displayName"` Value *float64 `json:"value,omitempty"` Name string `json:"name"` NameChanged bool `json:"-"` }
ObjectiveBase base structure representing an objective.
func (ObjectiveBase) GetValue ¶
func (o ObjectiveBase) GetValue() float64
type ObjectiveIndicatorValidationStatus ¶ added in v0.91.0
type ObjectiveIndicatorValidationStatus struct { ObjectiveName string `json:"objectiveName"` QueryValidationStatus }
type OpenTSDBMetric ¶
type OpenTSDBMetric struct {
Query *string `json:"query"`
}
OpenTSDBMetric represents metric from OpenTSDB.
type PingdomMetric ¶
type PingdomMetric struct { CheckID *string `json:"checkId"` CheckType *string `json:"checkType"` Status *string `json:"status,omitempty"` }
PingdomMetric represents metric from Pingdom.
type ProcessStatus ¶ added in v0.89.0
type PrometheusMetric ¶
type PrometheusMetric struct {
PromQL *string `json:"promql"`
}
PrometheusMetric represents metric from Prometheus
type QueryValidationStatus ¶ added in v0.91.0
type QueryValidationStatus struct {
ValidationStatus `json:"validationStatus"`
}
type RawMetricSpec ¶
type RawMetricSpec struct {
MetricQuery *MetricSpec `json:"query"`
}
RawMetricSpec represents integration with a metric source for a particular objective.
type RedshiftMetric ¶
type RedshiftMetric struct { Region *string `json:"region"` ClusterID *string `json:"clusterId"` DatabaseName *string `json:"databaseName"` Query *string `json:"query"` }
RedshiftMetric represents metric from Redshift.
type ReplayStatus
deprecated
type ReplayStatus struct { Source string `json:"source"` Status string `json:"status"` TriggeredBy string `json:"triggeredBy"` Unit string `json:"unit"` Value int `json:"value"` StartTime string `json:"startTime"` }
Deprecated: ReplayStatus exists for historical compatibility and should not be used.
type SLO ¶
type SLO struct { APIVersion manifest.Version `json:"apiVersion"` Kind manifest.Kind `json:"kind"` Metadata Metadata `json:"metadata"` Spec Spec `json:"spec"` Status *Status `json:"status,omitempty"` Organization string `json:"organization,omitempty"` ManifestSource string `json:"manifestSrc,omitempty"` }
SLO struct which mapped one to one with kind: slo yaml definition, external usage.
Example ¶
package main import ( "context" "log" "github.com/nobl9/nobl9-go/internal/examples" "github.com/nobl9/nobl9-go/manifest" "github.com/nobl9/nobl9-go/manifest/v1alpha" "github.com/nobl9/nobl9-go/manifest/v1alpha/slo" ) func main() { // Create the object: mySLO := slo.New( slo.Metadata{ Name: "my-slo", DisplayName: "My SLO", Project: "default", Labels: v1alpha.Labels{ "team": []string{"green", "orange"}, "region": []string{"eu-central-1"}, }, }, slo.Spec{ Description: "Example slo", AlertPolicies: []string{"my-policy-name"}, Attachments: []slo.Attachment{ { DisplayName: ptr("Grafana Dashboard"), URL: "https://loki.my-org.dev/grafana/d/dnd48", }, }, BudgetingMethod: slo.BudgetingMethodOccurrences.String(), Service: "prometheus", Indicator: &slo.Indicator{ MetricSource: slo.MetricSourceSpec{ Name: "prometheus", Project: "default", Kind: manifest.KindAgent, }, }, Objectives: []slo.Objective{ { ObjectiveBase: slo.ObjectiveBase{ DisplayName: "Good", Value: ptr(0.), Name: "good", }, BudgetTarget: ptr(0.9), CountMetrics: &slo.CountMetricsSpec{ Incremental: ptr(false), GoodMetric: &slo.MetricSpec{ Prometheus: &slo.PrometheusMetric{ PromQL: ptr(`sum(rate(prometheus_http_requests_total{code=~"^2.*"}[1h]))`), }, }, TotalMetric: &slo.MetricSpec{ Prometheus: &slo.PrometheusMetric{ PromQL: ptr(`sum(rate(prometheus_http_requests_total[1h]))`), }, }, }, }, }, TimeWindows: []slo.TimeWindow{ { Unit: "Day", Count: 1, IsRolling: true, }, }, }, ) // Verify the object: if err := mySLO.Validate(); err != nil { log.Fatal("slo validation failed, err: %w", err) } // Apply the object: client := examples.GetOfflineEchoClient() if err := client.Objects().V1().Apply(context.Background(), []manifest.Object{mySLO}); err != nil { log.Fatal("failed to apply slo, err: %w", err) } } func ptr[T any](v T) *T { return &v }
Output: apiVersion: n9/v1alpha kind: SLO metadata: name: my-slo displayName: My SLO project: default labels: region: - eu-central-1 team: - green - orange spec: description: Example slo indicator: metricSource: name: prometheus project: default kind: Agent budgetingMethod: Occurrences objectives: - displayName: Good value: 0.0 name: good target: 0.9 countMetrics: incremental: false good: prometheus: promql: sum(rate(prometheus_http_requests_total{code=~"^2.*"}[1h])) total: prometheus: promql: sum(rate(prometheus_http_requests_total[1h])) service: prometheus timeWindows: - unit: Day count: 1 isRolling: true alertPolicies: - my-policy-name attachments: - url: https://loki.my-org.dev/grafana/d/dnd48 displayName: Grafana Dashboard
func (SLO) GetManifestSource ¶
func (SLO) GetOrganization ¶
func (SLO) GetProject ¶
func (SLO) GetVersion ¶
type Spec ¶
type Spec struct { Description string `json:"description"` Indicator *Indicator `json:"indicator,omitempty"` BudgetingMethod string `json:"budgetingMethod"` Objectives []Objective `json:"objectives"` Service string `json:"service"` TimeWindows []TimeWindow `json:"timeWindows"` AlertPolicies []string `json:"alertPolicies"` Attachments []Attachment `json:"attachments,omitempty"` // CreatedAt is the date of the [SLO] creation in RFC3339 format. // Read-only field. CreatedAt string `json:"createdAt,omitempty"` // CreatedBy is the id of the user who first created the SLO. // Read-only field. CreatedBy string `json:"createdBy,omitempty"` // Deprecated: this implementation of Composite will be removed and replaced with SLO.Spec.Objectives.Composite. Composite *Composite `json:"composite,omitempty"` AnomalyConfig *AnomalyConfig `json:"anomalyConfig,omitempty"` Tier *string `json:"tier,omitempty"` }
Spec holds detailed information specific to SLO.
func (*Spec) AllMetricSpecs ¶
func (s *Spec) AllMetricSpecs() []*MetricSpec
AllMetricSpecs returns slice of all metrics defined in SLO regardless of their type.
func (*Spec) CountMetricPairs ¶
func (s *Spec) CountMetricPairs() []*CountMetricsSpec
CountMetricPairs returns a slice of all count metrics defined in this SLOSpec's objectives.
func (*Spec) CountMetrics ¶
func (s *Spec) CountMetrics() []*MetricSpec
CountMetrics returns a flat slice of all count metrics defined in this SLOSpec's objectives.
func (*Spec) CountMetricsCount ¶
CountMetricsCount returns total number of all count metrics defined in this SLOSpec's objectives.
func (*Spec) GoodTotalCountMetrics ¶
func (s *Spec) GoodTotalCountMetrics() (good, total []*MetricSpec)
func (*Spec) HasCompositeObjectives ¶ added in v0.79.0
HasCompositeObjectives returns true if any SLOSpec Objective is of composite type.
func (*Spec) HasCountMetrics ¶
HasCountMetrics returns true if SLOSpec has count metrics.
func (*Spec) HasRawMetric ¶
HasRawMetric returns true if SLOSpec has raw metric.
func (*Spec) IsComposite ¶
IsComposite returns true if SLOSpec contains composite type. Deprecated: this implementation of Composite will be removed and replaced with new CompositeSpec use HasCompositeObjectives instead for new implementation
func (*Spec) ObjectivesRawMetricsCount ¶
ObjectivesRawMetricsCount returns total number of all raw metrics defined in this SLO Spec's objectives.
func (*Spec) RawMetrics ¶
func (s *Spec) RawMetrics() []*MetricSpec
RawMetrics returns raw metric spec.
type SplunkMetric ¶
type SplunkMetric struct {
Query *string `json:"query"`
}
SplunkMetric represents metric from Splunk
type SplunkObservabilityMetric ¶
type SplunkObservabilityMetric struct {
Program *string `json:"program"`
}
SplunkObservabilityMetric represents metric from SplunkObservability
type Status ¶
type Status struct { UpdatedAt string `json:"updatedAt,omitempty"` CompositeSLO *ProcessStatus `json:"compositeSlo,omitempty"` ErrorBudgetAdjustment *ProcessStatus `json:"errorBudgetAdjustment,omitempty"` Replay *ProcessStatus `json:"replay,omitempty"` TargetSLO *TargetSloStatus `json:"targetSlo,omitempty"` ObjectiveIndicatorValidation []*ObjectiveIndicatorValidationStatus `json:"objectiveIndicatorValidation,omitempty"` // Deprecated: use Status.Replay instead. ReplayStatus *ReplayStatus `json:"timeTravel,omitempty"` }
Status holds dynamic fields returned when the Service is fetched from Nobl9 platform. Status is not part of the static object definition.
type SumoLogicMetric ¶
type SumoLogicMetric struct { Type *string `json:"type"` Query *string `json:"query"` Quantization *string `json:"quantization,omitempty"` Rollup *string `json:"rollup,omitempty"` }
SumoLogicMetric represents metric from Sumo Logic.
type TargetSloStatus ¶ added in v0.88.0
type TargetSloStatus struct { // Deprecated: use TargetSloStatus.Replay instead. TargetTimeTravel ReplayStatus `json:"targetTimeTravel,omitempty"` Replay ProcessStatus `json:"replay,omitempty"` }
TargetSloStatus represents the status of Replay a target SLO process.
type ThousandEyesMetric ¶
ThousandEyesMetric represents metric from ThousandEyes
type TimeWindow ¶
type TimeWindow struct { Unit string `json:"unit"` Count int `json:"count"` IsRolling bool `json:"isRolling"` Calendar *Calendar `json:"calendar,omitempty"` // Period is only returned in `/get/slo` requests it is ignored for `/apply` Period *Period `json:"period,omitempty"` }
TimeWindow represents content of time window
func (TimeWindow) GetType ¶
func (tw TimeWindow) GetType() twindow.TimeWindowTypeEnum
GetType returns value of twindow.TimeWindowTypeEnum for given time window>
type ValidationDetails ¶ added in v0.91.0
type ValidationDetails struct { *ErrorDetails *MetricSpec }
type ValidationStatus ¶ added in v0.91.0
type ValidationStatus struct { GoodMetricValidation *ValidationDetails `json:"goodMetric,omitempty"` BadMetricValidation *ValidationDetails `json:"badMetric,omitempty"` TotalMetricValidation *ValidationDetails `json:"totalMetric,omitempty"` RawMetricValidation *ValidationDetails `json:"rawMetric,omitempty"` }
type WhenDelayed ¶ added in v0.79.0
type WhenDelayed string
WhenDelayed represents enum for behavior of Composite SLO objectives
ENUM(
CountAsGood CountAsBad Ignore )
const ( // WhenDelayedCountAsGood is a WhenDelayed of type CountAsGood. WhenDelayedCountAsGood WhenDelayed = "CountAsGood" // WhenDelayedCountAsBad is a WhenDelayed of type CountAsBad. WhenDelayedCountAsBad WhenDelayed = "CountAsBad" // WhenDelayedIgnore is a WhenDelayed of type Ignore. WhenDelayedIgnore WhenDelayed = "Ignore" )
func ParseWhenDelayed ¶ added in v0.79.0
func ParseWhenDelayed(name string) (WhenDelayed, error)
ParseWhenDelayed attempts to convert a string to a WhenDelayed.
func WhenDelayedValues ¶ added in v0.79.0
func WhenDelayedValues() []WhenDelayed
WhenDelayedValues returns a list of the values for WhenDelayed
func (WhenDelayed) IsValid ¶ added in v0.79.0
func (x WhenDelayed) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (WhenDelayed) String ¶ added in v0.79.0
func (x WhenDelayed) String() string
String implements the Stringer interface.
Source Files ¶
- budgeting_method.go
- composite.go
- doc.go
- metrics.go
- metrics_amazon_prometheus.go
- metrics_app_dynamics.go
- metrics_azure_monitor.go
- metrics_azure_prometheus.go
- metrics_bigquery.go
- metrics_cloudwatch.go
- metrics_datadog.go
- metrics_dynatrace.go
- metrics_elasticsearch.go
- metrics_gcm.go
- metrics_generic.go
- metrics_grafana_loki.go
- metrics_graphite.go
- metrics_honeycomb.go
- metrics_influxdb.go
- metrics_instana.go
- metrics_lightstep.go
- metrics_logic_monitor.go
- metrics_newrelic.go
- metrics_opentsdb.go
- metrics_pingdom.go
- metrics_prometheus.go
- metrics_redshift.go
- metrics_splunk.go
- metrics_splunk_observability.go
- metrics_sumo_logic.go
- metrics_thousand_eyes.go
- metrics_validation.go
- slo.go
- slo_object.go
- time_window.go
- validation.go
- when_delayed.go
- when_delayed_enum.go