# Metric Collection

Metric Collection is the process of scraping metrics from applications running in Kubernetes pods using Prometheus.

## Collecting container metrics based on pod annotations

&#x20;Kubernetes Pod Annotations are used to mark pods as targets for metric collection. Set the value to true to enable metric scraping for containers inside the pod. You can add the following annotation:

```yaml
prometheus.io/scrape: "true" 
prometheus.io/port: "8000"
prometheus.io/path: /metrics
```

There are two ways to enable metric collection:

### &#x20;1. Through pod definition

Annotate workloads (e.g., Deployment) to enable metric collection:

```yaml
spec:
 template:
  metadata:
    annotations:
      prometheus.io/scrape: "true" 
      prometheus.io/port: "8000"
      prometheus.io/path: /metrics
```

### 2. Through running pods

This is a temporary method that works on running pods. The annotation will be reverted after the pod is rolled out or restarted.

```bash
kubectl -n <namespace> annotate pod <pod_name> prometheus.io/scrape="true" 
kubectl -n <namespace> annotate pod <pod_name> prometheus.io/port="8080"
kubectl -n <namespace> annotate pod <pod_name> prometheus.io/path="/metrics"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.cloudeka.ai/guidance-for-individual/deka-gpu/deka-gpu-metric-collection/metric-collection.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.
