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

     1  ---
     2  layout: api
     3  page_title: Events - HTTP API
     4  sidebar_title: Events
     5  description: |-
     6    The /event endpoints are used to query for and stream Nomad events.
     7  ---
     8  
     9  # Events HTTP API
    10  
    11  The `/event/stream` endpoint is used to stream events generated by Nomad.
    12  
    13  ## Event Stream
    14  
    15  This endpoint streams a servers backlog of events as well as new events as they occur.
    16  The stream will be kept alive until the connection is closed.
    17  
    18  | Method | Path               | Produces           |
    19  | ------ | ------------------ | ------------------ |
    20  | `GET`  | `/v1/event/stream` | `application/json` |
    21  
    22  The table below shows this endpoint's [required ACLs](/api-docs#acls). Due to
    23  the nature of this endpoint individual topics require specific policies.
    24  
    25  Note that if you do not include a `topic` parameter all topics will be included
    26  by default, requiring a management token.
    27  
    28  | Topic        | ACL Required         |
    29  | ------------ | -------------------- |
    30  | `*`          | `management`         |
    31  | `ACLToken`   | `management`         |
    32  | `ACLPolicy`  | `management`         |
    33  | `Job`        | `namespace:read-job` |
    34  | `Allocation` | `namespace:read-job` |
    35  | `Deployment` | `namespace:read-job` |
    36  | `Evaluation` | `namespace:read-job` |
    37  | `Node`       | `node:read`          |
    38  
    39  ### Parameters
    40  
    41  - `index` `(int: 0)` - Specifies the index to start streaming events from. If
    42    the requested index is no longer in the buffer the stream will start at the
    43    next available index.
    44  
    45  - `namespace` `(string: "default")` - Specifies the target namespace to filter
    46    on. Specifying `*` includes all namespaces for event types that support
    47    namespaces.
    48  
    49  - `topic` `(topic:filter_key: "*:*")` - Specifies a topic to subscribe to and
    50    filter on. The default is to subscribe to all topics. Multiple topics may be
    51    specified by passing multiple `topic` parameters. A valid topic parameter
    52    includes a `topic` type and an optional `filter_key` separated by a colon
    53    `:`. As an example `?topic=Deployment:redis` would subscribe to all
    54    `Deployment` events for a job redis. an additional topic
    55    `&topic=Deployment:web` would include deployment events for redis and web. To
    56    only subscribe to `Node` events a topic parameter of `?topic=Node` without a
    57    separator value would be used. `?topic=Node:*` is also valid.
    58  
    59  ### Event Topics
    60  
    61  | Topic      | Output                          |
    62  | ---------- | ------------------------------- |
    63  | ACLToken   | ACLToken                        |
    64  | ACLPolicy  | ACLPolicy                       |
    65  | Allocation | Allocation (no job information) |
    66  | Job        | Job                             |
    67  | Evaluation | Evaluation                      |
    68  | Deployment | Deployment                      |
    69  | Node       | Node                            |
    70  | NodeDrain  | Node                            |
    71  
    72  ### Event Types
    73  
    74  | Type                          |
    75  | ----------------------------- |
    76  | ACLTokenUpserted              |
    77  | ACLTokenDeleted               |
    78  | ACLPolicyUpserted             |
    79  | ACLPolicyDeleted              |
    80  | AllocationCreated             |
    81  | AllocationUpdated             |
    82  | AllocationUpdateDesiredStatus |
    83  | DeploymentStatusUpdate        |
    84  | DeploymentPromotion           |
    85  | DeploymentAllocHealth         |
    86  | EvaluationUpdated             |
    87  | JobRegistered                 |
    88  | JobDeregistered               |
    89  | JobBatchDeregistered          |
    90  | NodeRegistration              |
    91  | NodeDeregistration            |
    92  | NodeEligibility               |
    93  | NodeDrain                     |
    94  | NodeEvent                     |
    95  | PlanResult                    |
    96  
    97  ### Sample Request
    98  
    99  ```shell-session
   100  # Subscribe to all events and topics
   101  $ curl -s -v -N http://127.0.0.1:4646/v1/event/stream
   102  ```
   103  
   104  ```shell-session
   105  # Start at index 100 and subscribe to all Evaluation events
   106  $ curl -s -v -N http://127.0.0.1:4646/v1/event/stream?index=100&topic=Evaluation
   107  ```
   108  
   109  ```shell-session
   110  $ curl -G -s -v -N \
   111  --data-urlencode "topic=Node:ccc4ce56-7f0a-4124-b8b1-a4015aa82c40" \
   112  --data-urlencode "topic=Deployment" \
   113  --data-urlencode "topic=Job:web" \
   114  http://127.0.0.1:4646/v1/event/stream
   115  ```
   116  
   117  ### Sample Response
   118  
   119  ```json
   120  {
   121    "Index": 7,
   122    "Events": [
   123      {
   124        "Topic": "Node",
   125        "Type": "NodeRegistration",
   126        "Key": "ccc4ce56-7f0a-4124-b8b1-a4015aa82c40",
   127        "Namespace": "",
   128        "FilterKeys": null,
   129        "Index": 7,
   130        "Payload": {
   131          "Node": {
   132            "ID": "ccc4ce56-7f0a-4124-b8b1-a4015aa82c40",
   133            "Datacenter": "dc1",
   134            "Name": "nomad-4",
   135            "HTTPAddr": "127.0.0.1:4646",
   136            "TLSEnabled": false,
   137            "Attributes": {
   138              "cpu.arch": "amd64",
   139              "cpu.frequency": "4200",
   140              "cpu.modelname": "Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",
   141              "cpu.numcores": "8",
   142              "cpu.totalcompute": "33600",
   143              "driver.docker": "1",
   144              "driver.docker.bridge_ip": "172.17.0.1",
   145              "driver.docker.os_type": "linux",
   146              "driver.docker.runtimes": "runc",
   147              "driver.docker.version": "19.03.13",
   148              "driver.mock": "true",
   149              "driver.mock_driver": "1",
   150              "driver.raw_exec": "1",
   151              "kernel.name": "linux",
   152              "kernel.version": "5.4.0-48-generic",
   153              "memory.totalbytes": "16525733888",
   154              "nomad.advertise.address": "127.0.0.1:4646",
   155              "nomad.revision": "8c88f29bff0849720e33b0cc73af87495358f3b8",
   156              "nomad.version": "0.13.0-dev",
   157              "os.name": "ubuntu",
   158              "os.signals": "SIGBUS,SIGFPE,SIGTRAP,SIGTTOU,SIGWINCH,SIGXFSZ,SIGHUP,SIGILL,SIGALRM,SIGCHLD,SIGSYS,SIGXCPU,SIGPROF,SIGQUIT,SIGTERM,SIGUSR2,SIGCONT,SIGIO,SIGSEGV,SIGTTIN,SIGIOT,SIGKILL,SIGPIPE,SIGABRT,SIGINT,SIGSTOP,SIGTSTP,SIGURG,SIGUSR1",
   159              "os.version": "20.04",
   160              "unique.cgroup.mountpoint": "/sys/fs/cgroup/systemd",
   161              "unique.hostname": "x1c",
   162              "unique.network.ip-address": "127.0.0.1",
   163              "unique.storage.bytesfree": "299488927744",
   164              "unique.storage.bytestotal": "502468108288",
   165              "unique.storage.volume": "/dev/nvme0n1p2"
   166            },
   167            "NodeResources": {
   168              "Cpu": {
   169                "CpuShares": 33600
   170              },
   171              "Memory": {
   172                "MemoryMB": 15760
   173              },
   174              "Disk": {
   175                "DiskMB": 285614
   176              },
   177              "Networks": [
   178                {
   179                  "Mode": "bridge",
   180                  "Device": "",
   181                  "CIDR": "",
   182                  "IP": "",
   183                  "MBits": 0,
   184                  "DNS": null,
   185                  "ReservedPorts": null,
   186                  "DynamicPorts": null
   187                },
   188                {
   189                  "Mode": "host",
   190                  "Device": "lo",
   191                  "CIDR": "127.0.0.1/32",
   192                  "IP": "127.0.0.1",
   193                  "MBits": 1000,
   194                  "DNS": null,
   195                  "ReservedPorts": null,
   196                  "DynamicPorts": null
   197                },
   198                {
   199                  "Mode": "host",
   200                  "Device": "lo",
   201                  "CIDR": "::1/128",
   202                  "IP": "::1",
   203                  "MBits": 1000,
   204                  "DNS": null,
   205                  "ReservedPorts": null,
   206                  "DynamicPorts": null
   207                }
   208              ],
   209              "NodeNetworks": [
   210                {
   211                  "Mode": "bridge",
   212                  "Device": "",
   213                  "MacAddress": "",
   214                  "Speed": 0,
   215                  "Addresses": null
   216                },
   217                {
   218                  "Mode": "host",
   219                  "Device": "lo",
   220                  "MacAddress": "",
   221                  "Speed": 1000,
   222                  "Addresses": [
   223                    {
   224                      "Family": "ipv4",
   225                      "Alias": "default",
   226                      "Address": "127.0.0.1",
   227                      "ReservedPorts": "",
   228                      "Gateway": ""
   229                    },
   230                    {
   231                      "Family": "ipv6",
   232                      "Alias": "default",
   233                      "Address": "::1",
   234                      "ReservedPorts": "",
   235                      "Gateway": ""
   236                    }
   237                  ]
   238                }
   239              ],
   240              "Devices": null
   241            },
   242            "ReservedResources": {
   243              "Cpu": {
   244                "CpuShares": 0
   245              },
   246              "Memory": {
   247                "MemoryMB": 0
   248              },
   249              "Disk": {
   250                "DiskMB": 0
   251              },
   252              "Networks": {
   253                "ReservedHostPorts": ""
   254              }
   255            },
   256            "Resources": {
   257              "CPU": 33600,
   258              "MemoryMB": 15760,
   259              "DiskMB": 285614,
   260              "IOPS": 0,
   261              "Networks": [
   262                {
   263                  "Mode": "host",
   264                  "Device": "lo",
   265                  "CIDR": "127.0.0.1/32",
   266                  "IP": "127.0.0.1",
   267                  "MBits": 1000,
   268                  "DNS": null,
   269                  "ReservedPorts": null,
   270                  "DynamicPorts": null
   271                },
   272                {
   273                  "Mode": "host",
   274                  "Device": "lo",
   275                  "CIDR": "::1/128",
   276                  "IP": "::1",
   277                  "MBits": 1000,
   278                  "DNS": null,
   279                  "ReservedPorts": null,
   280                  "DynamicPorts": null
   281                }
   282              ],
   283              "Devices": null
   284            },
   285            "Reserved": {
   286              "CPU": 0,
   287              "MemoryMB": 0,
   288              "DiskMB": 0,
   289              "IOPS": 0,
   290              "Networks": null,
   291              "Devices": null
   292            },
   293            "Links": null,
   294            "Meta": {
   295              "connect.gateway_image": "envoyproxy/envoy:v1.11.2@sha256:a7769160c9c1a55bb8d07a3b71ce5d64f72b1f665f10d81aa1581bc3cf850d09",
   296              "connect.log_level": "info",
   297              "connect.sidecar_image": "envoyproxy/envoy:v1.11.2@sha256:a7769160c9c1a55bb8d07a3b71ce5d64f72b1f665f10d81aa1581bc3cf850d09"
   298            },
   299            "NodeClass": "",
   300            "ComputedClass": "v1:9803688035578634002",
   301            "Drain": false,
   302            "DrainStrategy": null,
   303            "SchedulingEligibility": "eligible",
   304            "Status": "initializing",
   305            "StatusDescription": "",
   306            "StatusUpdatedAt": 1602770857,
   307            "Events": [
   308              {
   309                "Message": "Node registered",
   310                "Subsystem": "Cluster",
   311                "Details": null,
   312                "Timestamp": "2020-10-15T10:07:37-04:00",
   313                "CreateIndex": 0
   314              }
   315            ],
   316            "Drivers": {
   317              "docker": {
   318                "Attributes": {
   319                  "driver.docker": "true",
   320                  "driver.docker.bridge_ip": "172.17.0.1",
   321                  "driver.docker.os_type": "linux",
   322                  "driver.docker.runtimes": "runc",
   323                  "driver.docker.version": "19.03.13"
   324                },
   325                "Detected": true,
   326                "Healthy": true,
   327                "HealthDescription": "Healthy",
   328                "UpdateTime": "2020-10-15T10:07:37.904159516-04:00"
   329              },
   330              "exec": {
   331                "Attributes": null,
   332                "Detected": false,
   333                "Healthy": false,
   334                "HealthDescription": "Driver must run as root",
   335                "UpdateTime": "2020-10-15T10:07:37.445083368-04:00"
   336              },
   337              "java": {
   338                "Attributes": null,
   339                "Detected": false,
   340                "Healthy": false,
   341                "HealthDescription": "Driver must run as root",
   342                "UpdateTime": "2020-10-15T10:07:37.445601605-04:00"
   343              },
   344              "mock_driver": {
   345                "Attributes": {
   346                  "driver.mock": "true"
   347                },
   348                "Detected": true,
   349                "Healthy": true,
   350                "HealthDescription": "Healthy",
   351                "UpdateTime": "2020-10-15T10:07:37.445193068-04:00"
   352              },
   353              "qemu": {
   354                "Attributes": null,
   355                "Detected": false,
   356                "Healthy": false,
   357                "HealthDescription": "",
   358                "UpdateTime": "2020-10-15T10:07:37.445684857-04:00"
   359              },
   360              "raw_exec": {
   361                "Attributes": {
   362                  "driver.raw_exec": "true"
   363                },
   364                "Detected": true,
   365                "Healthy": true,
   366                "HealthDescription": "Healthy",
   367                "UpdateTime": "2020-10-15T10:07:37.445431163-04:00"
   368              }
   369            },
   370            "CSIControllerPlugins": null,
   371            "CSINodePlugins": null,
   372            "HostVolumes": null,
   373            "CreateIndex": 7,
   374            "ModifyIndex": 7
   375          }
   376        }
   377      }
   378    ]
   379  }
   380  ```