Skip to content

Commit

Permalink
feat(metrics-operator): add support for user-friendly duration string…
Browse files Browse the repository at this point in the history
… for specifying time frame (#2147)

Signed-off-by: Florian Bacher <[email protected]>
  • Loading branch information
bacherfl authored Sep 27, 2023
1 parent 3ff67d5 commit 34e5384
Show file tree
Hide file tree
Showing 39 changed files with 1,367 additions and 322 deletions.
285 changes: 166 additions & 119 deletions .github/scripts/.helm-tests/default/result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,135 +158,162 @@ spec:
singular: analysis
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.analysisDefinition.name
name: AnalysisDefinition
type: string
- jsonPath: .status.state
name: State
type: string
- jsonPath: .status.warning
name: Warning
type: string
- jsonPath: .status.pass
name: Pass
type: string
name: v1alpha3
schema:
openAPIV3Schema:
description: Analysis is the Schema for the analyses API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
- additionalPrinterColumns:
- jsonPath: .spec.analysisDefinition.name
name: AnalysisDefinition
type: string
- jsonPath: .status.state
name: State
type: string
- jsonPath: .status.warning
name: Warning
type: string
- jsonPath: .status.pass
name: Pass
type: string
name: v1alpha3
schema:
openAPIV3Schema:
description: Analysis is the Schema for the analyses API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: AnalysisSpec defines the desired state of Analysis
properties:
analysisDefinition:
description: AnalysisDefinition refers to the AnalysisDefinition,
a CRD that stores the AnalysisValuesTemplates
properties:
name:
description: Name defines the name of the referenced object
type: string
namespace:
description: Namespace defines the namespace of the referenced
object
type: string
metadata:
type: object
spec:
description: AnalysisSpec defines the desired state of Analysis
properties:
analysisDefinition:
description: AnalysisDefinition refers to the AnalysisDefinition,
a CRD that stores the AnalysisValuesTemplates
properties:
name:
description: Name defines the name of the referenced object
type: string
namespace:
description: Namespace defines the namespace of the referenced
object
type: string
required:
- name
type: object
args:
additionalProperties:
type: string
required:
- name
type: object
args:
additionalProperties:
description: Args corresponds to a map of key/value pairs that can
be used to substitute placeholders in the AnalysisValueTemplate
query. i.e. for args foo:bar the query could be "query:percentile(95)?scope=tag(my_foo_label:)".
type: object
timeframe:
description: Timeframe specifies the range for the corresponding query
in the AnalysisValueTemplate. Please note that either a combination
of 'from' and 'to' or the 'recent' property may be set. If neither
is set, the Analysis can not be added to the cluster.
properties:
from:
description: From is the time of start for the query. This field
follows RFC3339 time format
format: date-time
type: string
recent:
description: Recent describes a recent timeframe using a duration
string. E.g. Setting this to '5m' provides an Analysis for the
last five minutes
pattern: ^0|([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
type: string
to:
description: To is the time of end for the query. This field follows
RFC3339 time format
format: date-time
type: string
type: object
required:
- analysisDefinition
- timeframe
type: object
status:
description: AnalysisStatus stores the status of the overall analysis
returns also pass or warnings
properties:
pass:
description: Pass returns whether the SLO is satisfied
type: boolean
raw:
description: Raw contains the raw result of the SLO computation
type: string
description: Args corresponds to a map of key/value pairs that can
be used to substitute placeholders in the AnalysisValueTemplate
query. i.e. for args foo:bar the query could be "query:percentile(95)?scope=tag(my_foo_label:)".
type: object
timeframe:
description: Timeframe specifies the range for the corresponding query
in the AnalysisValueTemplate
properties:
from:
description: From is the time of start for the query, this field
follows RFC3339 time format
format: date-time
type: string
to:
description: To is the time of end for the query, this field follows
RFC3339 time format
format: date-time
type: string
required:
- from
- to
type: object
required:
- analysisDefinition
- timeframe
type: object
status:
description: AnalysisStatus stores the status of the overall analysis
returns also pass or warnings
properties:
pass:
description: Pass returns whether the SLO is satisfied
type: boolean
raw:
description: Raw contains the raw result of the SLO computation
type: string
state:
description: State describes the current state of the Analysis (Pending/Progressing/Completed)
type: string
storedValues:
additionalProperties:
description: ProviderResult stores reference of already collected
provider query associated to its objective template
state:
description: State describes the current state of the Analysis (Pending/Progressing/Completed)
type: string
storedValues:
additionalProperties:
description: ProviderResult stores reference of already collected
provider query associated to its objective template
properties:
errMsg:
description: ErrMsg stores any possible error at retrieval time
type: string
objectiveReference:
description: Objective store reference to corresponding objective
template
properties:
name:
description: Name defines the name of the referenced object
type: string
namespace:
description: Namespace defines the namespace of the referenced
object
type: string
required:
- name
type: object
value:
description: Value is the value the provider returned
type: string
type: object
description: StoredValues contains all analysis values that have already
been retrieved successfully
type: object
timeframe:
description: Timeframe describes the time frame which is evaluated
by the Analysis
properties:
errMsg:
description: ErrMsg stores any possible error at retrieval time
from:
description: From is the time of start for the query. This field
follows RFC3339 time format
format: date-time
type: string
objectiveReference:
description: Objective store reference to corresponding objective
template
properties:
name:
description: Name defines the name of the referenced object
type: string
namespace:
description: Namespace defines the namespace of the referenced
object
type: string
required:
- name
type: object
value:
description: Value is the value the provider returned
recent:
description: Recent describes a recent timeframe using a duration
string. E.g. Setting this to '5m' provides an Analysis for the
last five minutes
pattern: ^0|([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
type: string
to:
description: To is the time of end for the query. This field follows
RFC3339 time format
format: date-time
type: string
type: object
description: StoredValues contains all analysis values that have already
been retrieved successfully
type: object
warning:
description: Warning returns whether the analysis returned a warning
type: boolean
required:
- state
type: object
type: object
served: true
storage: true
subresources:
status: {}
warning:
description: Warning returns whether the analysis returned a warning
type: boolean
required:
- state
- timeframe
type: object
type: object
served: true
storage: true
subresources:
status: {}
---
# Source: klt/templates/analysisdefinition-crd.yaml
apiVersion: apiextensions.k8s.io/v1
Expand Down Expand Up @@ -8344,6 +8371,26 @@ webhooks:
resources:
- keptnmetrics
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: 'metrics-webhook-service'
namespace: 'helmtests'
path: /validate-metrics-keptn-sh-v1alpha3-analysis
failurePolicy: Fail
name: vanalysis.kb.io
rules:
- apiGroups:
- metrics.keptn.sh
apiVersions:
- v1alpha3
operations:
- CREATE
- UPDATE
resources:
- analyses
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
Expand Down
9 changes: 6 additions & 3 deletions docs/content/en/docs/crd-ref/metrics/v1alpha3/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ _Appears in:_

| Field | Description |
| --- | --- |
| `timeframe` _[Timeframe](#timeframe)_ | Timeframe specifies the range for the corresponding query in the AnalysisValueTemplate |
| `timeframe` _[Timeframe](#timeframe)_ | Timeframe specifies the range for the corresponding query in the AnalysisValueTemplate. Please note that either a combination of 'from' and 'to' or the 'recent' property may be set. If neither is set, the Analysis can not be added to the cluster. |
| `args` _object (keys:string, values:string)_ | Args corresponds to a map of key/value pairs that can be used to substitute placeholders in the AnalysisValueTemplate query. i.e. for args foo:bar the query could be "query:percentile(95)?scope=tag(my_foo_label:{{.foo}})". |
| `analysisDefinition` _[ObjectReference](#objectreference)_ | AnalysisDefinition refers to the AnalysisDefinition, a CRD that stores the AnalysisValuesTemplates |

Expand All @@ -147,6 +147,7 @@ _Appears in:_

| Field | Description |
| --- | --- |
| `timeframe` _[Timeframe](#timeframe)_ | Timeframe describes the time frame which is evaluated by the Analysis |
| `raw` _string_ | Raw contains the raw result of the SLO computation |
| `pass` _boolean_ | Pass returns whether the SLO is satisfied |
| `warning` _boolean_ | Warning returns whether the analysis returned a warning |
Expand Down Expand Up @@ -494,11 +495,13 @@ _Appears in:_

_Appears in:_
- [AnalysisSpec](#analysisspec)
- [AnalysisStatus](#analysisstatus)

| Field | Description |
| --- | --- |
| `from` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#time-v1-meta)_ | From is the time of start for the query, this field follows RFC3339 time format |
| `to` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#time-v1-meta)_ | To is the time of end for the query, this field follows RFC3339 time format |
| `from` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#time-v1-meta)_ | From is the time of start for the query. This field follows RFC3339 time format |
| `to` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#time-v1-meta)_ | To is the time of end for the query. This field follows RFC3339 time format |
| `recent` _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#duration-v1-meta)_ | Recent describes a recent timeframe using a duration string. E.g. Setting this to '5m' provides an Analysis for the last five minutes |


#### TotalScore
Expand Down
Loading

0 comments on commit 34e5384

Please sign in to comment.