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