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

docs: reference pages for Evaluation and Metrics definitions and providers #1224

Closed
wants to merge 81 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
e089a5d
k8s doc references on landing page
StackScribe Mar 2, 2023
3246ac6
process go.mod file
StackScribe Mar 2, 2023
4c4ef1d
Merge branch 'main' of github.com:keptn/lifecycle-toolkit
StackScribe Mar 8, 2023
84bc148
Merge branch 'main' of github.com:keptn/lifecycle-toolkit
StackScribe Mar 9, 2023
9937c95
Merge branch 'main' of github.com:keptn/lifecycle-toolkit
StackScribe Mar 17, 2023
3350da4
Merge branch 'main' of github.com:keptn/lifecycle-toolkit
StackScribe Mar 21, 2023
74d49ed
Merge branch 'main' of github.com:keptn/lifecycle-toolkit
StackScribe Mar 23, 2023
b97cc28
Merge branch 'main' of github.com:keptn/lifecycle-toolkit
StackScribe Mar 24, 2023
91dac8e
Merge branch 'main' of github.com:keptn/lifecycle-toolkit
StackScribe Mar 30, 2023
489dcde
Merge branch 'main' of github.com:keptn/lifecycle-toolkit
StackScribe Mar 31, 2023
4232dd7
Merge branch 'main' of github.com:keptn/lifecycle-toolkit
StackScribe Apr 4, 2023
f02cb14
Merge branch 'main' of github.com:keptn/lifecycle-toolkit
StackScribe Apr 6, 2023
76c23bc
Merge branch 'main' of github.com:keptn/lifecycle-toolkit
StackScribe Apr 11, 2023
d65f789
ref pages for KeptnEvaluationDefinition and KeptnEvaluationProvider
StackScribe Apr 13, 2023
1f3b8cb
markdownlint-fix
StackScribe Apr 13, 2023
1df95c2
remove xrefs to autogenerated API ref for now
StackScribe Apr 13, 2023
0f1f393
Merge branch 'main' into 0412-eval-ref
StackScribe Apr 13, 2023
192ea92
Merge branch 'main' into 0412-eval-ref
StackScribe Apr 18, 2023
4015f51
markdownlint-fix
StackScribe Apr 18, 2023
b8cb8b7
Merge branch 'main' into 0412-eval-ref
StackScribe Apr 18, 2023
a52a9f7
Merge branch 'main' into 0412-eval-ref
StackScribe Apr 18, 2023
c0212fb
initial info for KeptnMetric yaml CRD
StackScribe Apr 19, 2023
c5bd13d
Merge branch 'main' into 0412-eval-ref
StackScribe Apr 20, 2023
610432d
Merge branch 'main' into 0412-eval-ref
StackScribe Apr 20, 2023
c60874a
Add metrics; update for 0.8.0
StackScribe Apr 21, 2023
e003a8d
Merge branch '0412-eval-ref' of github.com:StackScribe/lifecycle-tool…
StackScribe Apr 21, 2023
771c951
Merge branch 'main' into 0412-eval-ref
StackScribe Apr 21, 2023
9aea805
delete concepts/metrics
StackScribe Apr 21, 2023
ea4146b
Merge branch '0412-eval-ref' of github.com:StackScribe/lifecycle-tool…
StackScribe Apr 22, 2023
e8c5e65
Merge branch 'main' into 0412-eval-ref
StackScribe Apr 22, 2023
4660b30
Flo comments
StackScribe Apr 23, 2023
53829ce
Merge branch '0412-eval-ref' of github.com:StackScribe/lifecycle-tool…
StackScribe Apr 23, 2023
6ccac15
Flo comments
StackScribe Apr 24, 2023
718dba2
fixing links
aepfli Apr 24, 2023
efdd43c
crd-ref update
aepfli Apr 24, 2023
f4266a9
Merge remote-tracking branch 'upstream/main' into 0412-eval-ref
aepfli Apr 24, 2023
ccb7747
clarify evaluation target
StackScribe Apr 24, 2023
5065023
delete mention of KeptnEvaluationDefinition from metricsprovider intro
StackScribe Apr 24, 2023
80deefe
Merge branch 'main' into 0412-eval-ref
StackScribe Apr 24, 2023
db39067
Update docs/content/en/docs/implementing/metrics.md
StackScribe Apr 25, 2023
8664450
Update docs/content/en/docs/implementing/metrics.md
StackScribe Apr 25, 2023
326cba2
Update docs/content/en/docs/implementing/metrics.md
StackScribe Apr 25, 2023
56cf54d
Update docs/content/en/docs/implementing/metrics.md
StackScribe Apr 25, 2023
e500c80
Update docs/content/en/docs/implementing/metrics.md
StackScribe Apr 25, 2023
09034be
Update docs/content/en/docs/implementing/metrics.md
StackScribe Apr 25, 2023
ba05ab8
Update docs/content/en/docs/implementing/metrics.md
StackScribe Apr 25, 2023
b9ec458
Update docs/content/en/docs/implementing/metrics.md
StackScribe Apr 25, 2023
7e6bcdc
Update docs/content/en/docs/yaml-crd-ref/evaluationprovider.md
StackScribe Apr 25, 2023
992903e
Update docs/content/en/docs/yaml-crd-ref/evaluationprovider.md
StackScribe Apr 25, 2023
6258b62
Update docs/content/en/docs/yaml-crd-ref/metric.md
StackScribe Apr 25, 2023
4828ff4
Update docs/content/en/docs/yaml-crd-ref/evaluationprovider.md
StackScribe Apr 25, 2023
d431642
Update docs/content/en/docs/yaml-crd-ref/metric.md
StackScribe Apr 25, 2023
2962a04
Update docs/content/en/docs/yaml-crd-ref/metric.md
StackScribe Apr 25, 2023
6153d77
Update docs/content/en/docs/yaml-crd-ref/metric.md
StackScribe Apr 25, 2023
47250d2
Update docs/content/en/docs/yaml-crd-ref/metricsprovider.md
StackScribe Apr 25, 2023
502dd9b
Update docs/content/en/docs/yaml-crd-ref/metricsprovider.md
StackScribe Apr 25, 2023
d4498ec
Update docs/content/en/docs/yaml-crd-ref/metricsprovider.md
StackScribe Apr 25, 2023
143fd29
Update docs/content/en/docs/yaml-crd-ref/metricsprovider.md
StackScribe Apr 25, 2023
5db8911
Update docs/content/en/docs/yaml-crd-ref/metricsprovider.md
StackScribe Apr 25, 2023
565ce86
Update docs/content/en/docs/yaml-crd-ref/metricsprovider.md
StackScribe Apr 25, 2023
e27895b
Update docs/content/en/docs/implementing/metrics.md
StackScribe Apr 25, 2023
cb422e2
Merge branch 'main' into 0412-eval-ref
StackScribe Apr 25, 2023
d9bd066
mo comments
StackScribe Apr 25, 2023
a2c1ba9
Merge branch '0412-eval-ref' of github.com:StackScribe/lifecycle-tool…
StackScribe Apr 25, 2023
098391e
Merge branch 'main' into 0412-eval-ref
StackScribe Apr 25, 2023
c12c6cf
Update docs/content/en/docs/implementing/_index.md
StackScribe Apr 26, 2023
f87d60f
Update docs/content/en/docs/implementing/metrics.md
StackScribe Apr 26, 2023
fb924ca
Update docs/content/en/docs/implementing/metrics.md
StackScribe Apr 26, 2023
8c37067
Update docs/content/en/docs/implementing/metrics.md
StackScribe Apr 26, 2023
e6e9a9b
Update docs/content/en/docs/yaml-crd-ref/evaluationdefinition.md
StackScribe Apr 26, 2023
20c4b6c
remove ref to specific versions for features
StackScribe Apr 26, 2023
e35f915
Update metrics.md
StackScribe Apr 26, 2023
c4d17af
Merge branch 'main' into 0412-eval-ref
StackScribe Apr 26, 2023
6d1666a
remove mention of k8s metrics from intro
StackScribe May 1, 2023
8bef90a
fix list in implementing/_index.md
StackScribe May 1, 2023
044143c
Merge branch 'main' into 0412-eval-ref
StackScribe May 1, 2023
815df79
usage note, example from giovanni's PR
StackScribe May 2, 2023
937128a
Merge branch '0412-eval-ref' of github.com:StackScribe/lifecycle-tool…
StackScribe May 2, 2023
5590c67
add go.sum go.mod so I can push content
StackScribe May 2, 2023
72339ab
Update docs/content/en/docs/implementing/_index.md
StackScribe May 5, 2023
20a604b
Update docs/content/en/docs/yaml-crd-ref/metricsprovider.md
StackScribe May 5, 2023
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
49 changes: 0 additions & 49 deletions docs/content/en/docs/concepts/evaluations/_index.md

