AnalysisValueTemplate

Define the data source and query for each SLI

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

apiVersion: metrics.keptn.sh/v1beta1
kind: AnalysisValueTemplate
metadata:
  name: response-time-p95
  namespace: <namespace-where-this-resource-resides>
spec:
  provider:
    name: prometheus | dynatrace | dql | datadog
  query: <query>

Fields

  • apiVersion – API version being used
  • kind – Resource type. Must be set to AnalysisValueTemplate
  • metadata
    • labels – The Analysis feature uses the name and part-of labels 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 helm and kustomize.

      • 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. Analysis resources must specify this namespace when referencing this definition, unless it resides in the same namespace as the Analysis resource.
  • spec
    • provider (required) – the KeptnMetricProvider
      • name – The spec.name value of the KeptnMetricsProvider resource to use. Note that each AnalysisValueTemplate resource can use only one data source. However, an Analysis resource can use multiple AnalysisValueTemplate resources, each of which uses a different data source.
    • 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 the spec.args section of the AnalysisTemplate resource, which might be set to nodename: test.

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-lifecycle-toolkit-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.

See also