Create or update autoscaling policy API

Create or update autoscaling policy API

This feature is designed for indirect use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported.

New API reference

For the most up-to-date API details, refer to Autoscaling APIs.

Creates or updates an autoscaling policy.

Request

  1. resp = client.autoscaling.put_autoscaling_policy(
  2. name="<name>",
  3. policy={
  4. "roles": [],
  5. "deciders": {
  6. "fixed": {}
  7. }
  8. },
  9. )
  10. print(resp)
  1. const response = await client.autoscaling.putAutoscalingPolicy({
  2. name: "<name>",
  3. policy: {
  4. roles: [],
  5. deciders: {
  6. fixed: {},
  7. },
  8. },
  9. });
  10. console.log(response);
  1. PUT /_autoscaling/policy/<name>
  2. {
  3. "roles": [],
  4. "deciders": {
  5. "fixed": {
  6. }
  7. }
  8. }

Prerequisites

Description

This API puts an autoscaling policy with the provided name. See Autoscaling Deciders for available deciders.

Query parameters

master_timeout

(Optional, time units) Period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. Defaults to 30s. Can also be set to -1 to indicate that the request should never timeout.

timeout

(Optional, time units) Period to wait for a response from all relevant nodes in the cluster after updating the cluster metadata. If no response is received before the timeout expires, the cluster metadata update still applies but the response will indicate that it was not completely acknowledged. Defaults to 30s. Can also be set to -1 to indicate that the request should never timeout.

Examples

This example puts an autoscaling policy named my_autoscaling_policy using the fixed autoscaling decider, applying to the set of nodes having (only) the “data_hot” role.

  1. resp = client.autoscaling.put_autoscaling_policy(
  2. name="my_autoscaling_policy",
  3. policy={
  4. "roles": [
  5. "data_hot"
  6. ],
  7. "deciders": {
  8. "fixed": {}
  9. }
  10. },
  11. )
  12. print(resp)
  1. const response = await client.autoscaling.putAutoscalingPolicy({
  2. name: "my_autoscaling_policy",
  3. policy: {
  4. roles: ["data_hot"],
  5. deciders: {
  6. fixed: {},
  7. },
  8. },
  9. });
  10. console.log(response);
  1. PUT /_autoscaling/policy/my_autoscaling_policy
  2. {
  3. "roles" : [ "data_hot" ],
  4. "deciders": {
  5. "fixed": {
  6. }
  7. }
  8. }

The API returns the following result:

  1. {
  2. "acknowledged": true
  3. }