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

# OpenMetrics

> Metrics scraped from OpenMetrics and Prometheus endpoints.

The OpenMetrics integration requires CXDOT Collector 1.4.0 or greater.

[OpenMetrics](https://openmetrics.io/) defines a standard format for exposing metrics.
Use the OpenMetrics CXDOT Collector integration to collect metrics from OpenMetrics and
Prometheus endpoints running in your environment.

## Supported telemetry types

The OpenMetrics CXDOT Collector integration supports these telemetry types:

| Type | Supported |
| - | - |
| Logs | No |
| Metrics | Yes |
| Traces | No |
| Events | No |

## Prerequisites

The OpenMetrics CXDOT Collector integration has the following prerequisites:

* Make each OpenMetrics or Prometheus endpoint reachable from the CXDOT Collector.
* Identify the metric names to collect from each endpoint.

## Configure

The OpenMetrics integration is enabled by default. You can configure targets either by
annotating pods in your Kubernetes cluster or by listing static endpoints in your Helm
values. To configure the OpenMetrics CXDOT Collector integration, follow these steps:

1. To collect from app pods in Kubernetes, add a CXDOT integration annotation to the pod
   template that specifies the metrics endpoint URL and the metrics to collect. The
   annotation key must end with the container name. For example, add the following
   annotation to your workload:

   ```yaml theme={null}
   spec:
     template:
       metadata:
         annotations:
           integrations.cxdot.paloaltonetworks.com/app: |
             schema_version: v1.14
             openmetrics:
               scrape:
                 endpoints:
                   - endpoint: http://${target.host}:${target.port.metrics}/metrics
                     metrics:
                       include:
                         - requests
       spec:
         containers:
           - name: app
             image: registry.example.com/shop/api:1.4
             ports:
               - name: metrics
                 containerPort: 9090
   ```

   The Collector replaces `${target.host}` with the pod IP address and
   `${target.port.metrics}` with the container port named `metrics`.

2. Optional: To scrape specific endpoints, such as an app outside your Kubernetes
   cluster, configure static targets. For example, add the following to the
   `values.yaml` for your Helm chart:

   ```yaml theme={null}
   collection:
     cxdot:
       integrations:
         openmetrics:
           scrape:
             endpoints:
               - endpoint: http://app.example.com/metrics
                 metrics:
                   include:
                     - requests
   ```

   When `scrape.endpoints` isn't empty, this integration instance collects from exactly
   those endpoints and doesn't discover annotated targets.

3. Optional: Configure a second integration instance to collect from both annotated
   pods and static targets. For example, add the following to the `values.yaml` for
   your Helm chart:

   ```yaml theme={null}
   collection:
     cxdot:
       integrations:
         openmetrics: {}
         openmetrics/external:
           scrape:
             endpoints:
               - endpoint: http://app.example.com/metrics
                 metrics:
                   include:
                     - requests
   ```

   The `openmetrics/external` key defines a named instance for the static targets. The
   bare `openmetrics` key continues to collect from annotated pods.

For more information about how the CXDOT Collector discovers targets, see
[autodiscovery](https://docs-xcor.paloaltonetworks.com/ingest/xcor/collector/discover/kubernetes.md).

### Validate

To validate the OpenMetrics CXDOT Collector integration, follow these steps:

1. In Metrics Explorer, run the following query:

   ```text theme={null}
   {"cxdot.integration.target.health", "cxdot.integration.name"="openmetrics"}
   ```

   Confirm that each target reports `1`.

2. In the Live Telemetry Analyzer, filter for
   `cxdot.integration.name=openmetrics`. Confirm that the metric names you configured
   appear.

3. When you configured static targets, run the following query in Metrics Explorer:

   ```text theme={null}
   count by ("server.address", "server.port") ({"requests"})
   ```

   Confirm that the query returns the expected time series for each static target.

## Configuration reference

Configure one OpenMetrics integration instance with the following settings. In Helm values,
place these settings under `collection.cxdot.integrations.openmetrics`. In a Collector
configuration file, place them under `cxdot.integrations.openmetrics`.

### Optional settings

* **`enabled`**
  Type: `boolean`. Optional. Default: `true`.
  Whether to run the OpenMetrics integration. If true, the Collector collects metrics from
  configured or discovered endpoints. If false, the Collector doesn't run this integration.

* **`scrape`**
  Type: `object`. Optional.
  Settings for collecting metrics from OpenMetrics endpoints.

* **`scrape.enabled`**
  Type: `boolean`. Optional. Default: `true`.
  Whether to collect OpenMetrics metrics. If true, the Collector collects metrics from
  configured or discovered endpoints. If false, it doesn't collect OpenMetrics metrics.

* **`scrape.endpoints`**
  Type: `array of object`. Optional. Default: `[]`.
  OpenMetrics endpoints. Each entry identifies one target and the metrics to collect from it.
  When this list isn't empty, the integration collects from exactly these endpoints instead of
  endpoints found through discovery annotations.

* **`scrape.endpoints[].endpoint`**
  Type: `string`. Required.
  Full URL of the metrics endpoint, for example `https://app.svc:9090/metrics?format=text`.
  Metric collection uses the path and query exactly as given.

* **`scrape.endpoints[].namespace`**
  Type: `string`. Optional. Default: empty string.
  A name recorded on every time series from this endpoint, as the `cxdot.openmetrics.namespace`
  resource attribute. Metric names stay exactly as the target exposes them, so this groups an
  endpoint's telemetry without changing what its metrics are called.

* **`scrape.endpoints[].service`**
  Type: `string`. Optional. Default: empty string.
  Overrides the `service.name` resource attribute for this endpoint.

* **`scrape.endpoints[].metrics`**
  Type: `object`. Required.
  Which metrics to collect, and how to reshape them.

* **`scrape.endpoints[].metrics.include`**
  Type: `array of string`. Required. Minimum items: `1`.
  Target metrics to collect. The integration always collects its health and collection status
  metrics. Each entry is a regular expression matched against the metric name. Type suffixes are
  not part of the name: a counter exposed as `requests_total` is collected as `requests`,
  because OpenMetrics calls that family `requests` and carries the type separately. To collect
  every target metric, use `".*"`.

* **`scrape.endpoints[].metrics.exclude`**
  Type: `array of string`. Optional. Default: `[]`.
  Target metrics to exclude from the metrics selected by `include`. Each entry is a regular
  expression matched against the metric name. Health and collection status metrics aren't
  excluded.

* **`scrape.endpoints[].metrics.rename`**
  Type: `object`. Optional. Default: `{}`.
  Metric renames, as `{old: new}`. Only an exact name can be renamed. The integration ignores a
  rename whose key is a regular expression.

* **`scrape.endpoints[].metrics.types`**
  Type: `object`. Optional. Default: `{}`.
  Metric type overrides, as `{name: counter}`. Keys are exact metric names or regular
  expressions. Values are `counter` or `gauge`. A metric without a declared type is otherwise
  read as a gauge.

* **`scrape.endpoints[].metrics.strip_prefix`**
  Type: `string`. Optional. Default: empty string.
  A prefix removed from every metric name during collection. Removed first, so every other
  option here, `include` included, refers to the shortened name.

* **`scrape.endpoints[].labels`**
  Type: `object`. Optional.
  Settings for renaming labels and dropping samples.

* **`scrape.endpoints[].labels.rename`**
  Type: `object`. Optional. Default: `{}`.
  Label renames, as `{old: new}`. A rename changes the label name without removing the label, so
  distinct time series remain distinct. Renaming a label to a name the time series already has
  overwrites that label's value.

* **`scrape.endpoints[].labels.sample_drop_rules`**
  Type: `object`. Optional. Default: `{}`.
  Drops a whole sample when one of its labels matches. Each key is a label name. The value is a
  list of regular expressions matched against the label's value. To drop every sample the label
  appears on with a non-empty value, use `".+"`.

* **`scrape.endpoints[].tags`**
  Type: `array of string`. Optional. Default: `[]`.
  Extra resource attributes in `key:value` format to add to every time series from this
  endpoint. The integration ignores an entry without a colon.

* **`scrape.endpoints[].interval`**
  Type: `duration`. Optional. Default: `15s`.
  Time between metric collections from this endpoint.

* **`scrape.endpoints[].timeout`**
  Type: `duration`. Optional. Default: `10s`.
  Maximum time to wait for each metric collection.

* **`scrape.endpoints[].max_samples`**
  Type: `integer`. Optional. Default: `0`.
  Maximum number of samples accepted from one metric collection. A value of `0`, the default,
  means no limit. A collection that exceeds the limit fails and reports `up` as `0` instead of
  returning an incomplete set of samples.

* **`scrape.endpoints[].follow_redirects`**
  Type: `boolean`. Optional. Default: `true`.
  Whether to follow HTTP redirects. If true, the Collector follows redirects. If false, a
  redirect causes the metric collection to fail.


## Related topics

- [Prometheus and OpenMetrics ingestion](https://docs-xcor.paloaltonetworks.com/ingest/metrics-traces/collector/addl-metrics/prom-openmetrics.md)
- [Ingest metrics and traces using the OpenTelemetry Collector](https://docs-xcor.paloaltonetworks.com/ingest/metrics-traces/otel.md)
- [Ingest additional metrics](https://docs-xcor.paloaltonetworks.com/ingest/metrics-traces/collector/addl-metrics.md)
- [Concourse CI](https://docs-xcor.paloaltonetworks.com/ingest/xcor/integrations/collector/concourse_ci.md)
- [Classic Metrics Explorer](https://docs-xcor.paloaltonetworks.com/investigate/querying/metrics/explorer-classic.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.