This file was deleted.

12 changes: 12 additions & 0 deletions docs/content/en/docs/implementing/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ This section is under development.
Information that is published here has been reviewed for technical accuracy
but the format and content is still evolving.
We welcome your input!**

This section provides information about how to implement
various features and functionality with the Keptn Lifecycle Toolkit.
The following topics are covered:

* Workloads, Applications, and Deployments

* Evaluations
* [Metrics](metrics.md) that provides a single entry-point
to site metrics at the application or workload level,
based on one or more standard data providers
* Tracing
165 changes: 165 additions & 0 deletions docs/content/en/docs/implementing/metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
---
title: Keptn Metrics
description: Implement Keptn site metrics
weight: 130
---

The Keptn Metrics Operator provides a single entry point
to all metrics in the cluster
and allows you to define metrics based on multiple data platforms
and multiple instances of any data platform.
Metrics are fetched independently
and can be used for an evaluation at workload- and application-level.

This data can be displayed on Grafana
or another standard dashboard application that you configure
or can be retrieved using standard Kubernetes commands.

TODO: Add more introductory info

## Keptn metric basics

Keptn metrics are implemented with two CRDs:

* [KeptnMetric](../yaml-crd-ref/metric.md) --
define the metric to report
* [KeptnMetricsProvider](../yaml-crd-ref/metricsprovider.md) --
define the configuration for a data provider

