From 535835a9e929e76f4edd8aa06dc6709aefb89c95 Mon Sep 17 00:00:00 2001 From: Tomek Urbaszek Date: Tue, 25 Aug 2020 22:24:29 +0200 Subject: [PATCH 1/8] Add metrics API scaler docs Signed-off-by: Tomek Urbaszek --- content/docs/2.0/scalers/metrics-api.md | 95 +++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 content/docs/2.0/scalers/metrics-api.md diff --git a/content/docs/2.0/scalers/metrics-api.md b/content/docs/2.0/scalers/metrics-api.md new file mode 100644 index 000000000..fe5e2b586 --- /dev/null +++ b/content/docs/2.0/scalers/metrics-api.md @@ -0,0 +1,95 @@ ++++ +title = "Metrics API" +layout = "scaler" +availability = "v2.0+" +maintainer = "Community" +description = "Scale applications based on a metric value from an API" +go_file = "metrics_api_scaler" ++++ + +This specification describes the `metrics-api` trigger that scales based on a metric value from an API. + +### Trigger prerequisites + +To use an external API as a source of metric you need to have a following endpoint: + +```yaml +/api/v1/metric/{metric}: + get: + summary: Get Metric + description: Get value for a given metric + operationId: GetMetric + parameters: + - name: metric + in: path + required: true + schema: + type: string + description: Name of the metric for which information is requested + responses: + '200': + description: Metric inforation was provided + content: + application/json: + schema: + $ref: '#/components/schemas/ReportedMetric' + '404': + description: Metric is not supported + '401': + $ref: '#/components/responses/UnauthorizedError' + '500': + description: Unable to determine metric information + tags: + - Metrics + security: + - basic_auth: [] + - api_key: [] +``` +which returns: +```yaml +ReportedMetric: + type: object + required: + - name + - value + properties: + name: + type: string + value: + type: number +``` + + +### Trigger Specification + +The metrics API requires following configuration values: +- `apiURL` string repesenting the base URL of the API (i.e `http://app:1317/api/v1/`). +- `metricName` the metric name to be used to retive value . +- `targetValue` the target value for HPA. As long as the current metric doesn't match `TargetValue`, + HPA will increase the number of the pods until it reaches the maximum number of pods allowed to scale to. + + +An example of scaled object using metric API: + +```yaml +apiVersion: keda.k8s.io/v1alpha1 +kind: ScaledObject +metadata: + name: metrics-api-scaledobject + namespace: default + labels: + deploymentName: dummy +spec: + maxReplicaCount: 4 + scaleTargetRef: + deploymentName: dummy + triggers: + - type: metric-api + metadata: + targetValue: "1" + apiURL: "http://api:3232/api/v1" + metricName: "workersNumber" +``` + +**Note**: +This scaler scales deployment to 0 if and only if the value of the metric is lower or equal to zero. From b223d4fad139e08a7aecf25c72716a00d8bcddb6 Mon Sep 17 00:00:00 2001 From: Tomek Urbaszek Date: Wed, 26 Aug 2020 10:42:49 +0200 Subject: [PATCH 2/8] fixup! Add metrics API scaler docs Signed-off-by: Tomek Urbaszek --- content/blog/keda-2.0-beta.md.draft | 1 + content/docs/2.0/scalers/metrics-api.md | 202 ++++++++++++++++-------- 2 files changed, 138 insertions(+), 65 deletions(-) diff --git a/content/blog/keda-2.0-beta.md.draft b/content/blog/keda-2.0-beta.md.draft index 76d797c98..5bbf601f7 100644 --- a/content/blog/keda-2.0-beta.md.draft +++ b/content/blog/keda-2.0-beta.md.draft @@ -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. diff --git a/content/docs/2.0/scalers/metrics-api.md b/content/docs/2.0/scalers/metrics-api.md index fe5e2b586..df5e3e896 100644 --- a/content/docs/2.0/scalers/metrics-api.md +++ b/content/docs/2.0/scalers/metrics-api.md @@ -3,82 +3,23 @@ title = "Metrics API" layout = "scaler" availability = "v2.0+" maintainer = "Community" -description = "Scale applications based on a metric value from an API" +description = "Scale applications based on a metric from an API" go_file = "metrics_api_scaler" +++ -This specification describes the `metrics-api` trigger that scales based on a metric value from an API. - -### Trigger prerequisites - -To use an external API as a source of metric you need to have a following endpoint: - -```yaml -/api/v1/metric/{metric}: - get: - summary: Get Metric - description: Get value for a given metric - operationId: GetMetric - parameters: - - name: metric - in: path - required: true - schema: - type: string - description: Name of the metric for which information is requested - responses: - '200': - description: Metric inforation was provided - content: - application/json: - schema: - $ref: '#/components/schemas/ReportedMetric' - '404': - description: Metric is not supported - '401': - $ref: '#/components/responses/UnauthorizedError' - '500': - description: Unable to determine metric information - tags: - - Metrics - security: - - basic_auth: [] - - api_key: [] -``` -which returns: -```yaml -ReportedMetric: - type: object - required: - - name - - value - properties: - name: - type: string - value: - type: number -``` - - ### Trigger Specification +This specification describes the `metrics-api` trigger that scales based on a metric value from an API. + The metrics API requires following configuration values: - `apiURL` string repesenting the base URL of the API (i.e `http://app:1317/api/v1/`). - `metricName` the metric name to be used to retive value . -- `targetValue` the target value for HPA. As long as the current metric doesn't match `TargetValue`, - HPA will increase the number of the pods until it reaches the maximum number of pods allowed to scale to. - +- `targetValue` the target value is the target value to scale on. When the metric provided by the + API is equal or higher to this value, KEDA will start scaling out. -An example of scaled object using metric API: +An example of scaled object spec using metric API: ```yaml -apiVersion: keda.k8s.io/v1alpha1 -kind: ScaledObject -metadata: - name: metrics-api-scaledobject - namespace: default - labels: - deploymentName: dummy spec: maxReplicaCount: 4 scaleTargetRef: @@ -93,3 +34,134 @@ spec: **Note**: This scaler scales deployment to 0 if and only if the value of the metric is lower or equal to zero. + +### Trigger prerequisites + +To use an external API it has to comply with: + +```yaml +openapi: 3.0.1 +info: + title: KEDA - External Metric Source Petstore + description: >- + This is the specification to comply with for external KEDA metric sources. + termsOfService: 'http://swagger.io/terms/' + contact: + email: apiteam@swagger.io + license: + name: Apache 2.0 + url: 'http://www.apache.org/licenses/LICENSE-2.0.html' + version: 1.0.0 +externalDocs: + description: Find out more about Swagger + url: 'http://swagger.io' +servers: + - url: 'https://samples.keda.sh/' +tags: + - name: Health + description: Operations about runtime health + - name: Metrics + description: Operations about providing metrics to KEDA +paths: + /api/v1/metric/{metric}: + get: + summary: Get Metric + description: Get value for a given metric + operationId: GetMetric + parameters: + - name: metric + in: path + required: true + schema: + type: string + description: Name of the metric for which information is requested + responses: + '200': + description: Metric inforation was provided + content: + application/json: + schema: + $ref: '#/components/schemas/ReportedMetric' + '404': + description: Metric is not supported + '401': + $ref: '#/components/responses/UnauthorizedError' + '500': + description: Unable to determine metric information + tags: + - Metrics + security: + - basic_auth: [] + - api_key: [] + /api/v1/metrics: + get: + summary: Get All Metrics + description: Provides a list of all supported metrics + operationId: GetMetrics + responses: + '200': + description: Metric inforation was provided + content: + application/json: + schema: + $ref: '#/components/schemas/MetricInfo' + '401': + $ref: '#/components/responses/UnauthorizedError' + '500': + description: Unable to determine metric information + tags: + - Metrics + security: + - basic_auth: [] + - api_key: [] + /api/v1/health: + get: + summary: Get Health + description: Provides information about the health of the runtime + operationId: GetHealth + responses: + '200': + description: External metric source is healthy + '401': + $ref: '#/components/responses/UnauthorizedError' + '500': + description: External metric source is not healthy + tags: + - Health + security: + - basic_auth: [] + - api_key: [] +components: + schemas: + MetricInfo: + type: array + items: + type: object + properties: + name: + type: string + ReportedMetric: + type: object + required: + - name + - value + properties: + name: + type: string + value: + type: number + responses: + UnauthorizedError: + description: Authentication information is missing or invalid + securitySchemes: + basic_auth: + type: http + scheme: basic + api_key: + type: apiKey + name: X-API-Key + in: header +security: + - basic_auth: [] + - api_key: [] +``` From cd3a1f05075f07289b23e1bba7fb83c266259a7d Mon Sep 17 00:00:00 2001 From: Tomek Urbaszek Date: Wed, 26 Aug 2020 10:50:58 +0200 Subject: [PATCH 3/8] fixup! fixup! Add metrics API scaler docs Signed-off-by: Tomek Urbaszek --- content/docs/2.0/scalers/metrics-api.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/docs/2.0/scalers/metrics-api.md b/content/docs/2.0/scalers/metrics-api.md index df5e3e896..ebc07ec5b 100644 --- a/content/docs/2.0/scalers/metrics-api.md +++ b/content/docs/2.0/scalers/metrics-api.md @@ -12,7 +12,7 @@ go_file = "metrics_api_scaler" This specification describes the `metrics-api` trigger that scales based on a metric value from an API. The metrics API requires following configuration values: -- `apiURL` string repesenting the base URL of the API (i.e `http://app:1317/api/v1/`). +- `apiURL` string representing the base URL of the API (i.e `http://app:1317/api/v1/`). - `metricName` the metric name to be used to retive value . - `targetValue` the target value is the target value to scale on. When the metric provided by the API is equal or higher to this value, KEDA will start scaling out. @@ -23,12 +23,12 @@ An example of scaled object spec using metric API: spec: maxReplicaCount: 4 scaleTargetRef: - deploymentName: dummy + name: dummy triggers: - type: metric-api metadata: targetValue: "1" - apiURL: "http://api:3232/api/v1" + url: "http://api:3232/api/v1" metricName: "workersNumber" ``` From 017cee714ab98309b803dd76aebab4d4182cb41f Mon Sep 17 00:00:00 2001 From: Tomek Urbaszek Date: Wed, 26 Aug 2020 14:25:28 +0200 Subject: [PATCH 4/8] Add more information Signed-off-by: Tomek Urbaszek --- content/docs/2.0/scalers/metrics-api.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/content/docs/2.0/scalers/metrics-api.md b/content/docs/2.0/scalers/metrics-api.md index ebc07ec5b..2c721e0e7 100644 --- a/content/docs/2.0/scalers/metrics-api.md +++ b/content/docs/2.0/scalers/metrics-api.md @@ -12,24 +12,21 @@ go_file = "metrics_api_scaler" This specification describes the `metrics-api` trigger that scales based on a metric value from an API. The metrics API requires following configuration values: -- `apiURL` string representing the base URL of the API (i.e `http://app:1317/api/v1/`). -- `metricName` the metric name to be used to retive value . +- `url` string representing the base URL of the API (i.e `http://app:1317/api/v1/`). +- `metricName` the metric name to be used to retrieve value. Scaler will look for metric value under + `url/metric/{metricName}` endpoint. For more information check next section. - `targetValue` the target value is the target value to scale on. When the metric provided by the API is equal or higher to this value, KEDA will start scaling out. -An example of scaled object spec using metric API: +An example of triggers configuration using metric API scaler: ```yaml -spec: - maxReplicaCount: 4 - scaleTargetRef: - name: dummy - triggers: - - type: metric-api - metadata: - targetValue: "1" - url: "http://api:3232/api/v1" - metricName: "workersNumber" +triggers: +- type: metric-api + metadata: + targetValue: "1" + url: "http://api:3232/api/v1" + metricName: "workersNumber" ``` **Note**: @@ -165,3 +162,5 @@ security: - basic_auth: [] - api_key: [] ``` + +The `/health` endpoint is used once when creating new `metricsAPIScaler`. From 3ee0627b25cf8335cb44e910c307c7c1ceb72a68 Mon Sep 17 00:00:00 2001 From: Tomek Urbaszek Date: Wed, 2 Sep 2020 20:43:56 +0200 Subject: [PATCH 5/8] Update docs Signed-off-by: Tomek Urbaszek --- content/docs/2.0/scalers/metrics-api.md | 170 ++++-------------------- 1 file changed, 29 insertions(+), 141 deletions(-) diff --git a/content/docs/2.0/scalers/metrics-api.md b/content/docs/2.0/scalers/metrics-api.md index 2c721e0e7..30492c83c 100644 --- a/content/docs/2.0/scalers/metrics-api.md +++ b/content/docs/2.0/scalers/metrics-api.md @@ -9,158 +9,46 @@ go_file = "metrics_api_scaler" ### Trigger Specification -This specification describes the `metrics-api` trigger that scales based on a metric value from an API. +This specification describes the `metrics-api` trigger that scales based on a metric value from an API. This scaler +allows users to utilize any existing APIs as a source of metric. -The metrics API requires following configuration values: -- `url` string representing the base URL of the API (i.e `http://app:1317/api/v1/`). -- `metricName` the metric name to be used to retrieve value. Scaler will look for metric value under - `url/metric/{metricName}` endpoint. For more information check next section. +The metrics-api trigger requires following configuration values: +- `url` string representing the full URL that will be used to get the metric (i.e `http://app:1317/api/v1/stats`). +- `valueLocation` string using [GJSON path notation](https://github.com/tidwall/gjson#path-syntax) to point to + required value that will be used as current metric value - `targetValue` the target value is the target value to scale on. When the metric provided by the API is equal or higher to this value, KEDA will start scaling out. -An example of triggers configuration using metric API scaler: +Here is an example of trigger configuration using metric-api scaler: ```yaml triggers: - type: metric-api metadata: - targetValue: "1" - url: "http://api:3232/api/v1" - metricName: "workersNumber" + targetValue: "8" + url: "http://api:3232/api/v1/stats" + valueLocation: "components.worker.tasks" ``` +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 used API will return response similar to this +one: +```json +{ + "components": { + "worker": { + "tasks": 12, + ... + }, + ... + }, + ... +} +``` +Assuming such response, metric-api trigger will figure out that current metric value is 12. And because 12 > 8 it +would make KEDA to start scaling out. + **Note**: This scaler scales deployment to 0 if and only if the value of the metric is lower or equal to zero. -### Trigger prerequisites - -To use an external API it has to comply with: - -```yaml -openapi: 3.0.1 -info: - title: KEDA - External Metric Source Petstore - description: >- - This is the specification to comply with for external KEDA metric sources. - termsOfService: 'http://swagger.io/terms/' - contact: - email: apiteam@swagger.io - license: - name: Apache 2.0 - url: 'http://www.apache.org/licenses/LICENSE-2.0.html' - version: 1.0.0 -externalDocs: - description: Find out more about Swagger - url: 'http://swagger.io' -servers: - - url: 'https://samples.keda.sh/' -tags: - - name: Health - description: Operations about runtime health - - name: Metrics - description: Operations about providing metrics to KEDA -paths: - /api/v1/metric/{metric}: - get: - summary: Get Metric - description: Get value for a given metric - operationId: GetMetric - parameters: - - name: metric - in: path - required: true - schema: - type: string - description: Name of the metric for which information is requested - responses: - '200': - description: Metric inforation was provided - content: - application/json: - schema: - $ref: '#/components/schemas/ReportedMetric' - '404': - description: Metric is not supported - '401': - $ref: '#/components/responses/UnauthorizedError' - '500': - description: Unable to determine metric information - tags: - - Metrics - security: - - basic_auth: [] - - api_key: [] - /api/v1/metrics: - get: - summary: Get All Metrics - description: Provides a list of all supported metrics - operationId: GetMetrics - responses: - '200': - description: Metric inforation was provided - content: - application/json: - schema: - $ref: '#/components/schemas/MetricInfo' - '401': - $ref: '#/components/responses/UnauthorizedError' - '500': - description: Unable to determine metric information - tags: - - Metrics - security: - - basic_auth: [] - - api_key: [] - /api/v1/health: - get: - summary: Get Health - description: Provides information about the health of the runtime - operationId: GetHealth - responses: - '200': - description: External metric source is healthy - '401': - $ref: '#/components/responses/UnauthorizedError' - '500': - description: External metric source is not healthy - tags: - - Health - security: - - basic_auth: [] - - api_key: [] -components: - schemas: - MetricInfo: - type: array - items: - type: object - properties: - name: - type: string - ReportedMetric: - type: object - required: - - name - - value - properties: - name: - type: string - value: - type: number - responses: - UnauthorizedError: - description: Authentication information is missing or invalid - securitySchemes: - basic_auth: - type: http - scheme: basic - api_key: - type: apiKey - name: X-API-Key - in: header -security: - - basic_auth: [] - - api_key: [] -``` - -The `/health` endpoint is used once when creating new `metricsAPIScaler`. +The value of the metric must be json number type. The value is casted to **integer**. From defcf2c678af347481565a76c33bd191fbbedeea Mon Sep 17 00:00:00 2001 From: Tomek Urbaszek Date: Thu, 3 Sep 2020 22:24:29 +0200 Subject: [PATCH 6/8] fixup! Update docs Signed-off-by: Tomek Urbaszek --- content/docs/2.0/scalers/metrics-api.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/content/docs/2.0/scalers/metrics-api.md b/content/docs/2.0/scalers/metrics-api.md index 30492c83c..e42075d09 100644 --- a/content/docs/2.0/scalers/metrics-api.md +++ b/content/docs/2.0/scalers/metrics-api.md @@ -13,7 +13,7 @@ This specification describes the `metrics-api` trigger that scales based on a me allows users to utilize any existing APIs as a source of metric. The metrics-api trigger requires following configuration values: -- `url` string representing the full URL that will be used to get the metric (i.e `http://app:1317/api/v1/stats`). +- `url` string representing the full URL that will be used to get the metric (eg. `http://app:1317/api/v1/stats`). - `valueLocation` string using [GJSON path notation](https://github.com/tidwall/gjson#path-syntax) to point to required value that will be used as current metric value - `targetValue` the target value is the target value to scale on. When the metric provided by the @@ -31,8 +31,8 @@ triggers: ``` 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 used API will return response similar to this -one: +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": { @@ -45,8 +45,7 @@ one: ... } ``` -Assuming such response, metric-api trigger will figure out that current metric value is 12. And because 12 > 8 it -would make KEDA to start scaling out. +Assuming such response, metric-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. From c1e84af5e7cb29020509be60d02c0a8170fb5aeb Mon Sep 17 00:00:00 2001 From: Tomek Urbaszek Date: Fri, 4 Sep 2020 09:00:01 +0200 Subject: [PATCH 7/8] fixup! fixup! Update docs Signed-off-by: Tomek Urbaszek --- content/docs/2.0/scalers/metrics-api.md | 36 ++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/content/docs/2.0/scalers/metrics-api.md b/content/docs/2.0/scalers/metrics-api.md index e42075d09..b8cb2e3e9 100644 --- a/content/docs/2.0/scalers/metrics-api.md +++ b/content/docs/2.0/scalers/metrics-api.md @@ -3,21 +3,21 @@ title = "Metrics API" layout = "scaler" availability = "v2.0+" maintainer = "Community" -description = "Scale applications based on a metric from an API" +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 from an API. This scaler -allows users to utilize any existing APIs as a source of metric. +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. -The metrics-api trigger requires following configuration values: -- `url` string representing the full URL that will be used to get the metric (eg. `http://app:1317/api/v1/stats`). -- `valueLocation` string using [GJSON path notation](https://github.com/tidwall/gjson#path-syntax) to point to - required value that will be used as current metric value -- `targetValue` the target value is the target value to scale on. When the metric provided by the - API is equal or higher to this value, KEDA will start scaling out. +**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: @@ -30,9 +30,16 @@ triggers: valueLocation: "components.worker.tasks" ``` +### Authentication Parameters + +Not supported yet. + +### Example + 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: +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": { @@ -45,9 +52,8 @@ similar to this one: ... } ``` -Assuming such response, metric-api trigger will figure out that current metric value is 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. +> NOTE: This scaler scales deployment to 0 if and only if the value of the metric is lower or equal to zero. -The value of the metric must be json number type. The value is casted to **integer**. +> NOTE: The value of the metric must be json number type. The value is casted to **integer**. From 13889913aff201c3823e759acbc1e3002176991a Mon Sep 17 00:00:00 2001 From: Tomek Urbaszek Date: Fri, 4 Sep 2020 09:19:59 +0200 Subject: [PATCH 8/8] fixup! fixup! fixup! Update docs Signed-off-by: Tomek Urbaszek --- content/docs/2.0/scalers/metrics-api.md | 41 +++++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/content/docs/2.0/scalers/metrics-api.md b/content/docs/2.0/scalers/metrics-api.md index b8cb2e3e9..fd3678cc0 100644 --- a/content/docs/2.0/scalers/metrics-api.md +++ b/content/docs/2.0/scalers/metrics-api.md @@ -10,14 +10,8 @@ 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. -**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. +This scaler allows users to utilize **any existing APIs** as a metric provider. Here is an example of trigger configuration using metric-api scaler: @@ -30,13 +24,42 @@ triggers: valueLocation: "components.worker.tasks" ``` +**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. + ### Authentication Parameters Not supported yet. ### Example -When checking current metric this scaler sends GET request to provided `url` and then uses `valueLocation` +Here is a full example of scaled object definition using Metric API trigger: + +```yaml +apiVersion: keda.sh/v1alpha1 +kind: ScaledObject +metadata: + name: http-scaledobject + namespace: keda + labels: + deploymentName: dummy +spec: + maxReplicaCount: 12 + scaleTargetRef: + name: dummy + triggers: + - type: metrics-api + metadata: + targetValue: "7" + url: "http://api:3232/components/stats" + valueLocation: 'components.worker.tasks' +``` + +When checking current metric Metrics API 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: @@ -54,6 +77,4 @@ The above example expects that the API endpoint will return response similar to ``` 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. - > NOTE: The value of the metric must be json number type. The value is casted to **integer**.