website: working on docs

This commit is contained in:
Armon Dadgar 2014-02-18 15:30:07 -08:00
parent 467db27813
commit 03e62172f1
6 changed files with 216 additions and 286 deletions

View File

@ -4,75 +4,87 @@ page_title: "Agent"
sidebar_current: "docs-agent-running" sidebar_current: "docs-agent-running"
--- ---
# Serf Agent # Consul Agent
The Serf agent is the core process of Serf. The agent maintains membership The Consul agent is the core process of Consul. The agent maintains membership
information, propagates events, invokes event handlers, detects failures, information, registers services, runs checks, responds to queries
and more. The agent must run on every node that is part of a Serf cluster. and more. The agent must run on every node that is part of a Consul cluster.
Any Agent may run in one of two modes: client or server. A server
node takes on the additional responsibility of being part of the [consensus quorum](#).
These nodes take part in Raft, and provide strong consistency and availability in
the case of failure. The higher burden on the server nodes means that usually they
should be run on dedicated instances, as they are more resource intensive than a client
node. Client nodes make up the majority of the cluster, and they are very lightweight
as they maintain very little state and interface with the server nodes for most operations.
## Running an Agent ## Running an Agent
The agent is started with the `serf agent` command. This command blocks, The agent is started with the `consul agent` command. This command blocks,
running forever or until told to quit. The agent command takes a variety running forever or until told to quit. The agent command takes a variety
of configuration options but the defaults are usually good enough. When of configuration options but the defaults are usually good enough. When
running `serf agent`, you should see output similar to that below: running `consul agent`, you should see output similar to that below:
``` ```
$ serf agent $ consul agent -data=/tmp/consul
==> Starting Serf agent... ==> Starting Consul agent...
==> Serf agent running! ==> Starting Consul agent RPC...
Node name: 'mitchellh.local' ==> Consul agent running!
Bind addr: '0.0.0.0:7946' Node name: 'Armons-MacBook-Air.local'
RPC addr: '127.0.0.1:7373' Datacenter: 'dc1'
Encrypted: false Advertise addr: '10.1.10.12'
Snapshot: false RPC addr: '127.0.0.1:8400'
Profile: lan HTTP addr: '127.0.0.1:8500'
DNS addr: '127.0.0.1:8600'
Encrypted: false
Server: false (bootstrap: false)
==> Log data will now stream in as it occurs: ==> Log data will now stream in as it occurs:
2013/10/22 10:35:33 [INFO] Serf agent starting 2014/02/18 14:25:02 [INFO] serf: EventMemberJoin: Armons-MacBook-Air.local 10.1.10.12
2013/10/22 10:35:33 [INFO] serf: EventMemberJoin: mitchellh.local 127.0.0.1 2014/02/18 14:25:02 [ERR] agent: failed to sync remote state: No known Consul servers
2013/10/22 10:35:33 [INFO] Serf agent started
2013/10/22 10:35:33 [INFO] agent: Received event: member-join
... ...
``` ```
There are six important components that `serf agent` outputs: There are several important components that `consul agent` outputs:
* **Node name**: This is a unique name for the agent. By default this * **Node name**: This is a unique name for the agent. By default this
is the hostname of the machine, but you may customize it to whatever is the hostname of the machine, but you may customize it to whatever
you'd like using the `-node` flag. you'd like using the `-node` flag.
* **Bind addr**: This is the address and port used for communication between * **Datacenter**: This is the datacenter the agent is configured to run
Serf agents in a cluster. Every Serf agent in a cluster does not have to in. Consul has first-class support for multiple datacenters, but to work efficiently
use the same port. each node must be configured to correctly report it's datacenter. The `-dc` flag
can be used to set the datacenter. For single-DC configurations, the agent
will default to "dc1".
* **Advertise addr**: This is the address and port used for communication between
Consul agents in a cluster. Every Consul agent in a cluster does not have to
use the same port, but this address **MUST** be reachable by all other nodes.
* **RPC addr**: This is the address and port used for RPC communications * **RPC addr**: This is the address and port used for RPC communications
for other `serf` commands. Other Serf commands such as `serf members` for other `consul` commands. Other Consul commands such as `consul members`
connect to a running agent and use RPC to query and control the agent. connect to a running agent and use RPC to query and control the agent.
By default, this binds only to localhost on the default port. If you By default, this binds only to localhost on the default port. If you
change this address, you'll have to specify an `-rpc-addr` to commands change this address, you'll have to specify an `-rpc-addr` to commands
such as `serf members` so they know how to talk to the agent. This is also such as `consul members` so they know how to talk to the agent. This is also
the address other applications can use over [RPC to control Serf](/docs/agent/rpc.html). the address other applications can use over [RPC to control Consul](/docs/agent/rpc.html).
* **Encrypted**: This shows if Serf is encrypting all traffic that it * **HTTP/DNS addr**: This is the addresses the agent is listening on for the
HTTP and DNS interfaces respectively. These are bound to localhost for security,
but can be configured to listen on other addresses or ports.
* **Encrypted**: This shows if Consul is encrypting all traffic that it
sends and expects to receive. It is a good sanity check to avoid sending sends and expects to receive. It is a good sanity check to avoid sending
non-encrypted traffic over any public networks. You can read more about non-encrypted traffic over any public networks. You can read more about
[encryption here](/docs/agent/encryption.html). [encryption here](/docs/agent/encryption.html).
* **Snapshot**: This shows if Serf snapshotting is enabled. The snapshot * **Server**: This shows if the agent is running in the server or client mode.
file enables Serf to automatically re-join a cluster after failure and Server nodes have the extra burden of participating in the consensus quorum,
prevents replay of events that have already been seen. It requires storing storing cluster state, and handling queries. Additionally, a server may be
state on disk, and [must be configured](/docs/agent/options.html) in "bootstrap" mode. The first server must be in this mode to allow additional
using a CLI flag or in the configuration directory. If it is not provided, servers to join the cluster. Multiple servers cannot be in bootstrap mode,
other nodes will still attempt to reconnect on recovery, however the node otherwise the cluster state will be inconsistent.
will take longer to join the cluster and will replay old events.
* **Profile**: The profile controls various timing values which should
be appropriate to the environment Serf is running in. It defaults to
optimizing for a LAN environment, but can also be set for WAN or
local-only communication. The profile can be set in
the [configuration](/docs/agent/options.html).
## Stopping an Agent ## Stopping an Agent
@ -87,8 +99,13 @@ When force killed, the agent ends immediately. The rest of the cluster will
eventually (usually within seconds) detect that the node has died and will eventually (usually within seconds) detect that the node has died and will
notify the cluster that the node has _failed_. notify the cluster that the node has _failed_.
The difference between a node _failing_ and a node _leaving_ may not be It is especially important that a server node be allowed to gracefully leave,
important for your use case. For example, for a web server and load so that there will be a minimal impact on availablity as the server leaves
the consensus quorum.
For client agents, the difference between a node _failing_ and a node _leaving_
may not be important for your use case. For example, for a web server and load
balancer setup, both result in the same action: remove the web node balancer setup, both result in the same action: remove the web node
from the load balancer pool. But for other situations, you may handle from the load balancer pool. But for other situations, you may handle
each scenario differently. each scenario differently.

View File

@ -6,22 +6,22 @@ sidebar_current: "docs-agent-encryption"
# Encryption # Encryption
The Serf agent supports encrypting all of its network traffic. The exact The Consul agent supports encrypting all of its network traffic. The exact
method of this encryption is described on the method of this encryption is described on the
[encryption internals page](/docs/internals/security.html). [encryption internals page](/docs/internals/security.html).
## Enabling Encryption ## Enabling Encryption
Enabling encryption only requires that you set an encryption key when Enabling encryption only requires that you set an encryption key when
starting the Serf agent. The key can be set using the `-encrypt` flag starting the Consul agent. The key can be set using the `-encrypt` flag
on `serf agent` or by setting the `encrypt_key` in a configuration file. on `consul agent` or by setting the `encrypt_key` in a configuration file.
It is advisable to put the key in a configuration file to avoid other users It is advisable to put the key in a configuration file to avoid other users
from being able to discover it by inspecting running processes. from being able to discover it by inspecting running processes.
The key must be 16-bytes that are base64 encoded. The easiest method to The key must be 16-bytes that are base64 encoded. The easiest method to
obtain a cryptographically suitable key is by using `serf keygen`. obtain a cryptographically suitable key is by using `consul keygen`.
``` ```
$ serf keygen $ consul keygen
cg8StVXbQJ0gPvMd9o7yrg== cg8StVXbQJ0gPvMd9o7yrg==
``` ```
@ -29,26 +29,21 @@ With that key, you can enable encryption on the agent. You can verify
encryption is enabled because the output will include "Encrypted: true". encryption is enabled because the output will include "Encrypted: true".
``` ```
$ serf agent -encrypt=cg8StVXbQJ0gPvMd9o7yrg== $ consul agent -data=/tmp/consul -encrypt=cg8StVXbQJ0gPvMd9o7yrg==
==> Starting Serf agent... ==> Starting Consul agent...
==> Serf agent running! ==> Starting Consul agent RPC...
Node name: 'mitchellh.local' ==> Consul agent running!
Bind addr: '0.0.0.0:7946' Node name: 'Armons-MacBook-Air.local'
RPC addr: '127.0.0.1:7373' Datacenter: 'dc1'
Encrypted: true Advertise addr: '10.1.10.12'
RPC addr: '127.0.0.1:8400'
HTTP addr: '127.0.0.1:8500'
DNS addr: '127.0.0.1:8600'
Encrypted: true
Server: false (bootstrap: false)
... ...
``` ```
All nodes within a Serf cluster must share the same encryption key in All nodes within a Consul cluster must share the same encryption key in
order to send and receive cluster information. order to send and receive cluster information.
## Multiple Clusters
If you're running multiple Serf clusters, for example a Serf cluster to
maintain cache nodes and a Serf cluster to maintain web servers, then you
can use different encryption keys for each cluster in order to separately
encrypt the traffic.
This has the added benefit that the Serf agents from one cluster cannot
even accidentally join the other cluster, since the two clusters will not
be able to communicate without the same encryption key.

View File

@ -11,14 +11,14 @@ the command-line or via configuration files. All of the configuration
options are completely optional and their defaults will be specified options are completely optional and their defaults will be specified
with their descriptions. with their descriptions.
When loading configuration, Serf loads the configuration from files When loading configuration, Consul loads the configuration from files
and directories in the order specified. Configuration specified later and directories in the order specified. Configuration specified later
will be merged into configuration specified earlier. In most cases, will be merged into configuration specified earlier. In most cases,
"merge" means that the later version will override the earlier. But in "merge" means that the later version will override the earlier. But in
some cases, such as event handlers, merging just appends the handlers. some cases, such as event handlers, merging just appends the handlers.
The exact merging behavior will be specified. The exact merging behavior will be specified.
Serf also supports reloading of configuration when it receives the Consul also supports reloading of configuration when it receives the
SIGHUP signal. Not all changes are respected, but those that are SIGHUP signal. Not all changes are respected, but those that are
are documented below. are documented below.
@ -26,18 +26,19 @@ are documented below.
The options below are all specified on the command-line. The options below are all specified on the command-line.
* `-bind` - The address that Serf will bind to for communication with * `-serf-bind` - The address that the underlying Serf library will bind to.
other Serf nodes. By default this is "0.0.0.0:7946". Serf nodes may This is an IP address that should be reachable by all other nodes in the cluster.
have different ports. If a join is specified without a port, we default By default this is "0.0.0.0", meaning Consul will use the first available private
to locally configured port. Serf uses both TCP and UDP and use the IP address. Consul uses both TCP and UDP and use the same port for both, so if you
same port for both, so if you have any firewalls be sure to allow both protocols. have any firewalls be sure to allow both protocols.
If this configuration value is changed and no port is specified, the default of
"7946" will be used. An important compatibility note, protocol version 2 * `-server-addr` - The address that the agent will bind to for handling RPC calls
introduces support for non-consistent ports across the cluster. For more information, if running in server mode. This does not affect clients running in client mode.
see the [compatibility page](/docs/compatibility.html). By default this is "0.0.0.0:8300". This port is used for TCP communications so any
firewalls must be configured to allow this.
* `-advertise` - The advertise flag is used to change the address that we * `-advertise` - The advertise flag is used to change the address that we
advertise to other nodes in the cluster. By default, the bind address is advertise to other nodes in the cluster. By default, the `-serf-bind` address is
advertised. However, in some cases (specifically NAT traversal), there may advertised. However, in some cases (specifically NAT traversal), there may
be a routable address that cannot be bound to. This flag enables gossiping be a routable address that cannot be bound to. This flag enables gossiping
a different address to support this. If this address is not routable, the node a different address to support this. If this address is not routable, the node
@ -56,33 +57,11 @@ The options below are all specified on the command-line.
in alphabetical order. For more information on the format of the configuration in alphabetical order. For more information on the format of the configuration
files, see the "Configuration Files" section below. files, see the "Configuration Files" section below.
* `-discover` - Discover provides a cluster name, which is used with mDNS to
automatically discover Serf peers. When provided, Serf will respond to mDNS
queries and periodically poll for new peers. This feature requires a network
environment that supports multicasting.
* `-encrypt` - Specifies the secret key to use for encryption of Serf * `-encrypt` - Specifies the secret key to use for encryption of Serf
network traffic. This key must be 16-bytes that are base64 encoded. The network traffic. This key must be 16-bytes that are base64 encoded. The
easiest way to create an encryption key is to use `serf keygen`. All easiest way to create an encryption key is to use `consul keygen`. All
nodes within a cluster must share the same encryption key to communicate. nodes within a cluster must share the same encryption key to communicate.
* `-event-handler` - Adds an event handler that Serf will invoke for
events. This flag can be specified multiple times to define multiple
event handlers. By default no event handlers are registered. See the
[event handler page](/docs/agent/event-handlers.html) for more details on
event handlers as well as a syntax for filtering event handlers by event.
Event handlers can be changed by reloading the configuration.
* `-join` - Address of another agent to join upon starting up. This can be
specified multiple times to specify multiple agents to join. If Serf is
unable to join with any of the specified addresses, agent startup will
fail. By default, the agent won't join any nodes when it starts up.
* `-replay` - If set, old user events from the past will be replayed for the
agent/cluster that is joining based on a `-join` configuration. Otherwise,
past events will be ignored. This configures for the initial join
only.
* `-log-level` - The level of logging to show after the Serf agent has * `-log-level` - The level of logging to show after the Serf agent has
started. This defaults to "info". The available log levels are "trace", started. This defaults to "info". The available log levels are "trace",
"debug", "info", "warn", "err". This is the log level that will be shown "debug", "info", "warn", "err". This is the log level that will be shown
@ -93,46 +72,47 @@ The options below are all specified on the command-line.
* `-node` - The name of this node in the cluster. This must be unique within * `-node` - The name of this node in the cluster. This must be unique within
the cluster. By default this is the hostname of the machine. the cluster. By default this is the hostname of the machine.
* `-profile` - Serf by default is configured to run in a LAN or Local Area * `-rpc-addr` - The address that Consul will bind to for the agent's RPC server.
Network. However, there are cases in which a user may want to use Serf over By default this is "127.0.0.1:8400", allowing only loopback connections.
the Internet or (WAN), or even just locally. To support setting the correct The RPC address is used by other Serf commands, such as `consul members`,
configuration values for each environment, you can select a timing profile. in order to query a running Consul agent. It is also used by other applications
The current choices are "lan", "wan", and "local". This defaults to "local". to control Consul using it's [RPC protocol](/docs/agent/rpc.html).
If a "lan" or "local" profile is used over the Internet, or a "local" profile
over the LAN, a high rate of false failures is risked, as the timing constrains
are too tight.
* `-protocol` - The Serf protocol version to use. This defaults to the latest * `-data` - This flag provides a data directory for the agent to store state.
version. This should be set only when [upgrading](/docs/upgrading.html). This is required for all agents. The directory should be durable across reboots.
You can view the protocol versions supported by Serf by running `serf -v`. This is especially critical for agents that are running in server mode, as they
must be able to persist the cluster state.
* `-role` - **Deprecated** The role of this node, if any. By default this is blank or empty. * `-dc` - This flag controls the datacenter the agent is running in. If not provided
The role can be used by events in order to differentiate members of a it defaults to "dc1". Consul has first class support for multiple data centers but
cluster that may have different functional roles. For example, if you're it relies on proper configuration. Nodes in the same datacenter should be on a single
using Serf in a load balancer and web server setup, you only want to add LAN.
web servers to the load balancers, so the role of web servers may be "web"
and the event handlers can filter on that. This has been deprecated as of
version 0.4. Instead "-tag role=foo" should be used. The role can be changed
during a config reload
* `-rpc-addr` - The address that Serf will bind to for the agent's RPC server. * `-recursor` - This flag provides an address of an upstream DNS server that is used to
By default this is "127.0.0.1:7373", allowing only loopback connections. recursively resolve queries if they are not inside the service domain for consul. For example,
The RPC address is used by other Serf commands, such as `serf members`, a node can use Consul directly as a DNS server, and if the record is outside of the "consul." domain,
in order to query a running Serf agent. It is also used by other applications the query will be resolved upstream using this server.
to control Serf using it's [RPC protocol](/docs/agent/rpc.html).
* `-snapshot` - The snapshot flag provides a file path that is used to store * `-http-addr` - This flag controls the address the agent listens on for HTTP requests.
recovery information, so when Serf restarts it is able to automatically By default it is bound to "127.0.0.1:8500". This port must allow for TCP traffic.
re-join the cluster, and avoid replay of events it has already seen. The path
must be read/writable by Serf, and the directory must allow Serf to create
other files, so that it can periodically compact the snapshot file.
* `-tag` - The tag flag is used to associate a new key/value pair with the * `-dns-addr` - This flag controls the address the agent listens on for DNS requests.
agent. The tags are gossiped and can be used to provide additional information By default it is bound to "127.0.0.1:8600". This port must allow for UDP and TCP traffic.
such as roles, ports, and configuration values to other nodes. Multiple tags
can be specified per agent. There is a byte size limit for the maximum number * `-server` - This flag is used to control if an agent is in server or client mode. When provided,
of tags, but in practice dozens of tags may be used. Tags can be changed during an agent will act as a Consul server. Each Consul cluster must have at least one server, and ideally
a config reload. no more than 5 *per* datacenter. All servers participate in the Raft consensus algorithm, to ensure that
transactions occur in a consistent, linearlizable manner. Transactions modify cluster state, which
is maintained on all server nodes to ensure availability in the case of node failure. Server nodes also
participate in a WAN gossip pool with server nodes in other datacenters. Servers act as gateways
to other datacenters and forward traffic as appropriate.
* `-bootstrap` - This flag is used to control if a server is in "bootstrap" mode. It is important that
no more than one server *per* datacenter be running in this mode. The initial server **must** be in bootstrap
mode. Technically, a server in boostrap mode is allowed to self-elect as the Raft leader. It is important
that only a single node is in this mode, because otherwise consistency cannot be guarenteed if multiple
nodes are able to self-elect. Once there are multiple servers in a datacenter, it is generally a good idea
to disable bootstrap mode on all of them.
## Configuration Files ## Configuration Files
@ -144,65 +124,73 @@ The configuration files are JSON formatted, making them easily readable
and editable by both humans and computers. The configuration is formatted and editable by both humans and computers. The configuration is formatted
at a single JSON object with configuration within it. at a single JSON object with configuration within it.
Configuration files are used for more than just setting up the agent,
they are also used to provide check and service definitions. These are used
to announce the availability of system servers to the rest of the cluster.
They are documented seperately under [check configuration](#) and
[service configuration](#) respectively.
#### Example Configuration File #### Example Configuration File
<pre class="prettyprint lang-json"> <pre class="prettyprint lang-json">
{ {
"tags": { "datacenter": "east-aws",
"role": "load-balancer", "data_dir": "/opt/consul",
"datacenter": "east" "log_level": "INFO",
}, "node_name": "foobar",
"server": true
"event_handlers": [
"handle.sh",
"user:deploy=deploy.sh"
]
} }
</pre> </pre>
#### Configuration Key Reference #### Configuration Key Reference
* `node_name` - Equivalent to the `-node` command-line flag. * `bootstrap` - Equivalent to the `-bootstrap` command-line flag.
* `role` - **Deprecated**. Equivalent to the `-role` command-line flag. * `datacenter` - Equivalent to the `-dc` command-line flag.
* `tags` - This is a dictionary of tag values. It is the same as specifying * `data_dir` - Equivalent to the `-data` command-line flag.
the `tag` command-line flag once per tag.
* `bind` - Equivalent to the `-bind` command-line flag. * `dns_addr` - Equivalent to the `-dns-addr` command-line flag.
* `advertise` - Equivalent to the `-advertise` command-line flag. * `recursor` - Equivalent to the `-recursor` command-line flag.
* `discover` - Equivalent to the `-discover` command-line flag. * `domain` - By default, Consul responds to DNS queries in the "consul." domain.
This flag can be used to change that domain. All queries in this domain are assumed
to be handled by Consul, and will not be recursively resolved.
* `encrypt_key` - Equivalent to the `-encrypt` command-line flag. * `encrypt` - Equivalent to the `-encrypt` command-line flag.
* `http_addr` - Equivalent to the `-http-addr` command-line flag.
* `log_level` - Equivalent to the `-log-level` command-line flag. * `log_level` - Equivalent to the `-log-level` command-line flag.
* `profile` - Equivalent to the `-profile` command-line flag. * `node_name` - Equivalent to the `-node` command-line flag.
* `protocol` - Equivalent to the `-protocol` command-line flag.
* `rpc_addr` - Equivalent to the `-rpc-addr` command-line flag. * `rpc_addr` - Equivalent to the `-rpc-addr` command-line flag.
* `event_handlers` - An array of strings specifying the event handlers. * `serf_bind_addr` - Equivalent to the `-serf-bind` command-line flag.
The format of the strings is equivalent to the format specified for
the `-event-handler` command-line flag.
* `start_join` - An array of strings specifying addresses of nodes to * `serf_lan_port` - This configures which port Serf listens on to communicate
join upon startup. with nodes on the local LAN. By default this is 8301. All nodes in the datacenter
should be able to reach this port over TCP and UDP.
* `replay_on_join` - Equivalent to the `-replay` command-line flag. * `serf_wan_port` - This configures which port Serf listens on to communicate
with nodes on the remote WAN. By default this is 8302. All nodes in the WAN gossip
pool should be able to reach this port over TCP and UDP. This only applies to
agents running in server mode.
* `snapshot_path` - Equivalent to the `-snapshot` command-line flag. * `server_addr` - Equivalent to the `-server-addr` command-line flag.
* `advertise_addr` - Equivalent to the `-advertise` command-line flag.
* `server` - Equivalent to the `-server` command-line flag.
* `leave_on_terminate` - If enabled, when the agent receives a TERM signal, * `leave_on_terminate` - If enabled, when the agent receives a TERM signal,
it will send a Leave message to the rest of the cluster and gracefully it will send a Leave message to the rest of the cluster and gracefully
leave. Defaults to false. leave. Defaults to false.
* `skip_leave_on_interrupt` - This is the similar to`leave_on_terminate` but * `skip_leave_on_interrupt` - This is the similar to`leave_on_terminate` but
only affects interrupt handling. By default, an interrupt causes Serf to only affects interrupt handling. By default, an interrupt causes Consul to
gracefully leave, but setting this to true disables that. Defaults to false. gracefully leave, but setting this to true disables that. Defaults to false.
Interrupts are usually from a Control-C from a shell. (This was previously Interrupts are usually from a Control-C from a shell.
`leave_on_interrupt` but has since changed).

View File

@ -6,11 +6,11 @@ sidebar_current: "docs-agent-rpc"
# RPC Protocol # RPC Protocol
The Serf agent provides a complete RPC mechanism that can The Consul agent provides a complete RPC mechanism that can
be used to control the agent programmatically. This RPC be used to control the agent programmatically. This RPC
mechanism is the same one used by the CLI, but can be mechanism is the same one used by the CLI, but can be
used by other applications to easily leverage the power used by other applications to easily leverage the power
of Serf without directly embedding. Additionally, it can of Consul without directly embedding. Additionally, it can
be used as a fast IPC mechanism to allow applications to be used as a fast IPC mechanism to allow applications to
receive events immediately instead of using the fork/exec receive events immediately instead of using the fork/exec
model of event handlers. model of event handlers.
@ -46,14 +46,13 @@ All responses may be accompanied by an error.
Possible commands include: Possible commands include:
* handshake - Used to initialize the connection, set the version * handshake - Used to initialize the connection, set the version
* event - Fires a new user event
* force-leave - Removes a failed node from the cluster * force-leave - Removes a failed node from the cluster
* join - Requests Serf join another node * join - Requests Consul join another node
* members - Returns the list of members * members-lan - Returns the list of lan members
* stream - Starts streaming events over the connection * members-wan - Returns the list of wan members
* monitor - Starts streaming logs over the connection * monitor - Starts streaming logs over the connection
* stop - Stops streaming logs or events * stop - Stops streaming logs
* leave - Serf agent performs a graceful leave and shutdown * leave - Consul agent performs a graceful leave and shutdown
Below each command is documented along with any request or Below each command is documented along with any request or
response body that is applicable. response body that is applicable.
@ -76,20 +75,6 @@ in the future.
There is no special response body, but the client should wait for the There is no special response body, but the client should wait for the
response and check for an error. response and check for an error.
### event
The event command is used to fire a new user event. It takes the
following request body:
```
{"Name": "foo", "Payload": "test payload", "Coalesce": true}
```
The `Name` is a string, but `Payload` is just opaque bytes. Coalesce
is used to control if Serf should enable [event coalescing](/docs/commands/event.html).
There is no special response body.
### force-leave ### force-leave
This command is used to remove failed nodes from a cluster. It takes This command is used to remove failed nodes from a cluster. It takes
@ -107,12 +92,17 @@ This command is used to join an existing cluster using a known node.
It takes the following body: It takes the following body:
``` ```
{"Existing": ["192.168.0.1:6000", "192.168.0.2:6000"], "Replay": false} {"Existing": ["192.168.0.1:6000", "192.168.0.2:6000"], "WAN": false}
``` ```
The `Existing` nodes are each contacted, and `Replay` controls if we will replay The `Existing` nodes are each contacted, and `WAN` controls if we are adding a
old user events or if they will simply be ignored. The response body in addition WAN member or LAN member. LAN members are expected to be in the same datacenter,
to the header is returned. The body looks like: and should be accessible at relatively low latencies. WAN members are expected to
be operating in different datacenters, with relatively high access latencies. It is
important that only agents running in "server" mode are able to join nodes over the
WAN.
The response body in addition to the header is returned. The body looks like:
``` ```
{"Num": 2} {"Num": 2}
@ -120,10 +110,12 @@ to the header is returned. The body looks like:
The body returns the number of nodes successfully joined. The body returns the number of nodes successfully joined.
### members ### members-lan
The members command is used to return all the known members and associated The members-lan command is used to return all the known lan members and associated
information. There is no request body, but the response looks like: information. All agents will respond to this command.
There is no request body, but the response looks like:
``` ```
{"Members": [ {"Members": [
@ -146,77 +138,16 @@ information. There is no request body, but the response looks like:
} }
``` ```
### stream ### members-wan
The stream command is used to subscribe to a stream of all events The members-wan command is used to return all the known wan members and associated
matching a given type filter. Events will continue to be sent until information. Only agents in server mode will respond to this command.
the stream is stopped. The request body looks like:
``` There is no request body, and the response is the same as `members-lan`
{"Type": "member-join,user:deploy"}`
```
The format of type is the same as the [event handler](/docs/agent/event-handlers.html),
except no script is specified. The one exception is that `"*"` can be specified to
subscribe to all events.
The server will respond with a standard response header indicating if the stream
was successful. However, now as events occur they will be sent and tagged with
the same `Seq` as the stream command that matches.
Assume we issued the previous stream command with Seq `50`,
we may start getting messages like:
```
{"Seq": 50, "Error": ""}
{
"Event": "user",
"LTime": 123,
"Name": "deploy",
"Payload": "9c45b87",
"Coalesce": true,
}
{"Seq": 50, "Error": ""}
{
"Event": "member-join",
"Members": [
{
"Name": "TestNode"
"Addr": [127, 0, 0, 1],
"Port": 5000,
"Tags": {
"role": "test"
},
"Status": "alive",
"ProtocolMin": 0,
"ProtocolMax": 3,
"ProtocolCur": 2,
"DelegateMin": 0,
"DelegateMax": 1,
"DelegateCur": 1,
},
...
]
}
```
It is important to realize that these messages are sent asyncronously,
and not in response to any command. That means if a client is streaming
commands, there may be events streamed while a client is waiting for a
response to a command. This is why the `Seq` must be used to pair requests
with their corresponding responses.
There is no limit to the number of concurrent streams a client can request,
however a message is not deduplicated, so if multiple streams match a given
event, it will be sent multiple times with the corresponding `Seq` number.
To stop streaming, the `stop` command is used.
### monitor ### monitor
The monitor command is similar to the stream command, but instead of The monitor command subscribes the channel to log messages from the Agent.
events it subscribes the channel to log messages from the Agent.
The request is like: The request is like:
@ -249,15 +180,14 @@ To stop streaming, the `stop` command is used.
### stop ### stop
The stop command is used to stop either a stream or monitor. The stop command is used to stop a monitor.
The request looks like: The request looks like:
``` ```
{"Stop": 50} {"Stop": 50}
``` ```
This unsubscribes the client from the monitor and/or stream registered This unsubscribes the client from the monitor with `Seq` value of 50.
with `Seq` value of 50.
There is no special response body. There is no special response body.

View File

@ -6,35 +6,35 @@ sidebar_current: "docs-agent-telemetry"
# Telemetry # Telemetry
The Serf agent collects various metrics data at runtime about the performance The Consul agent collects various metrics data at runtime about the performance
of different libraries and sub-systems. These metrics are aggregated on a ten second of different libraries and sub-systems. These metrics are aggregated on a ten second
interval and are retained for one minute. interval and are retained for one minute.
To view the telemetry information, you must send a `USR1` signal to the Serf To view the telemetry information, you must send a `USR1` signal to the Consul
process. Windows users must use the `BREAK` signal instead. process. Windows users must use the `BREAK` signal instead.
Once Serf receives the signal, it will dump the current telemetry Once Consul receives the signal, it will dump the current telemetry
information to the stderr of the agent. information to the stderr of the agent.
In general, the telemetry information is used for debugging or otherwise In general, the telemetry information is used for debugging or otherwise
getting a better view into what Serf is doing. getting a better view into what Consul is doing.
Below is an example output: Below is an example output:
``` ```
[2014-01-29 10:56:50 -0800 PST][G] 'serf-agent.runtime.num_goroutines': 19.000 [2014-01-29 10:56:50 -0800 PST][G] 'consul-agent.runtime.num_goroutines': 19.000
[2014-01-29 10:56:50 -0800 PST][G] 'serf-agent.runtime.alloc_bytes': 755960.000 [2014-01-29 10:56:50 -0800 PST][G] 'consul-agent.runtime.alloc_bytes': 755960.000
[2014-01-29 10:56:50 -0800 PST][G] 'serf-agent.runtime.malloc_count': 7550.000 [2014-01-29 10:56:50 -0800 PST][G] 'consul-agent.runtime.malloc_count': 7550.000
[2014-01-29 10:56:50 -0800 PST][G] 'serf-agent.runtime.free_count': 4387.000 [2014-01-29 10:56:50 -0800 PST][G] 'consul-agent.runtime.free_count': 4387.000
[2014-01-29 10:56:50 -0800 PST][G] 'serf-agent.runtime.heap_objects': 3163.000 [2014-01-29 10:56:50 -0800 PST][G] 'consul-agent.runtime.heap_objects': 3163.000
[2014-01-29 10:56:50 -0800 PST][G] 'serf-agent.runtime.total_gc_pause_ns': 1151002.000 [2014-01-29 10:56:50 -0800 PST][G] 'consul-agent.runtime.total_gc_pause_ns': 1151002.000
[2014-01-29 10:56:50 -0800 PST][G] 'serf-agent.runtime.total_gc_runs': 4.000 [2014-01-29 10:56:50 -0800 PST][G] 'consul-agent.runtime.total_gc_runs': 4.000
[2014-01-29 10:56:50 -0800 PST][C] 'serf-agent.agent.ipc.accept': Count: 5 Sum: 5.000 [2014-01-29 10:56:50 -0800 PST][C] 'consul-agent.agent.ipc.accept': Count: 5 Sum: 5.000
[2014-01-29 10:56:50 -0800 PST][C] 'serf-agent.agent.ipc.command': Count: 10 Sum: 10.000 [2014-01-29 10:56:50 -0800 PST][C] 'consul-agent.agent.ipc.command': Count: 10 Sum: 10.000
[2014-01-29 10:56:50 -0800 PST][C] 'serf-agent.serf.events': Count: 5 Sum: 5.000 [2014-01-29 10:56:50 -0800 PST][C] 'consul-agent.serf.events': Count: 5 Sum: 5.000
[2014-01-29 10:56:50 -0800 PST][C] 'serf-agent.serf.events.foo': Count: 4 Sum: 4.000 [2014-01-29 10:56:50 -0800 PST][C] 'consul-agent.serf.events.foo': Count: 4 Sum: 4.000
[2014-01-29 10:56:50 -0800 PST][C] 'serf-agent.serf.events.baz': Count: 1 Sum: 1.000 [2014-01-29 10:56:50 -0800 PST][C] 'consul-agent.serf.events.baz': Count: 1 Sum: 1.000
[2014-01-29 10:56:50 -0800 PST][S] 'serf-agent.memberlist.gossip': Count: 50 Min: 0.007 Mean: 0.020 Max: 0.041 Stddev: 0.007 Sum: 0.989 [2014-01-29 10:56:50 -0800 PST][S] 'consul-agent.memberlist.gossip': Count: 50 Min: 0.007 Mean: 0.020 Max: 0.041 Stddev: 0.007 Sum: 0.989
[2014-01-29 10:56:50 -0800 PST][S] 'serf-agent.serf.queue.Intent': Count: 10 Sum: 0.000 [2014-01-29 10:56:50 -0800 PST][S] 'consul-agent.serf.queue.Intent': Count: 10 Sum: 0.000
[2014-01-29 10:56:50 -0800 PST][S] 'serf-agent.serf.queue.Event': Count: 10 Min: 0.000 Mean: 2.500 Max: 5.000 Stddev: 2.121 Sum: 25.000 [2014-01-29 10:56:50 -0800 PST][S] 'consul-agent.serf.queue.Event': Count: 10 Min: 0.000 Mean: 2.500 Max: 5.000 Stddev: 2.121 Sum: 25.000
``` ```

View File

@ -4,9 +4,9 @@ page_title: "Documentation"
sidebar_current: "docs-home" sidebar_current: "docs-home"
--- ---
# Serf Documentation # Consul Documentation
Welcome to the Serf documentation! This documentation is more of a reference Welcome to the Consul documentation! This documentation is more of a reference
guide for all available features and options of Serf. If you're just getting guide for all available features and options of Consul. If you're just getting
started with Serf, please start with the started with Consul, please start with the
[introduction and getting started guide](/intro/index.html) instead. [introduction and getting started guide](/intro/index.html) instead.