A Metric can be created with a query that fetches data for a property
that describes some quality of the application,
but this is not done automatically.

## Using OpenTelemetry with Keptn metrics

Keptn metrics can be exposed as OpenTelemetry (OTel) metrics
via port `9999` of the KLT metrics-operator.

To expose OTel metrics,
be sure that the `EXPOSE_KEPTN_METRICS` environment variable
in the `metrics-operator` manifest is set to `true`,
which is the default value.

To access the metrics, use the following command:

```shell
kubectl port-forward deployment/metrics-operator 9999 -n keptn-lifecycle-toolkit-system
```

You can access the metrics from your browser at: `http://localhost:9999`

## Accessing Metrics via the Kubernetes Custom Metrics API

`KeptnMetrics` can also be retrieved via the Kubernetes Custom Metrics API.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

### Using the HorizontalPodAutoscaler

Use the Kubernetes Custom Metrics API
to refer to `KeptnMetric` via the
[Kubernetes HorizontalPodAutoscaler](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/)
(HPA),
as in the following example:

```yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: podtato-head-entry
namespace: podtato-kubectl
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: podtato-head-entry
minReplicas: 1
maxReplicas: 10
metrics:
- type: Object
object:
metric:
name: keptnmetric-sample
describedObject:
apiVersion: metrics.keptn.sh/v1alpha1
kind: KeptnMetric
name: keptnmetric-sample
target:
type: Value
value: "10"
```

