Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update KeptnMetric to store multiple metrics in status #1900

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 71 additions & 15 deletions .github/scripts/.helm-tests/default/result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2929,7 +2929,7 @@ spec:
description: Name of the provider
type: string
required:
- name
- name
type: object
query:
description: Query represents the query to be run
Expand All @@ -2943,13 +2943,13 @@ spec:
to be applied on the data. Accepted values: p90, p95, p99, max,
min, avg, median'
enum:
- p90
- p95
- p99
- max
- min
- avg
- median
- p90
- p95
- p99
- max
- min
- avg
- median
type: string
interval:
default: 5m
Expand All @@ -2960,11 +2960,16 @@ spec:
description: Step represents the query resolution step width for
the data query
type: string
storedResults:
description: StoredResults indicates the upper limit of how many
past results should be stored in the status of a KeptnMetric
maximum: 255
type: integer
type: object
required:
- fetchIntervalSeconds
- provider
- query
- fetchIntervalSeconds
- provider
- query
type: object
status:
description: KeptnMetricStatus defines the observed state of KeptnMetric
Expand All @@ -2973,6 +2978,61 @@ spec:
description: ErrMsg represents the error details when the query could
not be evaluated
type: string
intervalResults:
description: IntervalResults contain a slice of all the interval results
items:
properties:
errMsg:
description: ErrMsg represents the error details when the query
could not be evaluated
type: string
lastUpdated:
description: LastUpdated represents the time when the status
data was last updated
format: date-time
type: string
range:
description: Range represents the time range for which this
data was queried
properties:
aggregation:
description: 'Aggregation defines the type of aggregation
function to be applied on the data. Accepted values: p90,
p95, p99, max, min, avg, median'
enum:
- p90
- p95
- p99
- max
- min
- avg
- median
type: string
interval:
default: 5m
description: Interval specifies the duration of the time
interval for the data query
type: string
step:
description: Step represents the query resolution step width
for the data query
type: string
storedResults:
description: StoredResults indicates the upper limit of
how many past results should be stored in the status of
a KeptnMetric
maximum: 255
type: integer
type: object
value:
description: Value represents the resulting value
type: string
required:
- lastUpdated
- range
- value
type: object
type: array
lastUpdated:
description: LastUpdated represents the time when the status data
was last updated
Expand All @@ -2985,10 +3045,6 @@ spec:
value:
description: Value represents the resulting value
type: string
required:
- lastUpdated
- rawValue
- value
type: object
type: object
served: true
Expand Down
20 changes: 20 additions & 0 deletions docs/content/en/docs/crd-ref/metrics/v1alpha3/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,23 @@ _Appears in:_
| `query` _string_ | Query represents the query to be run. It can include placeholders that are defined using the go template syntax. More info on go templating - https://pkg.go.dev/text/template |


#### IntervalResult





