Skip to content

Latest commit

 

History

History
 
 

prometheus

Monitoring with Prometheus and Grafana

Membrane supports monitoring through the integration with Prometheus.

With the Prometheus plugin, Membrane enables the observation of APIs. It gathers metrics about the processes passing through it and makes them available for scraping by Prometheus. This data can then be used for monitoring and alerting purposes.

To enable monitoring for an API, simply add the Prometheus plugin to it.

Run the Example

To monitor APIs using Prometheus and Grafana, follow the steps below:

Providing a Metrics Endpoint for Prometheus

  1. Start the example environment with Docker Compose:

    docker-compose up
  2. Access the following endpoints:

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
  1. Then, query the metrics endpoint of Membrane

Quering Prometheus

  1. Open Prometheus at http://localhost:9090
  2. Search for membrane_count

Grafana

  1. Proceed to Grafana:
  • Access localhost:3000 in your browser.
  • Log in with the default credentials: username admin and password admin.
  • Click on "Explore" from the left-hand menu.
  • You can now select different queries to display the collected metrics.

Grafana example

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.