Skip to content

Operator

Daniel Carbone edited this page Nov 6, 2026 · 1 revision

Operator

$consul->Operator wraps Consul's Operator API for cluster-level tasks: Raft, Autopilot, the gossip keyring and usage. Most calls need an operator ACL privilege.

Raft

[$raft, $err] = $consul->Operator->RaftGetConfiguration();
foreach ($raft->Servers as $server) {
    echo "{$server->Node} {$server->Address} leader=" . var_export($server->Leader, true) . "\n";
}

RaftRemovePeerByAddress(), RaftRemovePeerByID() and RaftLeaderTransfer() modify the Raft cluster. Use them with care.

Autopilot

[$conf, $err] = $consul->Operator->AutopilotGetConfiguration();
var_dump($conf->CleanupDeadServers);

[$health, $err] = $consul->Operator->AutopilotServerHealth();
echo $health->Healthy ? 'healthy' : 'unhealthy', ", failure tolerance {$health->FailureTolerance}\n";

AutopilotCASConfiguration() updates the configuration only if its ModifyIndex still matches.

Keyring

The Keyring* methods manage the gossip encryption keys. They fail with an error if gossip encryption is not enabled on the cluster.

Enterprise-only

The Area*, SegmentList, License* and AuditHash methods use Consul Enterprise endpoints. They return an error against Consul CE.

Many Operator methods return only $err, or [$value, $err] without query metadata. See Responses and Errors.

Clone this wiki locally