Documentation ¶
Overview ¶
Package slo defines SLO object definitions.
Index ¶
- Constants
- type AmazonPrometheusMetric
- type AnomalyConfig
- type AnomalyConfigAlertMethod
- type AnomalyConfigNoData
- type AppDynamicsMetric
- type Attachment
- type AzureMonitorMetric
- type AzureMonitorMetricDimension
- type BigQueryMetric
- type BudgetingMethod
- type Calendar
- type CloudWatchMetric
- type CloudWatchMetricDimension
- type Composite
- type CompositeBurnRateCondition
- type CompositeVersion
- type CountMetricsSpec
- type DatadogMetric
- type DynatraceMetric
- type ElasticsearchMetric
- 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 Metadata
- type MetricSourceSpec
- type MetricSpec
- type NewRelicMetric
- type Objective
- type ObjectiveBase
- type OpenTSDBMetric
- type Period
- type PingdomMetric
- type PrometheusMetric
- type RawMetricSpec
- type RedshiftMetric
- type ReplayStatus
- 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) GetVersion() string
- 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) 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 ThousandEyesMetric
- type TimeWindow
Examples ¶
Constants ¶
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 ¶
This section is empty.
Functions ¶
This section is empty.
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 { ResourceID string `json:"resourceId"` MetricName string `json:"metricName"` Aggregation string `json:"aggregation"` Dimensions []AzureMonitorMetricDimension `json:"dimensions,omitempty"` MetricNamespace string `json:"metricNamespace,omitempty"` }
AzureMonitorMetric represents metric from AzureMonitor
type AzureMonitorMetricDimension ¶
AzureMonitorMetricDimension represents name/value pair that is part of the identity of a metric.
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 Composite ¶
type Composite struct { BudgetTarget *float64 `json:"target"` BurnRateCondition *CompositeBurnRateCondition `json:"burnRateCondition,omitempty"` }
Composite represents configuration for Composite SLO.
type CompositeBurnRateCondition ¶
CompositeBurnRateCondition represents configuration for Composite SLO with occurrences budgeting method.
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"` }
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 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 { Dataset string `json:"dataset"` Calculation string `json:"calculation"` Attribute string `json:"attribute"` }
HoneycombMetric represents metric from Honeycomb. To access this integration, contact support@nobl9.com.
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 Metadata ¶
type Metadata struct { Name string `json:"name"` DisplayName string `json:"displayName,omitempty"` Project string `json:"project,omitempty"` Labels v1alpha.Labels `json:"labels,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"` }
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) 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"` Operator *string `json:"op,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.
type ObjectiveBase ¶
type ObjectiveBase struct { DisplayName string `json:"displayName"` Value *float64 `json:"value"` Name string `json:"name"` NameChanged bool `json:"-"` }
ObjectiveBase base structure representing an objective.
func (ObjectiveBase) GetValue ¶
func (o ObjectiveBase) GetValue() float64
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 PrometheusMetric ¶
type PrometheusMetric struct {
PromQL *string `json:"promql"`
}
PrometheusMetric represents metric from Prometheus
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 ¶
type SLO ¶
type SLO struct { APIVersion string `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.ApplyObjects(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"` 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 string `json:"createdAt,omitempty"` Composite *Composite `json:"composite,omitempty"` AnomalyConfig *AnomalyConfig `json:"anomalyConfig,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) 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.
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 {
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 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>
Source Files ¶
- budgeting_method.go
- doc.go
- metrics.go
- metrics_amazon_prometheus.go
- metrics_app_dynamics.go
- metrics_azure_monitor.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_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