# Kubernetes Prometheus Node

### Supported Platforms

| Platform              | Metrics | Logs | Traces |
| --------------------- | ------- | ---- | ------ |
| Kubernetes DaemonSet  | ✓       |      |        |
| OpenShift 4 DaemonSet | ✓       |      |        |

### Configuration Table

<table><thead><tr><th width="224.0390625">Field</th><th>Description</th></tr></thead><tbody><tr><td>Cluster Name*</td><td>The cluster name that will be added as the <code>k8s.cluster.name</code> resource attribute.</td></tr><tr><td>Relabel Configs</td><td>Enable or disable relabel configurations. See <a href="#relabel-configs">Relabel Configs</a>.</td></tr><tr><td>Scrapers</td><td>Enable or disable HTTP and HTTPS scrapers.</td></tr><tr><td>Collection Interval</td><td>Sets how often (seconds) to scrape for metrics.</td></tr><tr><td>Skip TLS Certificate Verification</td><td>Enable to skip TLS certificate verification.</td></tr><tr><td>TLS Certificate Authority File</td><td>Certificate authority used to validate the exporters TLS certificate. See <a href="#transport-layer-security">Transport Layer Security</a>.</td></tr><tr><td>TLS Client Certificate File</td><td>A TLS certificate used for client authentication if mutual TLS is enabled. See <a href="#transport-layer-security">Transport Layer Security</a>.</td></tr><tr><td>TLS Client Private Key File</td><td>A TLS private key used for client authentication if mutual TLS is enabled. See <a href="#transport-layer-security">Transport Layer Security</a>.</td></tr></tbody></table>

<mark style="color:red;">\*</mark>*<mark style="color:red;">required field</mark>*

#### Relabel Configs

Relabel configs are used to control how detected pods are scraped. There are four options.

**prometheus.io/scrape**

When enabled, only pods with the `prometheus.io/scrape: "true"` annotation will be considered for scraping. This option is enabled by default, to prevent the receiver from scraping all pods.

**prometheus.io/path**

The default HTTP path is `/metrics`. The path can be overridden by enabling this option and configuring the `prometheus.io/path` annotation.

**prometheus.io/scheme**

When this option is enabled, the HTTP scraper (configured with the "Scrapers" option) will only scrape pods that have the `prometheus.io/scheme: "http"` annotation set. Similarly, the HTTPS scraper will only scrape pods that have the `prometheus.io/scheme: "https"` annotation set.

This option is recommended when using both HTTP and HTTPS scrapers.

**prometheus.io/job-name**

When this option is enabled, the `service.name` resource attribute will be set to the value of the\
pod annotation `prometheus.io/job-name`. This allows you to dynamically set `service.name`, which defaults to `kubernetes-pod-http` and `kubernetes-pod-https`, depending on which scraper is in use.

**Example Configuration**

When using Relabel configs, make sure to annotate your pods. Pod annotations are set at `spec.template.metadata.annotations`, not to be confused with `metadata.annotations`.

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2
  template:
    metadata:
      annotations:
+       prometheus.io/path: /metrics
+       prometheus.io/port: '9113'
+       prometheus.io/scrape: 'true'
+       prometheus.io/scheme: http
+       prometheus.io/job-name: nginx
```

{% hint style="info" %}
**NOTE**

Updating pod annotations will cause your pods to be re-deployed.
{% endhint %}

#### Transport Layer Security

When using TLS, if you need to configure a TLS certificate authority or a client key pair, update\
your Bindplane Collector YAML manifest to include a `volumeMount` that will mount your TLS files\
into the container.

You can find documentation for mounting secrets into a container [here](https://kubernetes.io/docs/concepts/configuration/secret/).

### Example Configuration

By default, the Prometheus source is configured to use the HTTP scraper and the `prometheus.io/scrape`relabel config is enabled. This means the receiver will only scrape pods that have `prometheus.io/scrape: "true"`set in their annotations.

A cluster name is required, and will be set as `k8s.cluster.name`. You can use a placeholder value if you intend to use [Resource Detection](https://docs.bindplane.com/integrations/processors/resource-detection) or [Add Fields](https://docs.bindplane.com/integrations/processors/add-fields) processors. See [Dynamic Cluster Name](https://docs.bindplane.com/integrations/sources/broken-reference) for more details.

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-55091859e88f69def5bd2b077fe0d7062776b18e%2Fintegrations-sources-kubernetes-prometheus-node-image-1.png?alt=media" alt="Bindplane docs - Kubernetes Prometheus Node - image 1"><figcaption></figcaption></figure>

Once running on a collector, some notable resource attributes are:

* k8s.cluster.name
* k8s.node.name
* k8s.container.name
* k8s.pod.name
* service.name: The name Prometheus job name

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-811ee7a4749bcb86d06b492eff2c1fc5c172833b%2Fintegrations-sources-kubernetes-prometheus-node-image-2.png?alt=media" alt="Bindplane docs - Kubernetes Prometheus Node - image 2"><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bindplane.com/integrations/sources/kubernetes-prometheus-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
