HiveMQ Swarm REST API Service
The HiveMQ Swarm REST API service enables monitoring via the /metrics
endpoint and is required for the commander rest
mode.
Enable HiveMQ Swarm REST API
To enable the HiveMQ Swarm REST API, set the enabled
tag in the HiveMQ Swarm REST configuration to true
.
The following example enables the commander
in rest
mode, enables the REST API, and configures an HTTP listener.
<swarm>
<commander>
<mode>rest</mode>
<agents>
<agent>
<host>localhost</host>
<port>3881</port>
</agent>
</agents>
</commander>
<rest>
<enabled>true</enabled>
<listeners>
<http>
<enabled>true</enabled>
<bindAddress>0.0.0.0</bindAddress>
<bindPort>8080</bindPort>
</http>
</listeners>
</rest>
</swarm>
HiveMQ Swarm REST API Configuration Options
You can configure listeners for the HiveMQ Swarm REST API service with environment variables, or the config.xml
file of your HiveMQ Swarm configuration.
Environment-variable Based REST API Configuration
The following environment variables are available for the HiveMQ Swarm REST API service:
Environment Variables for HTTP Listener Configuration
Variable |
Definition |
|
Enables the HTTP listener with the specified |
|
The bind address for the HTTP listener with the specified |
|
The bind port for the HTTP listener with the specified |
Environment Variables for HTTPS Listener Configuration
Variable |
Definition |
|
Enables the HTTPS listener with the specified |
|
The bind address for the HTTPS listener with the specified |
|
The bind port for the HTTPS listener with the specified |
|
The keystore path for the HTTPS listener with the specified |
|
The keystore password for the HTTPS listener with the specified |
|
The private key password for the HTTPS listener with the specified |
|
The truststore path for the HTTPS listener with the specified |
|
The truststore password for the HTTPS listener with the specified |
File-based REST API Configuration
If a listener configuration for the HiveMQ Swarm REST API is not obtained from environment variables, HiveMQ Swarm looks for the configuration in the HiveMQ Swarm config.xml
configuration file.
File-based HTTP Listener Configuration
<swarm>
<rest>
<enabled>true</enabled>
<listeners>
<http>
<enabled>true</enabled>
<bindAddress>0.0.0.0</bindAddress>
<bindPort>8181</bindPort>
</http>
</listeners>
</rest>
</swarm>
File-based HTTPS Listener Configuration
<swarm>
<rest>
<enabled>true</enabled>
<listeners>
<https>
<enabled>true</enabled>
<bindAddress>0.0.0.0</bindAddress>
<bindPort>8181</bindPort>
<tls>
<keystore>
<path>/path/to/keystore.jks</path>
<password>keystorePassword</password>
<privateKeyPassword>privateKeyPassword</privateKeyPassword>
</keystore>
<truststore>
<path>/path/to/truststore.jks</path>
<password>trustStorePassword</password>
</truststore>
</tls>
</https>
</listeners>
</rest>
</swarm>
Next Steps
Familiarize yourself with the HiveMQ Swarm REST API. For more information, see HiveMQ Swarm REST API specification.