github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/website/source/api/agent.html.md (about)

     1  ---
     2  layout: api
     3  page_title: Agent - HTTP API
     4  sidebar_current: api-agent
     5  description: |-
     6    The /agent endpoints interact with the local Nomad agent to interact with
     7    members and servers.
     8  ---
     9  
    10  # Agent HTTP API
    11  
    12  The `/agent` endpoints are used to interact with the local Nomad agent.
    13  
    14  ## List Members
    15  
    16  This endpoint queries the agent for the known peers in the gossip pool. This
    17  endpoint is only applicable to servers. Due to the nature of gossip, this is
    18  eventually consistent.
    19  
    20  | Method | Path                         | Produces                   |
    21  | ------ | ---------------------------- | -------------------------- |
    22  | `GET`  | `/agent/members`             | `application/json`         |
    23  
    24  The table below shows this endpoint's support for
    25  [blocking queries](/api/index.html#blocking-queries) and
    26  [required ACLs](/api/index.html#acls).
    27  
    28  | Blocking Queries | ACL Required |
    29  | ---------------- | ------------ |
    30  | `NO`             | `none`       |
    31  
    32  ### Sample Request
    33  
    34  ```text
    35  $ curl \
    36      https://nomad.rocks/v1/agent/members
    37  ```
    38  
    39  ### Sample Response
    40  
    41  ```json
    42  {
    43    "ServerName": "bacon-mac",
    44    "ServerRegion": "global",
    45    "ServerDC": "dc1",
    46    "Members": [
    47      {
    48        "Name": "bacon-mac.global",
    49        "Addr": "127.0.0.1",
    50        "Port": 4648,
    51        "Tags": {
    52          "mvn": "1",
    53          "build": "0.5.5dev",
    54          "port": "4647",
    55          "bootstrap": "1",
    56          "role": "nomad",
    57          "region": "global",
    58          "dc": "dc1",
    59          "vsn": "1"
    60        },
    61        "Status": "alive",
    62        "ProtocolMin": 1,
    63        "ProtocolMax": 5,
    64        "ProtocolCur": 2,
    65        "DelegateMin": 2,
    66        "DelegateMax": 4,
    67        "DelegateCur": 4
    68      }
    69    ]
    70  }
    71  ```
    72  
    73  ## List Servers
    74  
    75  This endpoint lists the known server nodes. The `servers` endpoint is used to
    76  query an agent in client mode for its list of known servers. Client nodes
    77  register themselves with these server addresses so that they may dequeue work.
    78  The servers endpoint can be used to keep this configuration up to date if there
    79  are changes in the cluster.
    80  
    81  | Method | Path                         | Produces                   |
    82  | ------ | ---------------------------- | -------------------------- |
    83  | `GET`  | `/agent/servers`             | `application/json`         |
    84  
    85  The table below shows this endpoint's support for
    86  [blocking queries](/api/index.html#blocking-queries) and
    87  [required ACLs](/api/index.html#acls).
    88  
    89  | Blocking Queries | ACL Required |
    90  | ---------------- | ------------ |
    91  | `NO`             | `none`       |
    92  
    93  ### Sample Request
    94  
    95  ```text
    96  $ curl \
    97      https://nomad.rocks/v1/agent/servers
    98  ```
    99  
   100  ### Sample Response
   101  
   102  ```json
   103  [
   104    "127.0.0.1:4647"
   105  ]
   106  ```
   107  
   108  ## Update Servers
   109  
   110  This endpoint updates the list of known servers to the provided list. This
   111  **replaces** all previous server addresses with the new list.
   112  
   113  | Method | Path                         | Produces                   |
   114  | ------ | ---------------------------- | -------------------------- |
   115  | `POST` | `/agent/servers`             | `(empty body)`             |
   116  
   117  The table below shows this endpoint's support for
   118  [blocking queries](/api/index.html#blocking-queries) and
   119  [required ACLs](/api/index.html#acls).
   120  
   121  | Blocking Queries | ACL Required |
   122  | ---------------- | ------------ |
   123  | `NO`             | `none`       |
   124  
   125  ### Parameters
   126  
   127  - `address` `(string: <required>)` - Specifies the list of addresses in the
   128    format `ip:port`. This is specified as a query string!
   129  
   130  ### Sample Request
   131  
   132  ```text
   133  $ curl \
   134      --request POST \
   135      https://nomad.rocks/v1/agent/servers?address=1.2.3.4:4647&addres=5.6.7.8:4647
   136  ```
   137  
   138  ## Query Self
   139  
   140  This endpoint queries the state of the target agent (self).
   141  
   142  | Method | Path                         | Produces                   |
   143  | ------ | ---------------------------- | -------------------------- |
   144  | `POST` | `/agent/self`                | `application/json`         |
   145  
   146  The table below shows this endpoint's support for
   147  [blocking queries](/api/index.html#blocking-queries) and
   148  [required ACLs](/api/index.html#acls).
   149  
   150  | Blocking Queries | Consistency Modes | ACL Required |
   151  | ---------------- | ----------------- | ------------ |
   152  | `NO`             | `none`            | `none`       |
   153  
   154  ### Sample Request
   155  
   156  ```text
   157  $ curl \
   158      https://nomad.rocks/v1/agent/self
   159  ```
   160  
   161  ### Sample Response
   162  
   163  ```json
   164  {
   165    "config": {
   166      "Addresses": {
   167        "HTTP": "127.0.0.1",
   168        "RPC": "127.0.0.1",
   169        "Serf": "127.0.0.1"
   170      },
   171      "AdvertiseAddrs": {
   172        "HTTP": "127.0.0.1:4646",
   173        "RPC": "127.0.0.1:4647",
   174        "Serf": "127.0.0.1:4648"
   175      },
   176      "BindAddr": "127.0.0.1",
   177      "Client": {
   178        "AllocDir": "",
   179        "ChrootEnv": {},
   180        "ClientMaxPort": 14512,
   181        "ClientMinPort": 14000,
   182        "Enabled": true,
   183        "GCDiskUsageThreshold": 99,
   184        "GCInodeUsageThreshold": 99,
   185        "GCInterval": 600000000000,
   186        "MaxKillTimeout": "30s",
   187        "Meta": {},
   188        "NetworkInterface": "lo0",
   189        "NetworkSpeed": 0,
   190        "NodeClass": "",
   191        "Options": {
   192          "driver.docker.volumes": "true"
   193        },
   194        "Reserved": {
   195          "CPU": 0,
   196          "DiskMB": 0,
   197          "IOPS": 0,
   198          "MemoryMB": 0,
   199          "ParsedReservedPorts": null,
   200          "ReservedPorts": ""
   201        },
   202        "Servers": null,
   203        "StateDir": ""
   204      },
   205      "Consul": {
   206        "Addr": "",
   207        "Auth": "",
   208        "AutoAdvertise": true,
   209        "CAFile": "",
   210        "CertFile": "",
   211        "ChecksUseAdvertise": false,
   212        "ClientAutoJoin": true,
   213        "ClientServiceName": "nomad-client",
   214        "EnableSSL": false,
   215        "KeyFile": "",
   216        "ServerAutoJoin": true,
   217        "ServerServiceName": "nomad",
   218        "Timeout": 5000000000,
   219        "Token": "",
   220        "VerifySSL": false
   221      },
   222      "DataDir": "",
   223      "Datacenter": "dc1",
   224      "DevMode": true,
   225      "DisableAnonymousSignature": true,
   226      "DisableUpdateCheck": false,
   227      "EnableDebug": true,
   228      "EnableSyslog": false,
   229      "Files": null,
   230      "HTTPAPIResponseHeaders": {},
   231      "LeaveOnInt": false,
   232      "LeaveOnTerm": false,
   233      "LogLevel": "DEBUG",
   234      "NodeName": "",
   235      "Ports": {
   236        "HTTP": 4646,
   237        "RPC": 4647,
   238        "Serf": 4648
   239      },
   240      "Region": "global",
   241      "Revision": "f551dcb83e3ac144c9dbb90583b6e82d234662e9",
   242      "Server": {
   243        "BootstrapExpect": 0,
   244        "DataDir": "",
   245        "Enabled": true,
   246        "EnabledSchedulers": null,
   247        "HeartbeatGrace": "",
   248        "NodeGCThreshold": "",
   249        "NumSchedulers": 0,
   250        "ProtocolVersion": 0,
   251        "RejoinAfterLeave": false,
   252        "RetryInterval": "30s",
   253        "RetryJoin": [],
   254        "RetryMaxAttempts": 0,
   255        "StartJoin": []
   256      },
   257      "SyslogFacility": "LOCAL0",
   258      "TLSConfig": {
   259        "CAFile": "",
   260        "CertFile": "",
   261        "EnableHTTP": false,
   262        "EnableRPC": false,
   263        "KeyFile": "",
   264        "VerifyServerHostname": false
   265      },
   266      "Telemetry": {
   267        "CirconusAPIApp": "",
   268        "CirconusAPIToken": "",
   269        "CirconusAPIURL": "",
   270        "CirconusBrokerID": "",
   271        "CirconusBrokerSelectTag": "",
   272        "CirconusCheckDisplayName": "",
   273        "CirconusCheckForceMetricActivation": "",
   274        "CirconusCheckID": "",
   275        "CirconusCheckInstanceID": "",
   276        "CirconusCheckSearchTag": "",
   277        "CirconusCheckSubmissionURL": "",
   278        "CirconusCheckTags": "",
   279        "CirconusSubmissionInterval": "",
   280        "CollectionInterval": "1s",
   281        "DataDogAddr": "",
   282        "DisableHostname": false,
   283        "PublishAllocationMetrics": false,
   284        "PublishNodeMetrics": false,
   285        "StatsdAddr": "",
   286        "StatsiteAddr": "",
   287        "UseNodeName": false
   288      },
   289      "Vault": {
   290        "Addr": "https://vault.service.consul:8200",
   291        "AllowUnauthenticated": true,
   292        "ConnectionRetryIntv": 30000000000,
   293        "Enabled": null,
   294        "Role": "",
   295        "TLSCaFile": "",
   296        "TLSCaPath": "",
   297        "TLSCertFile": "",
   298        "TLSKeyFile": "",
   299        "TLSServerName": "",
   300        "TLSSkipVerify": null,
   301        "TaskTokenTTL": "",
   302        "Token": "root"
   303      },
   304      "Version": "0.5.5",
   305      "VersionPrerelease": "dev"
   306    },
   307    "member": {
   308      "Addr": "127.0.0.1",
   309      "DelegateCur": 4,
   310      "DelegateMax": 4,
   311      "DelegateMin": 2,
   312      "Name": "bacon-mac.global",
   313      "Port": 4648,
   314      "ProtocolCur": 2,
   315      "ProtocolMax": 5,
   316      "ProtocolMin": 1,
   317      "Status": "alive",
   318      "Tags": {
   319        "role": "nomad",
   320        "region": "global",
   321        "dc": "dc1",
   322        "vsn": "1",
   323        "mvn": "1",
   324        "build": "0.5.5dev",
   325        "port": "4647",
   326        "bootstrap": "1"
   327      }
   328    },
   329    "stats": {
   330      "runtime": {
   331        "cpu_count": "8",
   332        "kernel.name": "darwin",
   333        "arch": "amd64",
   334        "version": "go1.8",
   335        "max_procs": "7",
   336        "goroutines": "79"
   337      },
   338      "nomad": {
   339        "server": "true",
   340        "leader": "true",
   341        "leader_addr": "127.0.0.1:4647",
   342        "bootstrap": "false",
   343        "known_regions": "1"
   344      },
   345      "raft": {
   346        "num_peers": "0",
   347        "fsm_pending": "0",
   348        "last_snapshot_index": "0",
   349        "last_log_term": "2",
   350        "commit_index": "144",
   351        "term": "2",
   352        "last_log_index": "144",
   353        "protocol_version_max": "3",
   354        "snapshot_version_max": "1",
   355        "latest_configuration_index": "1",
   356        "latest_configuration": "[{Suffrage:Voter ID:127.0.0.1:4647 Address:127.0.0.1:4647}]",
   357        "last_contact": "never",
   358        "applied_index": "144",
   359        "protocol_version": "1",
   360        "protocol_version_min": "0",
   361        "snapshot_version_min": "0",
   362        "state": "Leader",
   363        "last_snapshot_term": "0"
   364      },
   365      "client": {
   366        "heartbeat_ttl": "17.79568937s",
   367        "node_id": "fb2170a8-257d-3c64-b14d-bc06cc94e34c",
   368        "known_servers": "127.0.0.1:4647",
   369        "num_allocations": "0",
   370        "last_heartbeat": "10.107423052s"
   371      },
   372      "serf": {
   373        "event_time": "1",
   374        "event_queue": "0",
   375        "encrypted": "false",
   376        "member_time": "1",
   377        "query_time": "1",
   378        "intent_queue": "0",
   379        "query_queue": "0",
   380        "members": "1",
   381        "failed": "0",
   382        "left": "0",
   383        "health_score": "0"
   384      }
   385    }
   386  }
   387  ```
   388  
   389  ## Join Agent
   390  
   391  This endpoint introduces a new member to the gossip pool. This endpoint is only
   392  eligible for servers.
   393  
   394  | Method | Path                         | Produces                   |
   395  | ------ | ---------------------------- | -------------------------- |
   396  | `POST` | `/agent/join`                | `application/json`         |
   397  
   398  The table below shows this endpoint's support for
   399  [blocking queries](/api/index.html#blocking-queries) and
   400  [required ACLs](/api/index.html#acls).
   401  
   402  | Blocking Queries | ACL Required |
   403  | ---------------- | ------------ |
   404  | `NO`             | `none`       |
   405  
   406  ### Parameters
   407  
   408  - `address` `(string: <required>)` - Specifies the address to join in the
   409    `ip:port` format. This is provided as a query parameter and may be specified
   410    multiple times to join multiple servers.
   411  
   412  ### Sample Request
   413  
   414  ```text
   415  $ curl \
   416      --request POST \
   417      https://nomad.rocks/v1/agent/join?address=1.2.3.4&address=5.6.7.8
   418  ```
   419  
   420  ### Sample Response
   421  
   422  ```json
   423  {
   424    "error": "",
   425    "num_joined": 2
   426  }
   427  ```
   428  
   429  ## Force Leave Agent
   430  
   431  This endpoint forces a member of the gossip pool from the `"failed"` state to
   432  the `"left"` state. This allows the consensus protocol to remove the peer and
   433  stop attempting replication. This is only applicable for servers.
   434  
   435  | Method | Path                         | Produces                   |
   436  | ------ | ---------------------------- | -------------------------- |
   437  | `POST` | `/agent/force-leave`         | `application/json`         |
   438  
   439  The table below shows this endpoint's support for
   440  [blocking queries](/api/index.html#blocking-queries) and
   441  [required ACLs](/api/index.html#acls).
   442  
   443  | Blocking Queries | ACL Required |
   444  | ---------------- | ------------ |
   445  | `NO`             | `none`       |
   446  
   447  ### Parameters
   448  
   449  - `node` `(string: <required>)` - Specifies the name of the node to force leave.
   450  
   451  ### Sample Request
   452  
   453  ```text
   454  $ curl \
   455      --request POST \
   456      https://nomad.rocks/v1/agent/force-leave?node=client-ab2e23dc
   457  ```