See the [Scaling Kubernetes Workloads based on Dynatrace Metrics](https://www.linkedin.com/pulse/scaling-kubernetes-workloads-based-dynatrace-metrics-keptnproject/)
blog post
for a detailed discussion of doing this with Dynatrace metrics.
The same approach could be used to implement HPA with other data providers.

### Retrieve KeptnMetric values with kubectl

Use the `kubectl get --raw` command
to retrieve the values of a `KeptnMetric`, as in the following example:

```shell
$ kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta2/namespaces/podtato-kubectl/keptnmetrics.metrics.sh/keptnmetric-sample/keptnmetric-sample" | jq .

{
"kind": "MetricValueList",
"apiVersion": "custom.metrics.k8s.io/v1beta2",
"metadata": {},
"items": [
{
"describedObject": {
"kind": "KeptnMetric",
"namespace": "podtato-kubectl",
"name": "keptnmetric-sample",
"apiVersion": "metrics.keptn.sh/v1alpha1"
},
"metric": {
"name": "keptnmetric-sample",
"selector": {
"matchLabels": {
"app": "frontend"
}
}
},
"timestamp": "2023-01-25T09:26:15Z",
"value": "10"
}
]
}
```

### Filter on matching labels

You can filter based on matching labels.
For example, to retrieve all metrics
that are labelled with `app=frontend`,
use the following command:

```shell
$ kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta2/namespaces/podtato-kubectl/keptnmetrics.metrics.sh/*/*?labelSelector=app%3Dfrontend" | jq .

{
"kind": "MetricValueList",
"apiVersion": "custom.metrics.k8s.io/v1beta2",
"metadata": {},
"items": [
{
"describedObject": {
"kind": "KeptnMetric",
"namespace": "keptn-lifecycle-toolkit-system",
"name": "keptnmetric-sample",
"apiVersion": "metrics.keptn.sh/v1alpha3"
},
"metric": {
"name": "keptnmetric-sample",
"selector": {
"matchLabels": {
"app": "frontend"
}
}
},
"timestamp": "2023-01-25T09:26:15Z",
"value": "10"
}
]
}
```
124 changes: 124 additions & 0 deletions docs/content/en/docs/yaml-crd-ref/evaluationdefinition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
title: KeptnEvaluationDefinition
description: Define an evaluation query
weight: 20
---

A `KeptnEvaluationDefinition` defines evaluation tasks
that can be run by the Keptn Lifecycle Toolkit
as part of pre- and post-analysis phases of a workload or application.

## Yaml Synopsis

```yaml
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
apiVersion: lifecycle.keptn.sh/v1alpha3
kind: KeptnEvaluationDefinition
metadata:
name: <evaluation-name>
spec:
objectives:
- evaluationTarget: ">1"
keptnMetricRef:
name: available-cpus
namespace: some-namespace
```

## Fields

* **apiVersion** -- API version being used.
Must be `v1alpha3` or later for this syntax.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be painful to maintain. At each new API release, we would need to change it. I suggest creating a pointer towards the autogenerated docs of the CRDs to find the right version.

* **kind** -- Resource type.
Must be set to `KeptnEvaluationDefinition`

* **metadata**
* **name** -- Unique name of this evaluation
such as `pre-deploy-eval` or `post-deploy-resource-eval`.
Names must comply with the
[Kubernetes Object Names and IDs](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names)
specification.

* **spec**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings about having this manually maintained. The APIs will change continuously and we need to keep this section aligned with the implementation. For the fields, we generate the documentation automatically in the API reference page: https://lifecycle.keptn.sh/docs/crd-ref/
I would rather keep it there so we don't have to maintain the fields in multiple places


* **objectives** -- define the evaluations to be performed.
Each objective is expressed as a `keptnMetricRef`
and an `evaluationTarget` value.

* **KeptnMericRef** -- A reference to the
[KeptnMetric](metric.md) object that contains the value,
identified by `name` and `namespace`
* **evaluationTarget** -- Desired value of the query,
expressed as an arithmatic formula,
usually less than (`<`) or greater than (`>`)
This is used to define success or failure criteria
for the referenced `KeptnMetric` in order to pass or fail
the pre- and post-evaluation stages

## Usage

A `KeptnEvaluationDefinition` references one or more
[KeptnMetric](metric.md) CRDs.
When multiple `KeptnMetric`s are used,
the Keptn Lifecycle Toolkit considers the evaluation successful
if **all** metrics meet their `evaluationTarget`.


## Example

```yaml
apiVersion: lifecycle.keptn.sh/v1alpha3
kind: KeptnEvaluationDefinition
metadata:
name: my-prometheus-evaluation
namespace: example
spec:
source: prometheus
objectives:
- keptnMetricRef:
name: available-cpus
namespace: example
evaluationTarget: ">1"
- keptnMetricRef:
name: cpus-throttling
namespace: example
evaluationTarget: "<0.01"
```

## Files

API Reference:

## Differences between versions

In the `v1alpha1` and `v1alpha2` API versions,
`KeptnEvaluationDefinition` referenced the `KeptnEvaluationProvider` CRD
to identify the data source associated with this definition
and itself contained the queries
that are now taken from the specified [KeptnMetric](metric.md) CRD.
The synopsis was:

```yaml
apiVersion: lifecycle.keptn.sh/v1alpha2
kind: KeptnEvaluationDefinition
metadata:
name: <evaluation-name>
spec:
source: prometheus | dynatrace | datadog
objectives:
- name: query-1
query: "xxxx"
evaluationTarget: <20
- name: query-2
query: "yyyy"
evaluationTarget: >4
```

Beginning with `v1alpha3` API version,
`KeptnEvaluationDefinition` references a `keptnMetricRef`
that points to a [KeptnMetric](metric.md) CRD,
that defines the data source, the query and the namespace to use.
The `KeptnEvaluationDefinition` merely specifies the evaluation target.

## See also

* [KeptnMetricsProvider](metricsprovider.md)
* [KeptnMetric](metric.md)
5 changes: 0 additions & 5 deletions docs/content/en/docs/yaml-crd-ref/evaluationdefnition.md

This file was deleted.

Loading