-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpod-annotation-scraping.yaml
More file actions
65 lines (64 loc) · 2.35 KB
/
Copy pathpod-annotation-scraping.yaml
File metadata and controls
65 lines (64 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Kubernetes Pod Annotation Scraping Config
# Scrapes metrics from pods with prometheus.io/scrape: 'true' annotation
# Deploy with: kubectl apply -f pod-annotation-scraping.yaml
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
name: otel-collector-annotation-scraper
spec:
mode: daemonset
config:
receivers:
prometheus:
config:
scrape_configs:
- job_name: 'kubernetes-pods'
scrape_interval: 30s
kubernetes_sd_configs:
- role: pod
relabel_configs:
# Only scrape pods with annotation prometheus.io/scrape: 'true'
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
# Use custom port from prometheus.io/port annotation
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
target_label: __address__
regex: (\d+)
replacement: '${__address__}:'
# Use custom path from prometheus.io/path annotation
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
# Add pod name as label
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: pod
# Add namespace as label
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: namespace
# Add node name as label
- source_labels: [__meta_kubernetes_pod_node_name]
action: replace
target_label: node
processors:
batch:
memory_limiter:
check_interval: 1s
limit_percentage: 75
spike_limit_percentage: 15
exporters:
debug:
verbosity: detailed
# Uncomment to export to Prometheus:
# prometheusremotewrite:
# endpoint: http://prometheus:9090/api/v1/write
service:
pipelines:
metrics:
receivers: [prometheus]
processors: [memory_limiter, batch]
exporters: [debug]