github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/docs/autoscaling/agent.mdx (about) 1 --- 2 layout: docs 3 page_title: Agent 4 sidebar_title: Agent 5 description: The Nomad Autoscaler is a long lived process which coordinates scaling activates. 6 --- 7 8 # Nomad Autoscaler Agent 9 10 The Nomad Autoscaler agent has a variety of parameters that can be specified 11 via configuration files or command-line flags. Configuration files are written 12 in [HCL][hcl_v2]. The Nomad Autoscaler can read and combine parameters from 13 multiple configuration files or directories to configure the agent. 14 15 ## Nomad Namespaces 16 17 The Nomad Autoscaler currently has limited support for 18 [Nomad Namespaces][nomad_namespaces]. The `nomad` configuration below supports 19 specifying a namespace; if configured with a namespace, the Autoscaler will 20 retrieve scaling policies and perform autoscaling only for jobs in that 21 namespace. A future version will include support for multiple namespaces. 22 23 ## Nomad ACLs 24 25 The Nomad Autoscaler can be configured to interact with an ACL-enabled Nomad 26 cluster. Nomad 0.11 includes the `scale` ACL policy disposition specifically for 27 supporting the operations of the Nomad Autoscaler. Therefore, the 28 following policy is sufficient for creating an ACL token that can be used by 29 the autoscaler for fetching scaling policies and scaling jobs: 30 31 ```hcl 32 namespace "default" { 33 policy = "scale" 34 } 35 ``` 36 37 Other APM and target plugins may require additional ACLs; see the plugin documentation for more information. 38 39 ## Load Order and Merging 40 41 The Nomad Autoscaler agent supports multiple configuration files, which can be 42 provided using the [`-config`][autoscaler_cli_config] CLI flag. The flag can 43 accept either a file or folder. In the case of a folder, any `.hcl` and `.json` 44 files in the folder will be loaded and merged in lexicographical order. Directories 45 are not loaded recursively. 46 47 For example: 48 49 ```shell-session 50 $ nomad-autoscaler agent -config=autoscaler.conf -config=/etc/nomad-autoscaler -config=extra.json 51 ``` 52 53 This will load configuration from `autoscaler.conf`, from `.hcl` and `.json` files 54 under `/etc/nomad-autoscaler`, and finally from `extra.json`. As each file is 55 processed, its contents are merged into the existing configuration. When merging, 56 any non-empty values from the latest config file will append or replace 57 parameters in the current configuration. An empty value means `""` for strings, 58 `0` for integer or float values, and `false` for booleans. 59 60 ## SIGHUP Reload 61 62 The Nomad Autoscaler agent supports handling the `SIGHUP` signal for reloading without the need for 63 restarting the agent. When sending a `SIGHUP` signal to the agent process, the agent will perform the 64 following actions. 65 66 - reload the contents of the scaling policy directory as defined by the [`-policy-dir`][autoscaler_cli_policy_dir] 67 parameter. 68 69 - reconfigure the Nomad clients used to fetch policies and execute scaling 70 actions with the values defined in the [`nomad`](#nomad-block) block. 71 72 - stop plugins that are no longer present in the configuration file. 73 74 - start plugins that were not previously present in the configuration file. 75 76 - reconfigure the remaining plugins with the configuration defined in their 77 `config` parameter. 78 79 ## General Parameters 80 81 - `log_level` `(string: "INFO")` - Specify the verbosity level of Nomad 82 Autoscaler's logs. Valid values include DEBUG, INFO, and WARN, in decreasing 83 order of verbosity. 84 85 - `log_json` `(bool: false)` - Output logs in a JSON format. 86 87 - `plugin_dir` `(string: "./plugins")` - The plugin directory is used to 88 discover Nomad Autoscaler plugins. 89 90 ## `http` Block 91 92 The `http` block configures the Nomad Autoscaler's HTTP endpoint. 93 94 ```hcl 95 http { 96 bind_address = "10.0.0.10" 97 bind_port = 9999 98 } 99 ``` 100 101 ### `http` Parameters 102 103 - `bind_address` `(string: "127.0.0.1")` - The HTTP address that the server will 104 bind to. 105 106 - `bind_port` `(int: 8080)` - The port that the server will bind to. 107 108 ## `nomad` Block 109 110 The `nomad` block configures the Nomad Autoscaler's Nomad client. 111 112 ```hcl 113 nomad { 114 address = "http://my-nomad.systems:4646" 115 region = "esp-vlc-1" 116 } 117 ``` 118 119 ### `nomad` Parameters 120 121 - `address` `(string: "http://127.0.0.1:4646")` - The address of the Nomad server 122 in the form of `protocol://addr:port`. 123 124 - `region` `(string: "global")` - The region of the Nomad servers to connect with. 125 126 - `namespace` `(string: "")` - The target namespace for queries and actions bound 127 to a namespace. 128 129 - `token` `(string: "")` - The SecretID of an ACL token to use to authenticate 130 API requests with. 131 132 - `http_auth` `(string: "")` - The authentication information to use when connecting 133 to a Nomad API which is using HTTP authentication. 134 135 - `ca_cert` `(string: "")` - Path to a PEM encoded CA cert file to use to verify 136 the Nomad server SSL certificate. 137 138 - `ca_path` `(string: "")` - Path to a directory of PEM encoded CA cert files to 139 verify the Nomad server SSL certificate. 140 141 - `client_cert` `(string: "")` - Path to a PEM encoded client certificate for TLS 142 authentication to the Nomad server. 143 144 - `client_key` `(string: "")` - Path to an unencrypted PEM encoded private key 145 matching the client certificate. 146 147 - `tls_server_name` `(string: "")` - The server name to use as the SNI host when 148 connecting via TLS. 149 150 - `skip_verify` `(bool: false)` - Do not verify TLS certificates. This is strongly 151 discouraged. 152 153 ## `policy` Block 154 155 The `policy` block configures the Nomad Autoscaler's policy handling. 156 157 ```hcl 158 policy { 159 dir = "/opt/nomad-autoscaler/policies" 160 default_cooldown = "2m" 161 } 162 ``` 163 164 ### `policy` Parameters 165 166 - `dir` `(string: "")` - The path to a directory used to load scaling policies. 167 168 - `default_cooldown` `(string: "5m")` - The default cooldown that will be applied 169 to all scaling policies which do not specify a cooldown period. 170 171 - `default_evaluation_interval` `(string: "10s")` - The default evaluation interval 172 that will be applied to all scaling policies which do not specify an evaluation 173 interval. 174 175 ## `policy_eval` Block 176 177 The `policy_eval` block holds the configuration related to the policy evaluation 178 process. 179 180 ```hcl 181 policy_eval { 182 ack_timeout = "10m" 183 delivery_limit = 4 184 185 workers = { 186 cluster = 2 187 horizontal = 2 188 } 189 } 190 ``` 191 192 ### `policy_eval` Parameters 193 194 - `ack_timeout` `(string: "5m")` - The time limit that an eval must be ACK'd 195 before being considered NACK'd. 196 197 - `delivery_limit` `(int: 1)` - The maximum number of times a policy evaluation 198 can be dequeued from the broker. 199 200 - `workers` `(map<string|int>: [cluster:10,horizontal:10])` - The number of workers 201 to initialize for each queue. Nomad Autoscaler supports `cluster` and `horizontal` 202 map keys. Nomad Autoscaler Enterprise supports additional `vertical_mem` and 203 `vertical_cpu` entries. 204 205 ## `telemetry` Block 206 207 The `telemetry` block configures the Nomad Autoscaler's publication of metrics 208 and telemetry to third-party systems. 209 210 ```hcl 211 telemetry { 212 disable_hostname = true 213 } 214 ``` 215 216 ### `telemetry` Parameters 217 218 Due to the number of provider-specific parameters to the `telemetry` block, parameters 219 in this section are grouped by the telemetry provider. 220 221 ### Common 222 223 The following options are available on all telemetry configurations. 224 225 - `disable_hostname` `(bool: false)` - Specifies if gauge values should be 226 prefixed with the local hostname. 227 228 - `enable_hostname_label` `(bool: false)` - Enable adding hostname to metric 229 labels. 230 231 - `collection_interval` `(duration: "1s")` - Specifies the time interval at which 232 the Nomad agent collects telemetry data. 233 234 ### `statsite` 235 236 These `telemetry` parameters apply to [Statsite][statsite]. 237 238 - `statsite_address` `(string: "")` - Specifies the address of a statsite server 239 to forward metrics data to. 240 241 ```hcl 242 telemetry { 243 statsite_address = "statsite.company.local:8125" 244 } 245 ``` 246 247 ### `statsd` 248 249 These `telemetry` parameters apply to [StatsD][statsd]. 250 251 - `statsd_address` `(string: "")` - Specifies the address of a statsd server to 252 forward metrics to. 253 254 ```hcl 255 telemetry { 256 statsd_address = "statsd.company.local:8125" 257 } 258 ``` 259 260 ### `datadog` 261 262 These `telemetry` parameters apply to [DataDog statsd][datadog_statsd]. 263 264 - `dogstatsd_address` `(string: "")` - Specifies the address of a DataDog statsd 265 server to forward metrics to. 266 267 - `dogstatsd_tags` `(list: [])` - Specifies a list of global tags that will be 268 added to all telemetry packets sent to DogStatsD. It is a list of strings, 269 where each string looks like `my_tag_name:my_tag_value`. 270 271 ```hcl 272 telemetry { 273 dogstatsd_address = "dogstatsd.company.local:8125" 274 dogstatsd_tags = ["my_tag_name:my_tag_value"] 275 } 276 ``` 277 278 ### `prometheus` 279 280 These `telemetry` parameters apply to [Prometheus][prometheus]. 281 282 - `prometheus_metrics` `(bool: false)` - Specifies whether the agent should 283 make Prometheus formatted metrics available at `/v1/metrics?format=prometheus`. 284 285 - `prometheus_retention_time` `(string: "24h")` - Specifies the amount of time that Prometheus 286 metrics are retained in memory. 287 288 ### `circonus` 289 290 These `telemetry` parameters apply to [Circonus][circonus]. 291 292 - `circonus_api_token` `(string: "")` - Specifies a valid Circonus API Token 293 used to create/manage check. If provided, metric management is enabled. 294 295 - `circonus_api_app` `(string: "nomad-autoscaler")` - Specifies a valid app name 296 associated with the API token. 297 298 - `circonus_api_url` `(string: "https://api.circonus.com/v2")` - Specifies the 299 base URL to use for contacting the Circonus API. 300 301 - `circonus_submission_interval` `(string: "10s")` - Specifies the interval at 302 which metrics are submitted to Circonus. 303 304 - `circonus_submission_url` `(string: "")` - Specifies the 305 `check.config.submission_url` field, of a Check API object, from a previously 306 created HTTPTRAP check. 307 308 - `circonus_check_id` `(string: "")` - Specifies the Check ID (**not check 309 bundle**) from a previously created HTTPTrap check. The numeric portion of the 310 `check._cid` field in the Check API object. 311 312 - `circonus_check_force_metric_activation` `(bool: false)` - Specifies if force 313 activation of metrics which already exist and are not currently active. If 314 check management is enabled, the default behavior is to add new metrics as 315 they are encountered. If the metric already exists in the check, it will 316 not be activated. This setting overrides that behavior. 317 318 - `circonus_check_instance_id` `(string: "<hostname>:<application>")` - Serves 319 to uniquely identify the metrics coming from this _instance_. It can be used 320 to maintain metric continuity with transient or ephemeral instances as they 321 move around within an infrastructure. By default, this is set to 322 "hostname:application name" (e.g. `host123:nomad-autoscaler`). 323 324 - `circonus_check_search_tag` `(string: <service>:<application>)` - Specifies a 325 special tag which, when coupled with the instance id, helps to narrow down the 326 search results when neither a Submission URL or Check ID is provided. By 327 default, this is set to "service:app" (e.g. `service:nomad-autoscaler`). 328 329 - `circonus_check_display_name` `(string: "")` - Specifies a name to give a 330 check when it is created. This name is displayed in the Circonus UI Checks 331 list. 332 333 - `circonus_check_tags` `(string: "")` - Comma separated list of additional 334 tags to add to a check when it is created. 335 336 - `circonus_broker_id` `(string: "")` - Specifies the ID of a specific Circonus 337 Broker to use when creating a new check. The numeric portion of `broker._cid` 338 field in a Broker API object. If metric management is enabled and neither a 339 Submission URL nor Check ID is provided, an attempt will be made to search for 340 an existing check using Instance ID and Search Tag. If one is not found, a new 341 HTTPTrap check will be created. By default, this is a random 342 Enterprise Broker is selected, or, the default Circonus Public Broker. 343 344 - `circonus_broker_select_tag` `(string: "")` - Specifies a special tag which 345 will be used to select a Circonus Broker when a Broker ID is not provided. The 346 best use of this is to as a hint for which broker should be used based on 347 _where_ this particular instance is running (e.g., a specific geographic location or 348 datacenter, dc:sfo). 349 350 ## `apm` Block 351 352 The `apm` block is used to configure application performance metric (APM) plugins. 353 354 ```hcl 355 apm "example-apm-plugin" { 356 driver = "example-apm-plugin" 357 args = ["-my-flag"] 358 359 config = { 360 address = "http://127.0.0.1:9090" 361 } 362 } 363 ``` 364 365 ### `apm` Parameters 366 367 - `args` `(array<string>: [])` - Specifies a set of arguments to pass to the 368 plugin binary when it is executed. 369 370 - `driver` `(string: "")` - The plugin's executable name relative to to the 371 plugin_dir. If the plugin has a suffix, such as .exe, this should be omitted. 372 373 - `config` `(map<string><string>: nil)` - Specifies configuration values for 374 the plugin either as HCL or JSON. The accepted values are plugin specific. 375 Please refer to the individual plugin's documentation. 376 377 ## `target` Block 378 379 The `target` block is used to configure scaling target plugins. 380 381 ```hcl 382 target "example-target-plugin" { 383 driver = "example-target-plugin" 384 args = ["-my-flag"] 385 386 config = { 387 region = "esp-vlc-1" 388 } 389 } 390 ``` 391 392 ### `target` Parameters 393 394 - `args` `(array<string>: [])` - Specifies a set of arguments to pass to the 395 plugin binary when it is executed. 396 397 - `driver` `(string: "")` - The plugin's executable name relative to to the 398 plugin_dir. If the plugin has a suffix, such as .exe, this should be omitted. 399 400 - `config` `(map<string><string>: nil)` - Specifies configuration values for 401 the plugin either as HCL or JSON. The accepted values are plugin specific. 402 Please refer to the individual plugin's documentation. 403 404 ## `strategy` Block 405 406 The `strategy` block is used to configure scaling strategy plugins. 407 408 ```hcl 409 strategy "example-strategy-plugin" { 410 driver = "example-strategy-plugin" 411 args = ["-my-flag"] 412 413 config = { 414 algorithm = "complex" 415 } 416 } 417 ``` 418 419 ### `strategy` Parameters 420 421 - `args` `(array<string>: [])` - Specifies a set of arguments to pass to the 422 plugin binary when it is executed. 423 424 - `driver` `(string: "")` - The plugin's executable name relative to to the 425 plugin_dir. If the plugin has a suffix, such as .exe, this should be omitted. 426 427 - `config` `(map<string><string>: nil)` - Specifies configuration values for 428 the plugin either as HCL or JSON. The accepted values are plugin specific. 429 Please refer to the individual plugin's documentation. 430 431 [hcl_v2]: https://github.com/hashicorp/hcl/tree/hcl2 432 [nomad_namespaces]: https://learn.hashicorp.com/tutorials/nomad/namespaces 433 [nomad_acls]: https://learn.hashicorp.com/collections/nomad/access-control 434 [autoscaler_cli_config]: /docs/autoscaling/cli#config 435 [autoscaler_cli_policy_dir]: /docs/autoscaling/cli#policy-dir 436 [statsite]: https://github.com/armon/statsite 437 [statsd]: https://github.com/etsy/statsd 438 [datadog_statsd]: https://github.com/DataDog/datadog-agent 439 [prometheus]: https://prometheus.io 440 [circonus]: http://circonus.com/