github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/api-docs/scaling-policies.mdx (about)

     1  ---
     2  layout: api
     3  page_title: Scaling Policies - HTTP API
     4  sidebar_title: Scaling Policies
     5  description: The /scaling/policy endpoints are used to list and view scaling policies.
     6  ---
     7  
     8  # Scaling Policies HTTP API
     9  
    10  The `/scaling/policies` and `/scaling/policy/` endpoints are used to list and view scaling policies.
    11  
    12  ## List Scaling Policies
    13  
    14  This endpoint returns the scaling policies from all jobs.
    15  
    16  | Method | Path                | Produces           |
    17  | ------ | ------------------- | ------------------ |
    18  | `GET`  | `/scaling/policies` | `application/json` |
    19  
    20  The table below shows this endpoint's support for
    21  [blocking queries](/api-docs#blocking-queries), [consistency modes](/api-docs#consistency-modes) and
    22  [required ACLs](/api-docs#acls).
    23  
    24  | Blocking Queries | Consistency Modes | ACL Required                      |
    25  | ---------------- | ----------------- | --------------------------------- |
    26  | `YES`            | `all`             | `namespace:list-scaling-policies` |
    27  
    28  ### Parameters
    29  
    30  - `job` `(string: "")`- Specifies the job ID to filter policies by.
    31  
    32  - `type` `(string: "")` - Specifies the type of scaling policy to filter by. In
    33    the open source version of Nomad, `horizontal` is the only supported value.
    34    Within Nomad Enterprise, `vertical_mem` and `vertical_cpu` are supported along
    35    with `vertical`. The latter returns policies matching both `vertical_mem` and
    36    `vertical_cpu`.
    37  
    38  ### Sample Request
    39  
    40  ```shell-session
    41  $ curl \
    42      https://localhost:4646/v1/scaling/policies
    43  ```
    44  
    45  ```shell-session
    46  $ curl \
    47      https://localhost:4646/v1/scaling/policies?job=example
    48  ```
    49  
    50  ```shell-session
    51  $ curl \
    52      https://localhost:4646/v1/scaling/policies?type=vertical
    53  ```
    54  
    55  ### Sample Response
    56  
    57  ```json
    58  [
    59    {
    60      "ID": "b2c64295-4315-2fdc-6158-a27156808729",
    61      "Enabled": true,
    62      "Type": "vertical_cpu",
    63      "Target": {
    64        "Namespace": "default",
    65        "Job": "example",
    66        "Group": "cache",
    67        "Task": "redis"
    68      },
    69      "CreateIndex": 1340,
    70      "ModifyIndex": 1340
    71    },
    72    {
    73      "ID": "c355d0ec-7aa1-2604-449d-4ec79c813d2c",
    74      "Enabled": true,
    75      "Type": "vertical_mem",
    76      "Target": {
    77        "Job": "example",
    78        "Group": "cache",
    79        "Task": "redis",
    80        "Namespace": "default"
    81      },
    82      "CreateIndex": 1340,
    83      "ModifyIndex": 1340
    84    },
    85    {
    86      "ID": "31a53813-24df-b2ad-77dc-1b4bad4e7dca",
    87      "Enabled": true,
    88      "Type": "horizontal",
    89      "Target": {
    90        "Job": "example",
    91        "Group": "cache",
    92        "Namespace": "default"
    93      },
    94      "CreateIndex": 1358,
    95      "ModifyIndex": 1358
    96    }
    97  ]
    98  ```
    99  
   100  ## Read Scaling Policy
   101  
   102  This endpoint reads a specific scaling policy.
   103  
   104  | Method | Path                         | Produces           |
   105  | ------ | ---------------------------- | ------------------ |
   106  | `GET`  | `/scaling/policy/:policy_id` | `application/json` |
   107  
   108  The table below shows this endpoint's support for
   109  [blocking queries](/api-docs#blocking-queries), [consistency modes](/api-docs#consistency-modes) and
   110  [required ACLs](/api-docs#acls).
   111  
   112  | Blocking Queries | Consistency Modes | ACL Required                    |
   113  | ---------------- | ----------------- | ------------------------------- |
   114  | `YES`            | `all`             | `namespace:read-scaling-policy` |
   115  
   116  ### Parameters
   117  
   118  - `:policy_id` `(string: <required>)` - Specifies the ID of the scaling policy (as returned
   119    by the scaling policy list endpoint). This is specified as part of the path.
   120  
   121  ### Sample Request
   122  
   123  ```shell-session
   124  $ curl \
   125      https://localhost:4646/v1/scaling/policy/5e9f9ef2-5223-6d35-bac1-be0f3cb974ad
   126  ```
   127  
   128  ### Sample Response
   129  
   130  ```json
   131  {
   132    "CreateIndex": 10,
   133    "Enabled": true,
   134    "ID": "5e9f9ef2-5223-6d35-bac1-be0f3cb974ad",
   135    "Type": "horizontal",
   136    "Max": 10,
   137    "Min": 0,
   138    "ModifyIndex": 10,
   139    "Policy": {
   140      "engage": true,
   141      "foo": "bar",
   142      "howdy": "doody",
   143      "value": 6.0
   144    },
   145    "Target": {
   146      "Group": "cache",
   147      "Job": "example",
   148      "Namespace": "default"
   149    }
   150  }
   151  ```