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

# Prometheus Integration

> How to send Prometheus metrics to Metoro

There are two ways to send Prometheus metrics to Metoro.

<Note>
  This page covers sending Prometheus metrics into Metoro. To query metrics with PromQL inside Metoro dashboards, see [PromQL](/docs/metrics/promql).
</Note>

<Tip>
  If your workloads already use Prometheus Operator `ServiceMonitor` or `PodMonitor` resources, use Metoro's built-in [ServiceMonitor scraping](/docs/metrics/servicemonitors). The Metoro Helm chart deploys the collector and Target Allocator for you.
</Tip>

## 1. OpenTelemetry Collector (Recommended)

The recommended approach is to use the OpenTelemetry Collector to scrape and forward Prometheus metrics to the exporter. This method preserves metric type information better than Prometheus Remote Write due to the more sophisticated type system in OpenTelemetry.

Here's an example configuration for the OpenTelemetry Collector:

```yaml theme={null}
apiVersion: v1
kind: ConfigMap
metadata:
  name: otel-collector-config
data:
  collector-config.yaml: |
    receivers:
      prometheus:
        config:
          scrape_configs:
            - job_name: 'prometheus-federate'
              scrape_interval: 60s
              metrics_path: /federate
              params:
                match[]:
                  - '{job=~".+"}'
              static_configs:
                - targets: ['PROMETHEUS_TO_SCRAPE_URL:9090']

#  Uncomment this to rename the metrics to include the company name so it's easier to identify in Metoro vs the inbuilt metrics
#    processors:
#      metricstransform:
#        transforms:
#          - include: '(.*)'
#            match_type: regexp
#            action: update
#            new_name: 'COMPANY_NAME_$1'
#      batch: {}
      
    exporters:
      otlphttp:
        endpoint: "http://metoro-exporter.metoro.svc.cluster.local/api/v1/custom/otel"
        tls:
          # Disable TLS for in-cluster communication, this is safe because the endpoint is internal to the cluster, when data is sent from the exporter out, it is encrypted
          insecure: true
        encoding: json

    service:
      pipelines:
        metrics:
          receivers: [prometheus]
          processors: [metricstransform, batch]
          exporters: [otlphttp]
```

This configuration:

1. Sets up a Prometheus receiver to scrape metrics from your Prometheus instance
2. Processes the metrics through a transformation pipeline
3. Exports them to Metoro using the OTLP protocol

A full example can be seen [here](https://github.com/metoro-io/metoro_examples/tree/main/metrics/otel-collector)

## 2. Prometheus Remote Write

<Alert>
  This method is not recommended as it may not preserve all metric type information due to limitations in the Prometheus Remote Write protocol. You may see that some metrics end up as gauges instead of counters, histograms or summaries.
</Alert>

If you are unable to use the OpenTelemetry Collector, you can configure Prometheus to directly send metrics to Metoro using Remote Write. While this method is simpler to set up, it may not preserve all metric type information due to limitations in the Prometheus Remote Write protocol.

Add the following to your Prometheus configuration:

```yaml theme={null}
# The rest of your configuration here

remote_write:
  - url: "http://metoro-exporter.metoro.svc.cluster.local/api/v1/send/prometheus/remote_write"
```

This configuration will send all scraped metrics directly to the exporter from your Prometheus instance using Prometheus Remote Write.

A full example can be seen [here](https://github.com/metoro-io/metoro_examples/tree/main/metrics/prometheus-remote-write)
