Metrics REST API
Description of the Sync Gateway Metrics Rest API
Use the API explorer to find out more about Sync Gateway’s endpoints by functionality.
Related REST API topics: Public REST API | Admin REST API | Use the REST API? | Monitor | Prometheus Integration
Couchbase Mobile’s API documentation utilizes Swagger UI to deliver an interactive and dynamic user experience. The page will not function correctly if your organization’s security policies restricts access to this type of content — instead see the alternate statics page Metrics REST API (Static Page)
Sync Gateway makes collecting performance data easy and secure by providing a Metrics REST API. It exposes Sync Gateway’s stats on two endpoints, which deliver the same data in one of two formats:
_metricsendpoint returns Sync Gateway statistics in Prometheus format.
For information on integration with Prometheus — see Prometheus Integration and our blog entry Monitoring Couchbase Sync Gateway with Prometheus and Grafana.
_expvarsendpoint returns Sync Gateway statistics in JSON format.
This API, separate from both the Public and Admin REST APIs, is available by default on port
4986 — see Configuration for how to change this, if needed.
To allow users to access the Metrics API up you need to create a Couchbase Server-based RBAC-user for them — see: REST API Access
The Metrics REST API is enabled by default on port 4986.
To change this you need to edit the
api.metricsInterface setting in your bootstrap configuration file and define the Sync Gateway URL and the port you want the API served on (for example: 4986) — see: Example 1.
If you are using 2.x file-based configuration then edit the
metricsInterfacesetting in the
sync-gateway-config.jsonconfiguration file — see: Legacy Pre-3.0 Configuration
Within the bootstrap configuration file:
"api.metricsInterface": "127.0.0.1:4986" (1)
Within the sync gateway configuration file:
"metricsInterface": "127.0.0.1:4986" (1)
|1||Here we define the Sync Gateway URL and the port (4986 in this instance) that we require the Metrics REST API to be served on.|
You can browse the API using the explorer below. The explorer groups all the endpoints by functionality. Just click a label to expand the endpoints. You can also generate curl requests if required, for each endpoint.