github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/api-docs/recommendations.mdx (about) 1 --- 2 layout: api 3 page_title: Recommendations - HTTP API 4 description: >- 5 The /recommendation endpoints are used to query for and interact with Dynamic 6 Application Sizing recommendations. 7 --- 8 9 # Recommendation HTTP API 10 11 The `/recommendation` endpoints are used to query and interact with Dynamic 12 Application Sizing recommendations. 13 14 <EnterpriseAlert> 15 This API endpoint and functionality only exists in Nomad Enterprise. This is 16 not present in the open source version of Nomad. 17 </EnterpriseAlert> 18 19 ## List Recommendations 20 21 This endpoint lists all the currently available recommendations and provides 22 optional filtering of that list. 23 24 | Method | Path | Produces | 25 | ------ | --------------------- | ------------------ | 26 | `GET` | `/v1/recommendations` | `application/json` | 27 28 The table below shows this endpoint's support for 29 [blocking queries](/api-docs#blocking-queries) and 30 [required ACLs](/api-docs#acls). 31 32 | Blocking Queries | ACL Required | 33 | ---------------- | ----------------------------------------------------------------------------------- | 34 | `YES` | `namespace:read-job` or `namespace:submit-recommendation` or `namespace:submit-job` | 35 36 ### Parameters 37 38 - `group` `(string: "")` - Specifies the task group name to filter within a job. If 39 specified, the `job` parameter must also be specified. 40 41 - `job` `(string: "")` - Specifies the job ID to filter the recommendations list by. 42 43 - `namespace` `(string: "default")` - Specifies the namespace to search. Specifying 44 `*` would return all recommendations across all the authorized namespaces. 45 46 - `task` `(string: "")` - Specifies the task name to filter within a job and task 47 group. If specified, the `job` and `group` query parameters must also be 48 specified. 49 50 ### Sample Request 51 52 ```shell-session 53 $ curl \ 54 https://localhost:4646/v1/recommendations 55 ``` 56 57 ```shell-session 58 $ curl \ 59 https://localhost:4646/v1/recommendations?namespace=* 60 ``` 61 62 ```shell-session 63 $ curl \ 64 https://localhost:4646/v1/recommendations?namespace=*&job=example&group=cache&task=redis 65 ``` 66 67 ### Sample Response 68 69 ```json 70 [ 71 { 72 "ID": "cb80a13d-20d8-fb05-db3f-4ea0fe667b1b", 73 "Region": "global", 74 "Namespace": "default", 75 "JobID": "example", 76 "JobVersion": 0, 77 "Group": "cache", 78 "Task": "redis", 79 "Resource": "MemoryMB", 80 "Value": 10, 81 "Current": 200, 82 "Meta": { 83 "nomad_autoscaler.count.capped": true, 84 "nomad_autoscaler.count.original": 6, 85 "nomad_autoscaler.reason_history": [], 86 "nomad_policy_id": "c355d0ec-7aa1-2604-449d-4ec79c813d2c", 87 "num_evaluated_windows": 1148, 88 "window_size": 300000000000 89 }, 90 "Stats": { 91 "min": 2.6640625, 92 "p99": 6.51171875, 93 "max": 6.515625, 94 "mean": 4.816847859995009 95 }, 96 "EnforceVersion": false, 97 "SubmitTime": 1603372587714807000, 98 "CreateIndex": 5193, 99 "ModifyIndex": 10437 100 }, 101 { 102 "ID": "fdd2b5f1-e6ad-110e-75b9-8f9410e1d8ab", 103 "Region": "global", 104 "Namespace": "default", 105 "JobID": "example", 106 "JobVersion": 0, 107 "Group": "cache", 108 "Task": "redis", 109 "Resource": "CPU", 110 "Value": 57, 111 "Current": 500, 112 "Meta": { 113 "window_size": 300000000000, 114 "nomad_policy_id": "b2c64295-4315-2fdc-6158-a27156808729", 115 "num_evaluated_windows": 1117 116 }, 117 "Stats": { 118 "min": 0, 119 "p99": 50, 120 "max": 63.46186447143555, 121 "mean": 0.3649455045779875 122 }, 123 "EnforceVersion": false, 124 "SubmitTime": 1603372287894356000, 125 "CreateIndex": 5275, 126 "ModifyIndex": 10419 127 } 128 ] 129 ``` 130 131 ## Read Recommendation 132 133 This endpoint reads information about a specific recommendation. 134 135 | Method | Path | Produces | 136 | ------ | --------------------------------------- | ------------------ | 137 | `GET` | `/v1/recommendation/:recommendation_id` | `application/json` | 138 139 The table below shows this endpoint's support for 140 [blocking queries](/api-docs#blocking-queries) and 141 [required ACLs](/api-docs#acls). 142 143 | Blocking Queries | ACL Required | 144 | ---------------- | -------------------- | 145 | `YES` | `namespace:read-job` | 146 147 ### Parameters 148 149 - `:recommendation_id` `(string: <required>)`- Specifies the recommendation ID to 150 query. This is specified as part of the path. 151 152 ### Sample Request 153 154 ```shell-session 155 $ curl \ 156 https://localhost:4646/v1/recommendation/cb80a13d-20d8-fb05-db3f-4ea0fe667b1b 157 ``` 158 159 ### Sample Response 160 161 ```json 162 { 163 "ID": "cb80a13d-20d8-fb05-db3f-4ea0fe667b1b", 164 "Region": "global", 165 "Namespace": "default", 166 "JobID": "example", 167 "JobVersion": 0, 168 "Group": "cache", 169 "Task": "redis", 170 "Resource": "MemoryMB", 171 "Value": 10, 172 "Current": 200, 173 "Meta": { 174 "nomad_autoscaler.count.original": 6, 175 "nomad_autoscaler.reason_history": [], 176 "nomad_policy_id": "c355d0ec-7aa1-2604-449d-4ec79c813d2c", 177 "num_evaluated_windows": 1148, 178 "window_size": 300000000000, 179 "nomad_autoscaler.count.capped": true 180 }, 181 "Stats": { 182 "min": 2.6640625, 183 "p99": 6.51171875, 184 "max": 6.515625, 185 "mean": 4.816847859995009 186 }, 187 "EnforceVersion": false, 188 "SubmitTime": 1603372587714807000, 189 "CreateIndex": 5193, 190 "ModifyIndex": 10437 191 } 192 ``` 193 194 ## Apply and Dismiss Recommendations 195 196 This endpoint is used to apply and dismiss recommendations. 197 198 | Method | Path | Produces | 199 | ------ | --------------------------- | ------------------ | 200 | `POST` | `/v1/recommendations/apply` | `application/json` | 201 202 The table below shows this endpoint's support for 203 [blocking queries](/api-docs#blocking-queries) and 204 [required ACLs](/api-docs#acls). 205 206 | Blocking Queries | ACL Required | 207 | ---------------- | --------------------------------------------------------------------------------- | 208 | `NO` | `namespace:submit-job` with `namespace:sentinel-override` if `PolicyOverride` set | 209 210 ### Parameters 211 212 - `Apply` `(array<string>: nil)` - Specifies a set of recommendation IDs to be 213 applied. This results in Nomad applying the recommendation to the job 214 specification and performing a job register. 215 216 - `Dismiss` `(array<string>: nil)` - Specifies a set of recommendation IDs to be 217 dismissed. This results in Nomad deleting them from the state store. 218 219 - `PolicyOverride` `(bool: false)` - If set, any soft mandatory Sentinel policies 220 will be overridden. This allows a recommendation to be applied when it would be 221 denied by a policy. 222 223 ### Sample Payload 224 225 ```json 226 { 227 "Apply": ["cb80a13d-20d8-fb05-db3f-4ea0fe667b1b"] 228 } 229 ``` 230 231 ### Sample Request 232 233 ```shell-session 234 $ curl \ 235 --request POST \ 236 --data @payload.json \ 237 https://localhost:4646/v1/recommendations/apply 238 ``` 239 240 ### Sample Response 241 242 ```json 243 { 244 "Errors": [], 245 "LastIndex": 0, 246 "RequestTime": 0, 247 "UpdatedJobs": [ 248 { 249 "EvalCreateIndex": 51, 250 "EvalID": "3c91a755-f314-e2fb-500b-437ad08e13ea", 251 "JobID": "example", 252 "JobModifyIndex": 51, 253 "Namespace": "default", 254 "Recommendations": ["cb80a13d-20d8-fb05-db3f-4ea0fe667b1b"], 255 "Warnings": "" 256 } 257 ] 258 } 259 ``` 260 261 ## Create or Update a Recommendation 262 263 This endpoint is used to create or update a recommendation. 264 265 | Method | Path | Produces | 266 | ------ | -------------------- | ------------------ | 267 | `POST` | `/v1/recommendation` | `application/json` | 268 269 The table below shows this endpoint's support for 270 [blocking queries](/api-docs#blocking-queries) and 271 [required ACLs](/api-docs#acls). 272 273 | Blocking Queries | ACL Required | 274 | ---------------- | ----------------------------------------------------------- | 275 | `NO` | `namespace:submit-recommendation` or `namespace:submit-job` | 276 277 ### Parameters 278 279 - `ID` `(string: "")` - The ID of an existing recommendation to update. 280 281 - `Region` `(string: "")`- The Nomad region identifier which contains the job 282 that the recommendation is for. If omitted, this defaults to that of the Nomad 283 agent. 284 285 - `Namespace` `(string: "")`- The namespace within which the target job is running 286 within. If omitted, this defaults to `default`. 287 288 - `JobID` `(string: <required>)`- The job ID which this recommendation is for. 289 290 - `Group` `(string: <required>)`- The task group name within the job which this 291 recommendation is for. 292 293 - `Task` `(string: <required>)`- The task name within the task group which this 294 recommendation is for. 295 296 - `Resource` `(string: <required>)`- The resource that the recommendation is for. 297 Possible values are `CPU` and `MemoryMB`. 298 299 - `Value` `(int: <required>)`- The value recommendation for the resource. This 300 must met the minimum requirements which are `1` for `CPU` and `10` for `MemoryMB`. 301 302 - `Meta` `(map<string|...>: nil)`- JSON block that is persisted as part of the 303 recommendation providing arbitrary, useful information. 304 305 - `Stats` `(map<string|float64>: nil)` - A mapping of statistics that are persisted 306 as part of the recommendation providing insight into the recommendation 307 calculation. 308 309 - `EnforceVersion` `(bool: false)`- Indicates that the recommendation is only valid 310 for the current version of the job. Subsequent job updates will automatically 311 dismiss this recommendation. 312 313 ### Sample Payload 314 315 ```json 316 { 317 "Region": "global", 318 "Namespace": "default", 319 "JobID": "example", 320 "Group": "cache", 321 "Task": "redis", 322 "Resource": "MemoryMB", 323 "Value": 512, 324 "Meta": { 325 "nomad_policy_id": "c355d0ec-7aa1-2604-449d-4ec79c813d2c" 326 }, 327 "Stats": { 328 "min": 2.6640625, 329 "p99": 6.51171875, 330 "max": 6.515625, 331 "mean": 4.816847859995009 332 } 333 } 334 ``` 335 336 ### Sample Request 337 338 ```shell-session 339 $ curl \ 340 --request POST \ 341 --data @payload.json \ 342 https://localhost:4646/v1/recommendation 343 ``` 344 345 ### Sample Response 346 347 ```json 348 { 349 "CreateIndex": 22, 350 "Current": 256, 351 "EnforceVersion": false, 352 "Group": "cache", 353 "ID": "47c97404-918f-8b19-873b-36d802f16f23", 354 "JobID": "example", 355 "JobVersion": 0, 356 "Meta": { 357 "nomad_policy_id": "c355d0ec-7aa1-2604-449d-4ec79c813d2c" 358 }, 359 "ModifyIndex": 25, 360 "Namespace": "default", 361 "Region": "global", 362 "Resource": "MemoryMB", 363 "Stats": { 364 "mean": 4.816847859995009, 365 "min": 2.6640625, 366 "p99": 6.51171875, 367 "max": 6.515625 368 }, 369 "SubmitTime": 1603444202372926000, 370 "Task": "redis", 371 "Value": 512 372 } 373 ```