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: document timeframe feature for KeptnMetric #1703

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
24 changes: 24 additions & 0 deletions docs/content/en/docs/implementing/evaluatemetrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,30 @@ $ kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta2/namespaces/podtato-kube
}
```

## Querying Metrics over a Timerange
odubajDT marked this conversation as resolved.
Show resolved Hide resolved

You can query metrics over a specified timeframe.
Let's suppose you set the `range.interval` field to be `3m`,
the Keptn Metrics Operator would query the metrics for the
last 3 minutes which means the
`from = currentTime - range.interval` and `to = currentTime`.

The default value is set to be `5m` if the `range.interval` is not set.

```yaml
apiVersion: metrics.keptn.sh/v1alpha3
kind: KeptnMetric
metadata:
name: good-metric
spec:
provider:
name: my-provider
query: "sum(kube_pod_container_resource_limits{resource='cpu'})"
fetchIntervalSeconds: 10
range:
interval: "3m"
```

## Using the HorizontalPodAutoscaler

Use the Kubernetes Custom Metrics API
Expand Down
7 changes: 7 additions & 0 deletions docs/content/en/docs/yaml-crd-ref/metric.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ spec:
name: "<named-provider>"
query: "<query>"
fetchIntervalSeconds: <#-seconds>
range:
interval: "<timeframe>"
```

## Fields
Expand Down Expand Up @@ -59,6 +61,9 @@ spec:
* **query** -- String in the provider-specific query language,
used to obtain a metric.
* **fetchIntervalSeconds** -- Number of seconds between updates of the metric.
* **range**
* **interval** -- Timeframe for which the metric would be queried.
Defaults to 5m.

## Usage

Expand Down Expand Up @@ -96,6 +101,8 @@ spec:
name: "my-provider"
query: "sum(kube_pod_container_resource_limits{resource='cpu'})"
fetchIntervalSeconds: 5
range:
interval: "5m"
```

## Files
Expand Down
4 changes: 3 additions & 1 deletion examples/support/metrics/metric.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ metadata:
spec:
provider:
name: my-provider
query: 'avg(rate(container_cpu_cfs_throttled_seconds_total{container="server", namespace="podtato-metrics"}[1m]))'
query: 'avg(rate(container_cpu_cfs_throttled_seconds_total{container="server", namespace="podtato-metrics"}))'
fetchIntervalSeconds: 10
range:
interval: "1m"
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ spec:
name: some-name
query: "sum(kube_pod_container_resource_limits{resource='cpu'}) - sum(kube_node_status_capacity{resource='cpu'})"
fetchIntervalSeconds: 10
range:
interval: "5m"
Loading