Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit 6d42666

Browse files
authored
Updates SLO Types
2 parents 8559410 + 3459c6b commit 6d42666

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

slo.go

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ type Slos struct {
1212
Slos []Slo `json:"slos"`
1313
}
1414

15+
// Defines values for QueryType.
1516
const (
1617
QueryTypeFreeform QueryType = "freeform"
1718
QueryTypeHistogram QueryType = "histogram"
1819
QueryTypeRatio QueryType = "ratio"
1920
QueryTypeThreshold QueryType = "threshold"
2021
)
2122

23+
// Defines values for ThresholdOperator.
2224
const (
2325
ThresholdOperatorEmpty ThresholdOperator = "<"
2426
ThresholdOperatorEqualEqual ThresholdOperator = "=="
@@ -27,48 +29,63 @@ const (
2729
ThresholdOperatorN3 ThresholdOperator = ">"
2830
)
2931

32+
// Alerting defines model for Alerting.
3033
type Alerting struct {
3134
Annotations []Label `json:"annotations,omitempty"`
3235
FastBurn *AlertingMetadata `json:"fastBurn,omitempty"`
3336
Labels []Label `json:"labels,omitempty"`
3437
SlowBurn *AlertingMetadata `json:"slowBurn,omitempty"`
3538
}
3639

40+
// AlertingMetadata defines model for AlertingMetadata.
3741
type AlertingMetadata struct {
3842
Annotations []Label `json:"annotations,omitempty"`
3943
Labels []Label `json:"labels,omitempty"`
4044
}
4145

46+
// DashboardRef defines model for DashboardRef.
4247
type DashboardRef struct {
4348
UID string `json:"UID"`
4449
}
4550

51+
// DestinationDatasource defines model for DestinationDatasource.
52+
type DestinationDatasource struct {
53+
Type string `json:"type,omitempty"`
54+
UID string `json:"uid,omitempty"`
55+
}
56+
57+
// FreeformQuery defines model for FreeformQuery.
4658
type FreeformQuery struct {
4759
Query string `json:"query"`
4860
}
4961

62+
// HistogramQuery defines model for HistogramQuery.
5063
type HistogramQuery struct {
5164
GroupByLabels []string `json:"groupByLabels,omitempty"`
5265
Metric MetricDef `json:"metric"`
5366
Percentile float64 `json:"percentile"`
5467
Threshold Threshold `json:"threshold"`
5568
}
5669

70+
// Label defines model for Label.
5771
type Label struct {
5872
Key string `json:"key"`
5973
Value string `json:"value"`
6074
}
6175

76+
// MetricDef defines model for MetricDef.
6277
type MetricDef struct {
63-
PrometheusMetric string `json:"prometheusMetric"`
64-
Type *string `json:"type,omitempty"`
78+
PrometheusMetric string `json:"prometheusMetric"`
79+
Type string `json:"type,omitempty"`
6580
}
6681

82+
// Objective defines model for Objective.
6783
type Objective struct {
6884
Value float64 `json:"value"`
6985
Window string `json:"window"`
7086
}
7187

88+
// Query defines model for Query.
7289
type Query struct {
7390
Freeform *FreeformQuery `json:"freeform,omitempty"`
7491
Histogram *HistogramQuery `json:"histogram,omitempty"`
@@ -77,32 +94,52 @@ type Query struct {
7794
Type QueryType `json:"type"`
7895
}
7996

97+
// QueryType defines model for Query.Type.
8098
type QueryType string
8199

100+
// RatioQuery defines model for RatioQuery.
82101
type RatioQuery struct {
83102
GroupByLabels []string `json:"groupByLabels,omitempty"`
84103
SuccessMetric MetricDef `json:"successMetric"`
85104
TotalMetric MetricDef `json:"totalMetric"`
86105
}
87106

88-
type Slo struct {
89-
Alerting *Alerting `json:"alerting,omitempty"`
90-
Description string `json:"description"`
107+
// ReadOnly defines model for ReadOnly.
108+
type ReadOnly struct {
91109
DrillDownDashboardRef *DashboardRef `json:"drillDownDashboardRef,omitempty"`
92-
Labels []Label `json:"labels,omitempty"`
93-
Name string `json:"name"`
94-
Objectives []Objective `json:"objectives"`
95-
Query Query `json:"query"`
96-
UUID string `json:"uuid"`
110+
Provenance string `json:"provenance,omitempty"`
111+
Status *Status `json:"status,omitempty"`
112+
}
113+
114+
// Slo defines model for Slo.
115+
type Slo struct {
116+
Alerting *Alerting `json:"alerting,omitempty"`
117+
Description string `json:"description"`
118+
DestinationDatasource *DestinationDatasource `json:"destinationDatasource,omitempty"`
119+
Labels []Label `json:"labels,omitempty"`
120+
Name string `json:"name"`
121+
Objectives []Objective `json:"objectives"`
122+
Query Query `json:"query"`
123+
ReadOnly *ReadOnly `json:"readOnly,omitempty"`
124+
UUID string `json:"uuid"`
125+
}
126+
127+
// Status defines model for Status.
128+
type Status struct {
129+
Message string `json:"message,omitempty"`
130+
Type string `json:"type"`
97131
}
98132

133+
// Threshold defines model for Threshold.
99134
type Threshold struct {
100135
Operator ThresholdOperator `json:"operator"`
101136
Value float64 `json:"value"`
102137
}
103138

139+
// ThresholdOperator defines model for Threshold.Operator.
104140
type ThresholdOperator string
105141

142+
// ThresholdQuery defines model for ThresholdQuery.
106143
type ThresholdQuery struct {
107144
GroupByLabels []string `json:"groupByLabels,omitempty"`
108145
Metric MetricDef `json:"metric"`

0 commit comments

Comments
 (0)