> ## Documentation Index
> Fetch the complete documentation index at: https://mw-docs.middleware.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Prometheus & Kubernetes

> Prometheus & Kubernetes Integration - Setup & Installation Docs | Middleware

Retrieve metrics from a Prometheus endpoint inside K8s.

## Add Middleware Prometheus Integration as a sidecar container

<Note> We are currently updating this feature. If you have any issues configuring this integration, please contast us at support\[at]middleware.io </Note>

To scrape the prometheus endpoint via Middleware Agent, You will have to add this `sidecar container` in your pod:

```yaml theme={null}
- 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: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # Middleware API Key
  - name: PROMETHEUS_SCRAPE_CONFIG
    value: job1@0.0.0.0:8889,job2@0.0.0.0:8890
```

### Understanding Environment Variables

**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://xxxxx.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 : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`

**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 : job1@0.0.0.0:8889,job2@0.0.0.0:8890`

## Visualize Your Prometheus Metrics

You can now access this metrics data under our Dashboard builder
`https://app.middleware.io/reports`

1. Create a new report
2. 'Add New Widget' in the report.
3. Select "prometheus" under the "Data Source" dropdown as shown in the screenshot below. You will be able to see a list of your metrics.

<img src="https://mintcdn.com/middlewareio/cgLzouXcJUXtP_sv/images/integration/prometheus-k8s.png?fit=max&auto=format&n=cgLzouXcJUXtP_sv&q=85&s=ca9b3aebd12226f02ccfd1a280324649" width="1819" height="916" data-path="images/integration/prometheus-k8s.png" />

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

# Troubleshooting

<Accordion title="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.
</Accordion>

# Next Steps

* [How to Create Alerts](https://docs.middleware.io/workflow/alerting/setup-alert)
* [Dashboard Basics & Customization](https://docs.middleware.io/workflow/custom-dashboard/dashboard-builder-overview)
* [Custom Telemetry Ingestion](https://docs.middleware.io/open-telemetry/otel-getting-started)
* [Getting Started With Real User Monitoring (RUM)](https://docs.middleware.io/rum/rum-overview)
* [Data Ingestion APIs](https://docs.middleware.io/data-ingestion-apis/opentelemetry-metrics)
* [Configure OTel Collector Contrib](https://docs.middleware.io/open-telemetry/otel-collector)

<Note> Need assistance or want to learn more about Middleware? Contact us at support\[at]middleware.io. </Note>
