/
prometheus-daemonset.yaml
202 lines (194 loc) · 5.1 KB
/
prometheus-daemonset.yaml
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
---
# create adot-col namespace
apiVersion: v1
kind: Namespace
metadata:
name: adot-col
labels:
name: adot-col
---
apiVersion: v1
kind: ConfigMap
metadata:
name: adot-collector-conf
namespace: adot-col
labels:
app: aws-adot
component: adot-collector-conf
data:
adot-collector-config: |
receivers:
prometheus:
config:
global:
external_labels:
cluster_id: YOUR_CLUSTER_NAME_HERE
scrape_interval: 60s
scrape_timeout: 50s
scrape_configs:
- job_name: kubecost-amp
honor_labels: true
dns_sd_configs:
- names:
- YOUR_NAMESPACE-cost-analyzer.YOUR_NAMESPACE
type: 'A'
port: 9003
# optionally add kubecost network costs scrape job:
- job_name: kubecost-networking
kubernetes_sd_configs:
- role: pod
relabel_configs:
# Scrape only the the targets matching the following metadata
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_instance]
action: keep
regex: kubecost
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_name]
action: keep
regex: network-costs
- job_name: kubernetes-nodes-cadvisor
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- replacement: kubernetes.default.svc:443
target_label: __address__
- regex: (.+)
replacement: /api/v1/nodes/$$1/proxy/metrics/cadvisor
source_labels:
- __meta_kubernetes_node_name
target_label: __metrics_path__
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
insecure_skip_verify: true
exporters:
prometheusremotewrite:
# replace this with your endpoint
endpoint: "https://aps-workspaces.YOUR_REGION.amazonaws.com/workspaces/ws-YOUR_WORKSPACE/api/v1/remote_write"
auth:
authenticator: sigv4auth
logging:
loglevel: debug
extensions:
health_check:
pprof:
endpoint: :1888
zpages:
endpoint: :55679
# replace this with your region
sigv4auth:
region: "YOUR_REGION"
service:
extensions: [pprof, zpages, health_check, sigv4auth]
pipelines:
metrics:
receivers: [prometheus]
exporters: [logging, prometheusremotewrite]
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: adotcol-admin-role
rules:
- apiGroups: [""]
resources:
- nodes
- nodes/proxy
- services
- endpoints
- pods
verbs: ["get", "list", "watch"]
- apiGroups:
- extensions
resources:
- ingresses
verbs: ["get", "list", "watch"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: adotcol-admin-role-binding
subjects:
- kind: ServiceAccount
name: adot-sa
namespace: adot-col
roleRef:
kind: ClusterRole
name: adotcol-admin-role
apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: Service
metadata:
name: adot-collector
namespace: adot-col
labels:
app: aws-adot
component: adot-collector
spec:
ports:
- name: metrics # Default endpoint for querying metrics.
port: 8888
selector:
component: adot-collector
type: NodePort
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: adot-collector
namespace: adot-col
labels:
app: aws-adot
component: adot-collector
spec:
selector:
matchLabels:
app: aws-adot
component: adot-collector
minReadySeconds: 5
template:
metadata:
labels:
app: aws-adot
component: adot-collector
spec:
serviceAccountName: adot-sa
containers:
- command:
- "/awscollector"
- "--config=/conf/adot-collector-config.yaml"
image: public.ecr.aws/aws-observability/aws-otel-collector:latest
name: adot-collector
resources:
limits:
cpu: 1
memory: 2Gi
requests:
cpu: 200m
memory: 400Mi
ports:
- containerPort: 8888 # Default endpoint for querying metrics.
volumeMounts:
- name: adot-collector-config-vol
mountPath: /conf
livenessProbe:
httpGet:
path: /
port: 13133 # Health Check extension default port.
readinessProbe:
httpGet:
path: /
port: 13133 # Health Check extension default port.
volumes:
- configMap:
name: adot-collector-conf
items:
- key: adot-collector-config
path: adot-collector-config.yaml
name: adot-collector-config-vol
---