Skip to content

Commit

Permalink
docs: document timeframe feature for KeptnMetric (#1703)
Browse files Browse the repository at this point in the history
  • Loading branch information
rakshitgondwal authored Jul 19, 2023
1 parent 8e2aa3b commit 077f0d5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
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

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"

0 comments on commit 077f0d5

Please sign in to comment.