AnalysisValueTemplate
An AnalysisValueTemplate resource
defines a Service Level Indicator (SLI),
which identifies the data to be analyzed
by data source to use and the query to issue.
One Analysis can use data from multiple instances
of multiple types of data provider.
Synopsis
{% include “analysisvaluetemplate.md_1.yaml” %}
Fields
- apiVersion – API version being used
- kind – Resource type.
Must be set to
AnalysisValueTemplate - metadata
- labels – The Analysis feature uses the
nameandpart-oflabels that are discussed in Basic annotations plus the following:-
app.kubernetes.io/instance analysis-sample
-
app.kubernetes.io/managed-by – Tool used to manage the operation of the application. Valid values are
helmandkustomize. -
app.kubernetes.io/created-by metrics-operator
TODO: Need to clarify how to use these annotations
-
- name – Unique name of this template. Names must comply with the Kubernetes Object Names and IDs specification.
- namespace (optional) – Namespace where this template lives.
Analysisresources must specify this namespace when referencing this definition, unless it resides in the same namespace as theAnalysisresource.
- labels – The Analysis feature uses the
- spec
- provider (required) – the KeptnMetricProvider
- name – The
spec.namevalue of the KeptnMetricsProvider resource to use. Note that eachAnalysisValueTemplateresource can use only one data source. However, anAnalysisresource can use multipleAnalysisValueTemplateresources, each of which uses a different data source.
- name – The
- query (required) – query to be made.
This is done in the data provider’s query language.
It can include variables that use the go templating syntax
to insert a placeholder in the query.
For example, the query might include
{{.nodename}}'}; the value to substitute for that variable for this Analysis is defined in thespec.argssection of theAnalysisTemplateresource, which might be set tonodename: test.
- provider (required) – the KeptnMetricProvider
Usage
You must define a
KeptnMetricsProvider
for each instance of each data provider you are using.
The AnalysisValueTemplate refers to that provider and queries it.
One Analysis can use data from multiple instances
of multiple types of data provider;
you must define a
KeptnMetricsProvider
resource for each instance of each data provider you are using.
The template refers to that provider and queries it.
Example
apiVersion: metrics.keptn.sh/v1beta1
kind: AnalysisValueTemplate
metadata:
labels:
app.kubernetes.io/name: analysisvaluetemplate
app.kubernetes.io/instance: analysisvaluetemplate-sample
app.kubernetes.io/part-of: metrics-operator
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/created-by: metrics-operator
name: response-time-p95
namespace: keptn-system
spec:
provider:
name: prometheus
query: "sum(kube_pod_container_resource_limits{node='{{.nodename}}'}) - sum(kube_node_status_capacity{node='{{.nodename}}'})"
For a full example of how the AnalysisValueTemplate is used
to implement the Keptn Analysis feature, see the
Analysis
guide page.
Files
API reference: AnalysisValueTemplate
Differences between versions
A preliminary release of the Keptn Analysis feature is included in Keptn v0.8.3 and v0.9.0 but is hidden behind a feature flag. See the Analysis reference page for instructions to activate the preview of this feature.