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

# Prometheus and OpenMetrics ingestion

You can configure the Collector to accept text-exposition payloads in either
Prometheus or OpenMetrics formats.

To enable the Prometheus and OpenMetrics ingestion for the Collector, add
`importPrometheus` and `importOpenMetrics` under the `push` YAML collection in the
Collector configuration:

```yaml theme={null}
push:
  importPrometheus:
    enabled: true
  importOpenMetrics:
    enabled: true
```

Traffic is served from `/import/openmetrics` and `/import/prometheus` from the
`listenAddress`, which defaults to `0.0.0.0:3030`.

```shell theme={null}
# Importing an untyped metric in OpenMetrics format.
curl -d $'test_metric_import 100\n# EOF' -X POST http://localhost:3030/import/openmetrics
# Same import, but in Prometheus format.
curl -d 'test_metric_import 100' -X POST http://localhost:3030/import/prometheus
```

Additional query parameters:

* `extra_label`: pass in repeated, default labels for all time series, formatted as
  `name=value`.
* `default_timestamp`: provide a default timestamp in Unix milliseconds for
  any time series that doesn't have one. Otherwise, the value defaults to `Now()` on
  the Chronosphere backend.

The following command includes both of these additional query parameters:

```shell theme={null}
curl -d 'test_metric_import 100' -X POST \
    http://localhost:3030/import/prometheus?extra_label=svc%3Dauth&extra_label=team%3Dbar&default_timestamp=1669701600
```

## Export Prometheus assets

You can use [Chronoctl](/tooling/chronoctl) to sync Prometheus rule definitions and
Alertmanager configuration into Observability Platform over the Chronosphere API.

<Note>
  You need Chronoctl installed and configured. Read the
  [Chronoctl documentation](/tooling/chronoctl) for more details.
</Note>

For example, to export rules from a Prometheus Operator cluster and sync them:

1. In your Prometheus installation, retrieve your Prometheus rules into a YAML file:

   ```shell theme={null}
   kubectl get prometheusrules -o yaml -A > prometheus_rules.yml
   ```

2. Gather the Alertmanager configuration you want evaluated with those rules (for
   example, your existing `alertmanager.yml`).

3. Run `chronoctl sync prometheus`. You must pass both Prometheus rules and
   Alertmanager YAML (`-p` and `-a`):

   ```shell theme={null}
   chronoctl sync prometheus -p prometheus_rules.yml -a alertmanager.yml
   ```

   Chronoctl prints a changelog of changes applied in Observability Platform. To
   preview changes without writing them, add `--dry-run`.

   To control how rules map to teams and collections, pass a Chronosphere mapping
   file with `-c`:

   ```shell theme={null}
   chronoctl sync prometheus -p prometheus_rules.yml -a alertmanager.yml -c chronoconfig.yml
   ```

For flags and output formats, run `chronoctl sync prometheus --help` or see the
[Chronoctl documentation](/tooling/chronoctl).
