2017-04-04 16:33:22 +00:00
|
|
|
---
|
|
|
|
layout: api
|
|
|
|
page_title: Events - HTTP API
|
|
|
|
description: |-
|
|
|
|
The /event endpoints fire new events and to query the available events in
|
|
|
|
Consul.
|
|
|
|
---
|
|
|
|
|
|
|
|
# Event HTTP Endpoint
|
|
|
|
|
|
|
|
The `/event` endpoints fire new events and to query the available events in
|
|
|
|
Consul.
|
|
|
|
|
|
|
|
## Fire Event
|
|
|
|
|
|
|
|
This endpoint triggers a new user event.
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | ------------------- | ------------------ |
|
|
|
|
| `PUT` | `/event/fire/:name` | `application/json` |
|
2017-04-04 16:33:22 +00:00
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2023-01-25 16:52:43 +00:00
|
|
|
[blocking queries](/consul/api-docs/features/blocking),
|
|
|
|
[consistency modes](/consul/api-docs/features/consistency),
|
|
|
|
[agent caching](/consul/api-docs/features/caching), and
|
|
|
|
[required ACLs](/consul/api-docs/api-structure#authentication).
|
2017-04-04 16:33:22 +00:00
|
|
|
|
2018-09-06 10:34:28 +00:00
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | ------------- |
|
|
|
|
| `NO` | `none` | `none` | `event:write` |
|
2017-04-04 16:33:22 +00:00
|
|
|
|
2023-01-25 16:52:43 +00:00
|
|
|
The corresponding CLI command is [`consul event`](/consul/commands/event).
|
2022-01-10 19:21:32 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Path Parameters
|
2017-04-04 16:33:22 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `name` `(string: <required>)` - Specifies the name of the event to fire.
|
|
|
|
This name must not start with an underscore,
|
2017-04-04 16:33:22 +00:00
|
|
|
since those are reserved for Consul internally.
|
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Query Parameters
|
|
|
|
|
2017-04-04 16:33:22 +00:00
|
|
|
- `dc` `(string: "")` - Specifies the datacenter to query. This will default to
|
2022-05-10 15:51:11 +00:00
|
|
|
the datacenter of the agent being queried.
|
2017-04-04 16:33:22 +00:00
|
|
|
|
|
|
|
- `node` `(string: "")` - Specifies a regular expression to filter by node name.
|
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `service` `(string: "")` - Specifies a regular expression to filter by service name.
|
2017-04-04 16:33:22 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `tag` `(string: "")` - Specifies a regular expression to filter by tag.
|
2017-04-04 16:33:22 +00:00
|
|
|
|
|
|
|
### Sample Payload
|
|
|
|
|
|
|
|
The body contents are opaque to Consul and become the "payload" that is passed
|
|
|
|
onto the receiver of the event.
|
|
|
|
|
|
|
|
```text
|
|
|
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit...
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2017-04-04 16:33:22 +00:00
|
|
|
$ curl \
|
|
|
|
--request PUT \
|
|
|
|
--data @payload \
|
2018-08-28 16:07:15 +00:00
|
|
|
http://127.0.0.1:8500/v1/event/fire/my-event
|
2017-04-04 16:33:22 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"ID": "b54fe110-7af5-cafc-d1fb-afc8ba432b1c",
|
|
|
|
"Name": "deploy",
|
|
|
|
"Payload": null,
|
|
|
|
"NodeFilter": "",
|
|
|
|
"ServiceFilter": "",
|
|
|
|
"TagFilter": "",
|
|
|
|
"Version": 1,
|
|
|
|
"LTime": 0
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
- `ID` is a unique identifier the newly fired event
|
|
|
|
|
|
|
|
## List Events
|
|
|
|
|
2018-04-02 10:57:04 +00:00
|
|
|
This endpoint returns the most recent events (up to 256) known by the agent. As a
|
2023-01-25 16:52:43 +00:00
|
|
|
consequence of how the [event command](/consul/commands/event) works, each
|
2017-04-04 16:33:22 +00:00
|
|
|
agent may have a different view of the events. Events are broadcast using the
|
2023-01-25 16:52:43 +00:00
|
|
|
[gossip protocol](/consul/docs/architecture/gossip), so they have no global ordering
|
2017-04-04 16:33:22 +00:00
|
|
|
nor do they make a promise of delivery.
|
|
|
|
|
2022-03-19 20:32:38 +00:00
|
|
|
@include 'http_api_results_filtered_by_acls.mdx'
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | ------------- | ------------------ |
|
|
|
|
| `GET` | `/event/list` | `application/json` |
|
2017-04-04 16:33:22 +00:00
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2023-01-25 16:52:43 +00:00
|
|
|
[blocking queries](/consul/api-docs/features/blocking),
|
|
|
|
[consistency modes](/consul/api-docs/features/consistency),
|
|
|
|
[agent caching](/consul/api-docs/features/caching), and
|
|
|
|
[required ACLs](/consul/api-docs/api-structure#authentication).
|
2017-04-04 16:33:22 +00:00
|
|
|
|
2018-09-06 10:34:28 +00:00
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | ------------ |
|
|
|
|
| `YES` | `none` | `none` | `event:read` |
|
2017-04-04 16:33:22 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Query Parameters
|
2017-04-04 16:33:22 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `name` `(string: "")` - Specifies the name of the event to filter.
|
2017-04-04 16:33:22 +00:00
|
|
|
|
|
|
|
- `node` `(string: "")` - Specifies a regular expression to filter by node name.
|
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `service` `(string: "")` - Specifies a regular expression to filter by service name.
|
2017-04-04 16:33:22 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `tag` `(string: "")` - Specifies a regular expression to filter by tag.
|
2017-04-04 16:33:22 +00:00
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2017-04-04 16:33:22 +00:00
|
|
|
$ curl \
|
2018-08-28 16:07:15 +00:00
|
|
|
http://127.0.0.1:8500/v1/event/list
|
2017-04-04 16:33:22 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"ID": "b54fe110-7af5-cafc-d1fb-afc8ba432b1c",
|
|
|
|
"Name": "deploy",
|
|
|
|
"Payload": "MTYwOTAzMA==",
|
|
|
|
"NodeFilter": "",
|
|
|
|
"ServiceFilter": "",
|
|
|
|
"TagFilter": "",
|
|
|
|
"Version": 1,
|
|
|
|
"LTime": 19
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
### Caveat
|
|
|
|
|
|
|
|
The semantics of this endpoint's blocking queries are slightly different. Most
|
|
|
|
blocking queries provide a monotonic index and block until a newer index is
|
|
|
|
available. This can be supported as a consequence of the total ordering of the
|
2023-01-25 16:52:43 +00:00
|
|
|
[consensus protocol](/consul/docs/architecture/consensus). With gossip, there is no
|
2017-04-04 16:33:22 +00:00
|
|
|
ordering, and instead `X-Consul-Index` maps to the newest event that matches the
|
|
|
|
query.
|
|
|
|
|
|
|
|
In practice, this means the index is only useful when used against a single
|
|
|
|
agent and has no meaning globally. Because Consul defines the index as being
|
|
|
|
opaque, clients should not be expecting a natural ordering either.
|