2020-03-24 22:08:34 +00:00
|
|
|
---
|
|
|
|
layout: api
|
|
|
|
page_title: Scaling Policies - HTTP API
|
2020-10-23 14:12:42 +00:00
|
|
|
sidebar_title: Scaling Policies
|
2020-03-24 22:08:34 +00:00
|
|
|
description: The /scaling/policy endpoints are used to list and view scaling policies.
|
|
|
|
---
|
|
|
|
|
|
|
|
# Scaling Policies HTTP API
|
|
|
|
|
|
|
|
The `/scaling/policies` and `/scaling/policy/` endpoints are used to list and view scaling policies.
|
|
|
|
|
2020-10-23 14:12:42 +00:00
|
|
|
## List Scaling Policies
|
2020-03-24 22:08:34 +00:00
|
|
|
|
|
|
|
This endpoint returns the scaling policies from all jobs.
|
|
|
|
|
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | ------------------- | ------------------ |
|
|
|
|
| `GET` | `/scaling/policies` | `application/json` |
|
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2020-03-26 23:43:03 +00:00
|
|
|
[blocking queries](/api-docs#blocking-queries), [consistency modes](/api-docs#consistency-modes) and
|
|
|
|
[required ACLs](/api-docs#acls).
|
2020-03-24 22:08:34 +00:00
|
|
|
|
2020-05-01 20:02:21 +00:00
|
|
|
| Blocking Queries | Consistency Modes | ACL Required |
|
|
|
|
| ---------------- | ----------------- | --------------------------------- |
|
|
|
|
| `YES` | `all` | `namespace:list-scaling-policies` |
|
2020-03-24 22:08:34 +00:00
|
|
|
|
2020-10-23 14:12:42 +00:00
|
|
|
### Parameters
|
|
|
|
|
|
|
|
- `job` `(string: "")`- Specifies the job ID to filter policies by.
|
|
|
|
|
|
|
|
- `type` `(string: "")` - Specifies the type of scaling policy to filter by. In
|
|
|
|
the open source version of Nomad, `horizontal` is the only supported value.
|
|
|
|
Within Nomad Enterprise, `vertical_mem` and `vertical_cpu` are supported along
|
|
|
|
with `vertical`. The latter returns policies matching both `vertical_mem` and
|
|
|
|
`vertical_cpu`.
|
|
|
|
|
2020-03-24 22:08:34 +00:00
|
|
|
### Sample Request
|
|
|
|
|
2020-05-18 20:53:06 +00:00
|
|
|
```shell-session
|
|
|
|
$ curl \
|
2020-03-24 22:08:34 +00:00
|
|
|
https://localhost:4646/v1/scaling/policies
|
|
|
|
```
|
|
|
|
|
2020-10-23 14:12:42 +00:00
|
|
|
```shell-session
|
|
|
|
$ curl \
|
|
|
|
https://localhost:4646/v1/scaling/policies?job=example
|
|
|
|
```
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
$ curl \
|
|
|
|
https://localhost:4646/v1/scaling/policies?type=vertical
|
|
|
|
```
|
|
|
|
|
2020-03-24 22:08:34 +00:00
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
2020-05-01 20:02:21 +00:00
|
|
|
{
|
2020-10-23 14:12:42 +00:00
|
|
|
"ID": "b2c64295-4315-2fdc-6158-a27156808729",
|
2020-05-01 20:02:21 +00:00
|
|
|
"Enabled": true,
|
2020-10-23 14:12:42 +00:00
|
|
|
"Type": "vertical_cpu",
|
2020-05-01 20:02:21 +00:00
|
|
|
"Target": {
|
2020-10-23 14:12:42 +00:00
|
|
|
"Namespace": "default",
|
|
|
|
"Job": "example",
|
2020-05-01 20:02:21 +00:00
|
|
|
"Group": "cache",
|
2020-10-23 14:12:42 +00:00
|
|
|
"Task": "redis"
|
|
|
|
},
|
|
|
|
"CreateIndex": 1340,
|
|
|
|
"ModifyIndex": 1340
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "c355d0ec-7aa1-2604-449d-4ec79c813d2c",
|
|
|
|
"Enabled": true,
|
|
|
|
"Type": "vertical_mem",
|
|
|
|
"Target": {
|
|
|
|
"Job": "example",
|
|
|
|
"Group": "cache",
|
|
|
|
"Task": "redis",
|
|
|
|
"Namespace": "default"
|
|
|
|
},
|
|
|
|
"CreateIndex": 1340,
|
|
|
|
"ModifyIndex": 1340
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"ID": "31a53813-24df-b2ad-77dc-1b4bad4e7dca",
|
|
|
|
"Enabled": true,
|
|
|
|
"Type": "horizontal",
|
|
|
|
"Target": {
|
2020-05-01 20:02:21 +00:00
|
|
|
"Job": "example",
|
2020-10-23 14:12:42 +00:00
|
|
|
"Group": "cache",
|
2020-05-01 20:02:21 +00:00
|
|
|
"Namespace": "default"
|
2020-10-23 14:12:42 +00:00
|
|
|
},
|
|
|
|
"CreateIndex": 1358,
|
|
|
|
"ModifyIndex": 1358
|
2020-05-01 20:02:21 +00:00
|
|
|
}
|
2020-03-24 22:08:34 +00:00
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2020-10-23 14:12:42 +00:00
|
|
|
## Read Scaling Policy
|
2020-03-24 22:08:34 +00:00
|
|
|
|
|
|
|
This endpoint reads a specific scaling policy.
|
|
|
|
|
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | ---------------------------- | ------------------ |
|
|
|
|
| `GET` | `/scaling/policy/:policy_id` | `application/json` |
|
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2020-03-26 23:43:03 +00:00
|
|
|
[blocking queries](/api-docs#blocking-queries), [consistency modes](/api-docs#consistency-modes) and
|
|
|
|
[required ACLs](/api-docs#acls).
|
2020-03-24 22:08:34 +00:00
|
|
|
|
2020-05-01 20:02:21 +00:00
|
|
|
| Blocking Queries | Consistency Modes | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------------------------- |
|
|
|
|
| `YES` | `all` | `namespace:read-scaling-policy` |
|
2020-03-24 22:08:34 +00:00
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
- `:policy_id` `(string: <required>)` - Specifies the ID of the scaling policy (as returned
|
2020-05-01 20:02:21 +00:00
|
|
|
by the scaling policy list endpoint). This is specified as part of the path.
|
2020-03-24 22:08:34 +00:00
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
2020-05-18 20:53:06 +00:00
|
|
|
```shell-session
|
|
|
|
$ curl \
|
2020-03-24 22:08:34 +00:00
|
|
|
https://localhost:4646/v1/scaling/policy/5e9f9ef2-5223-6d35-bac1-be0f3cb974ad
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-05-01 20:02:21 +00:00
|
|
|
"CreateIndex": 10,
|
|
|
|
"Enabled": true,
|
|
|
|
"ID": "5e9f9ef2-5223-6d35-bac1-be0f3cb974ad",
|
2020-10-23 14:12:42 +00:00
|
|
|
"Type": "horizontal",
|
2020-05-01 20:02:21 +00:00
|
|
|
"Max": 10,
|
|
|
|
"Min": 0,
|
|
|
|
"ModifyIndex": 10,
|
|
|
|
"Policy": {
|
|
|
|
"engage": true,
|
|
|
|
"foo": "bar",
|
|
|
|
"howdy": "doody",
|
|
|
|
"value": 6.0
|
|
|
|
},
|
|
|
|
"Target": {
|
|
|
|
"Group": "cache",
|
|
|
|
"Job": "example",
|
|
|
|
"Namespace": "default"
|
|
|
|
}
|
2020-03-24 22:08:34 +00:00
|
|
|
}
|
|
|
|
```
|