Prometheus & Kubernetes

Retrieve metrics from a Prometheus endpoint inside K8s.

Add Prometheus Integration from Middleware K8s Agent

If you are already using Middleware Kubernetes Agent then you can easily enable prometheus scraping from Middleware UI.

Step 1: Navigate to Prometheus Integration

Go to Installation > Integration > Prometheus > Kubernetes Agent as shown in the image

Prometheus K8s Integration

Step 2: Select the Cluster

Click on the "Add Cluster" button, which will open a dropdown of available clusters and select the Cluster where you want to enable Prometheus Scraping

Prometheus K8s Integration

Step 3: Enable Annotation Based Scraping

Check the box next to Enable Annotation Based Scraping and then click Save to apply the settings.

Prometheus K8s Integration

Step 4: Configuring the Target Services

Now all services that are exposing prometheus metrics will be scraped.

To confirm, check that the target services have these 3 annotations in place.

The port and path values may be different for different services.

Prometheus as a Sidecar Container

We are currently updating this feature. If you have any issues configuring this integration, please contact us at support[at]middleware.io

To scrape the prometheus endpoint using a sidecar, you will need to add sidecar container in your pod:

Environment Variables

If you are logged in to the docs both MW_TARGET and MW_API_KEY will be populated with your details.

MW_TARGET: Specifies the target URL for the Middleware service. This URL defines the endpoint where your application should interact with the middleware.

MW_API_KEY: Provides the API key required for authenticating with the Middleware service. Ensure the key is kept confidential and only shared with authorized users or services.

PROMETHEUS_SCRAPE_CONFIG: Configures Prometheus scraping targets. This variable should be set in the format 'job@address:port', where 'job' represents the scraping job name, 'address' is the IP address or hostname, and 'port' is the port to scrape metrics from.

Visualize Your Prometheus Metrics

You can now access this metrics data under our Dashboard builder

  1. Create a new report
  2. Add New Widget
  3. Select prometheus under the Data Source dropdown to see all metrics, as shown in the screenshot below.

These metrics can be visualized using various widget types, such as Timeseries, Bar Chart, Pie Chart, and more.

Troubleshooting

Missing Integrations Menu

If you do not see the Integrations Menu in Middlware, that means your account has not been granted Installation permissions. Contact your system administrator to add the Installation permission to your user role in Settings.

Next Steps

Need assistance or want to learn more about Middleware? Contact our support team in Slack.