_Appears in:_
- [KeptnMetricStatus](#keptnmetricstatus)

| Field | Description |
| --- | --- |
| `value` _string_ | Value represents the resulting value |
rakshitgondwal marked this conversation as resolved.
Show resolved Hide resolved
| `range` _[RangeSpec](#rangespec)_ | Range represents the time range for which this data was queried |
| `lastUpdated` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#time-v1-meta)_ | LastUpdated represents the time when the status data was last updated |
| `errMsg` _string_ | ErrMsg represents the error details when the query could not be evaluated |


#### KeptnMetric


Expand Down Expand Up @@ -257,6 +274,7 @@ _Appears in:_
| `rawValue` _integer array_ | RawValue represents the resulting value in raw format |
| `lastUpdated` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#time-v1-meta)_ | LastUpdated represents the time when the status data was last updated |
| `errMsg` _string_ | ErrMsg represents the error details when the query could not be evaluated |
| `intervalResults` _[IntervalResult](#intervalresult) array_ | IntervalResults contain a slice of all the interval results |


#### KeptnMetricsProvider
Expand Down Expand Up @@ -415,13 +433,15 @@ _Appears in:_
RangeSpec defines the time range for which data is to be queried

_Appears in:_
- [IntervalResult](#intervalresult)
- [KeptnMetricSpec](#keptnmetricspec)

| Field | Description |
| --- | --- |
| `interval` _string_ | Interval specifies the duration of the time interval for the data query |
| `step` _string_ | Step represents the query resolution step width for the data query |
| `aggregation` _string_ | Aggregation defines the type of aggregation function to be applied on the data. Accepted values: p90, p95, p99, max, min, avg, median |
| `storedResults` _integer_ | StoredResults indicates the upper limit of how many past results should be stored in the status of a KeptnMetric |


#### RangeValue
Expand Down
86 changes: 71 additions & 15 deletions helm/chart/templates/keptnmetric-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ spec:
description: Name of the provider
type: string
required:
- name
- name
type: object
query:
description: Query represents the query to be run
Expand All @@ -239,13 +239,13 @@ spec:
to be applied on the data. Accepted values: p90, p95, p99, max,
min, avg, median'
enum:
- p90
- p95
- p99
- max
- min
- avg
- median
- p90
- p95
- p99
- max
- min
- avg
- median
type: string
interval:
default: 5m
Expand All @@ -256,11 +256,16 @@ spec:
description: Step represents the query resolution step width for
the data query
type: string
storedResults:
description: StoredResults indicates the upper limit of how many
past results should be stored in the status of a KeptnMetric
maximum: 255
type: integer
type: object
required:
- fetchIntervalSeconds
- provider
- query
- fetchIntervalSeconds
- provider
- query
type: object
status:
description: KeptnMetricStatus defines the observed state of KeptnMetric
Expand All @@ -269,6 +274,61 @@ spec:
description: ErrMsg represents the error details when the query could
not be evaluated
type: string
intervalResults:
description: IntervalResults contain a slice of all the interval results
items:
properties:
errMsg:
description: ErrMsg represents the error details when the query
could not be evaluated
type: string
lastUpdated:
description: LastUpdated represents the time when the status
data was last updated
format: date-time
type: string
range:
description: Range represents the time range for which this
data was queried
properties:
aggregation:
description: 'Aggregation defines the type of aggregation
function to be applied on the data. Accepted values: p90,
p95, p99, max, min, avg, median'
enum:
- p90
- p95
- p99
- max
- min
- avg
- median
type: string
interval:
default: 5m
description: Interval specifies the duration of the time
interval for the data query
type: string
step:
description: Step represents the query resolution step width
for the data query
type: string
storedResults:
description: StoredResults indicates the upper limit of
how many past results should be stored in the status of
a KeptnMetric
maximum: 255
type: integer
type: object
value:
description: Value represents the resulting value
type: string
required:
- lastUpdated
- range
- value
type: object
type: array
lastUpdated:
description: LastUpdated represents the time when the status data
was last updated
Expand All @@ -281,10 +341,6 @@ spec:
value:
description: Value represents the resulting value
type: string
required:
- lastUpdated
- rawValue
- value
type: object
type: object
served: true
Expand Down
22 changes: 19 additions & 3 deletions metrics-operator/api/v1alpha3/keptnmetric_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ type KeptnMetricSpec struct {
// KeptnMetricStatus defines the observed state of KeptnMetric
type KeptnMetricStatus struct {
// Value represents the resulting value
Value string `json:"value"`
Value string `json:"value,omitempty"`
// RawValue represents the resulting value in raw format
RawValue []byte `json:"rawValue"`
RawValue []byte `json:"rawValue,omitempty"`
// LastUpdated represents the time when the status data was last updated
LastUpdated metav1.Time `json:"lastUpdated"`
LastUpdated metav1.Time `json:"lastUpdated,omitempty"`
// ErrMsg represents the error details when the query could not be evaluated
ErrMsg string `json:"errMsg,omitempty"`
// IntervalResults contain a slice of all the interval results
IntervalResults []IntervalResult `json:"intervalResults,omitempty"`
}

// ProviderRef represents the provider object
Expand All @@ -63,6 +65,20 @@ type RangeSpec struct {
// Aggregation defines the type of aggregation function to be applied on the data. Accepted values: p90, p95, p99, max, min, avg, median
// +kubebuilder:validation:Enum:=p90;p95;p99;max;min;avg;median
Aggregation string `json:"aggregation,omitempty"`
// StoredResults indicates the upper limit of how many past results should be stored in the status of a KeptnMetric
// +kubebuilder:validation:Maximum:=255
rakshitgondwal marked this conversation as resolved.
Show resolved Hide resolved
StoredResults uint `json:"storedResults,omitempty"`
}

type IntervalResult struct {
// Value represents the resulting value
Value string `json:"value"`
// Range represents the time range for which this data was queried
Range *RangeSpec `json:"range"`
// LastUpdated represents the time when the status data was last updated
LastUpdated metav1.Time `json:"lastUpdated"`
// ErrMsg represents the error details when the query could not be evaluated
ErrMsg string `json:"errMsg,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
28 changes: 28 additions & 0 deletions metrics-operator/api/v1alpha3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading