Membrane allows the observation of APIs traffic and other key metrics via Prometheus and Grafana.
The Prometheus plugin provides an HTTP endpoint that exposes the metrics.
Membrane supports monitoring through the integration with Prometheus.
To monitor APIs using Prometheus and Grafana, follow the steps below:
-
Start a setup of Membrane, Prometheus and Grafana with Docker Compose:
docker compose up
-
Access the following endpoints to generate traffic:
- localhost:2001 - Returns a status code of 200.
- localhost:2002 - Returns a status code of 404.
- localhost:2003 - Returns a status code of 500.
You can use cURL commands to access these endpoints, e.g.:
curl -v http://localhost:2001 curl -v http://localhost:2002 curl -v http://localhost:2003
-
Then, query the metrics endpoint of Membrane
- Open Prometheus at http://localhost:9090
- Search for
membrane_count.
- Access localhost:3000 in your browser.
- Log in with the default credentials: username
adminand passwordadmin. (When prompted to change the password, pressskip.) - Click on
Dashboardsfrom the left-hand menu. - Click on
Newand selectImport. - Navigate to the
dashboardsdirectory in this folder and pick a dashboard JSON file.
full.jsondisplays nearly all available metrics.openapi.jsondisplays OpenAPI validation metrics. This requires the OpenAPI plugin to be active in an API.minimal.jsonis pictured below:
HOW IT IS DONE
Take a look at the proxies.xml.
<router>
<api port="2000">
<path>/metrics</path>
<prometheus />
</api>
<api port="2001">
<return statusCode="200"/>
</api>
<api port="2002">
<return statusCode="404"/>
</api>
<api port="2003">
<return statusCode="500"/>
</api>
</router>The <prometheus /> tag configures the specified API endpoint for data collection by Prometheus.
