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

Add metrics API scaler docs #239

Merged
merged 8 commits into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions content/blog/keda-2.0-beta.md.draft
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Here are some highlights:
- Provide more information when quering KEDA resources with `kubectl`
- **Extensibility**
- Introduction of External Push scaler ([docs](https://keda.sh/docs/2.0/scalers/external-push/))
- Introduction of Metric API scaler ([docs](https://keda.sh/docs/2.0/scalers/metrics-api/))
- Provide KEDA client-go library

For a full list of changes, we highly recommend going through [our changelog](https://github.com/kedacore/keda/blob/v2/CHANGELOG.md#v200)! With our stable release, we'll provide a full overview of what's released in a new blog post.
Expand Down
59 changes: 59 additions & 0 deletions content/docs/2.0/scalers/metrics-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
+++
turbaszek marked this conversation as resolved.
Show resolved Hide resolved
title = "Metrics API"
layout = "scaler"
availability = "v2.0+"
maintainer = "Community"
description = "Scale applications based on a metric provided by an API"
go_file = "metrics_api_scaler"
+++

### Trigger Specification

This specification describes the `metrics-api` trigger that scales based on a metric value provided by an API.
This scaler allows users to utilize any existing APIs as a metric provider.
turbaszek marked this conversation as resolved.
Show resolved Hide resolved

**Parameter list:**
- `url`: Full URL of the API operation to call to get the metric value (eg. `http://app:1317/api/v1/stats`).
- `valueLocation`: [GJSON path notation](https://github.com/tidwall/gjson#path-syntax) to refer to the field in
the payload containing the metric value
- `targetValue`: Target value to scale on. When the metric provided by the API is equal or higher to this value,
KEDA will start scaling out. When the metric is 0 or less, KEDA will scale down to 0.

Here is an example of trigger configuration using metric-api scaler:

```yaml
turbaszek marked this conversation as resolved.
Show resolved Hide resolved
tomkerkhove marked this conversation as resolved.
Show resolved Hide resolved
triggers:
- type: metric-api
metadata:
targetValue: "8"
url: "http://api:3232/api/v1/stats"
valueLocation: "components.worker.tasks"
```

### Authentication Parameters

Not supported yet.

### Example
turbaszek marked this conversation as resolved.
Show resolved Hide resolved

When checking current metric this scaler sends GET request to provided `url` and then uses `valueLocation`
to access the value in response's payload.

The above example expects that the API endpoint will return response similar to this one:
```json
{
"components": {
"worker": {
"tasks": 12,
...
},
...
},
...
}
```
Assuming such response, Metrics API trigger will figure out that current metric value is 12.

> NOTE: This scaler scales deployment to 0 if and only if the value of the metric is lower or equal to zero.
turbaszek marked this conversation as resolved.
Show resolved Hide resolved

> NOTE: The value of the metric must be json number type. The value is casted to **integer**.