Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pages/cockpit/how-to/send-metrics-from-k8s-to-cockpit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ alloy-singleton:

## Add annotations for auto-discovery

Annotations in Kubernetes provide a way to attach metadata to your resources. For `k8s-monitoring`, these annotations signal which Pods should be scraped for metrics, and what port to use. In this documentation we are adding annotations to specify we want `k8s-monitoring` to scrape the Pods from our deployment. Make sure that you replace `$METRICS_PORT` with the port where your application exposes Prometheus metrics.
Annotations in Kubernetes provide a way to attach metadata to your resources. For `k8s-monitoring`, these annotations signal which Pods should be scraped for metrics, and what port to use. These annotations have to be on the Pods that the deployement will spawn so they have to be in the Pod template, not the deployement itself.
In this documentation we are adding annotations to specify we want `k8s-monitoring` to scrape the Pods from our deployment. Make sure that you replace `$METRICS_PORT` with the port where your application exposes Prometheus metrics.

### Kubernetes deployment template

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
...
annotations:
"k8s.grafana.com/metrics.portNumber" = "$METRICS_PORT"
"k8s.grafana.com/scrape" = "true"
spec:
...
template:
metadata:
annotations:
"k8s.grafana.com/metrics.portNumber" = "$METRICS_PORT"
"k8s.grafana.com/scrape" = "true"
```

### Terraform/OpenTofu deployment template
Expand Down Expand Up @@ -173,4 +173,4 @@ Now that your metrics are exported to your Cockpit, you can access and query the
6. In the **Labels filter** drop-down, select the `cluster` label and in the **Value** drop-down, select your cluster.
7. Optionally, click the **Clock** icon on the top right corner of your screen and filter by time range.
8. Click **Run query** to see your metrics. An output similar to the following should display.
<Lightbox image={image} alt="" />
<Lightbox image={image} alt="" />
Loading