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
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
Step 3: Enable Annotation Based Scraping
Check the box next to Enable Annotation Based Scraping and then click Save to apply the settings.
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.
prometheus.io/scrape: "true" prometheus.io/port: "8080" prometheus.io/path: "/metrics"
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:
- name: middleware-prometheus-agent image: ghcr.io/middleware-labs/mw-kube-agent:prometheus-integration imagePullPolicy: Always env: - name: MW_TARGET value: https://xxxxx.middleware.io:443 # Middleware Target URL - name: MW_API_KEY value: "<MW_API_KEY>" # Middleware API Key - name: PROMETHEUS_SCRAPE_CONFIG value: [email protected]:8889,[email protected]:8890
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.
Example Value: https://<MW_UID>.middleware.io:443
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.
Example Value: "<MW_API_KEY>"
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.
Example Value: [email protected]:8889,[email protected]:8890
Visualize Your Prometheus Metrics
You can now access this metrics data under our Dashboard builder
https://app.middleware.io/reports
- Create a new report
- Add New Widget
- 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
- How to Create Alerts
- Dashboard Basics & Customization
- Custom Telemetry Ingestion
- Getting Started With Real User Monitoring (RUM)
- Data Ingestion APIs
Need assistance or want to learn more about Middleware? Contact our support team in Slack.