-
Notifications
You must be signed in to change notification settings - Fork 6
/
1.vmagent.yaml
206 lines (202 loc) · 5.23 KB
/
1.vmagent.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
203
204
205
206
apiVersion: v1
kind: ServiceAccount
metadata:
name: vmagent
namespace: monit
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: vmagent
rules:
- apiGroups: ["", "networking.k8s.io", "extensions"]
resources:
- nodes
- nodes/metrics
- nodes/proxy
- services
- endpoints
- endpointslices
- pods
- app
- ingresses
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources:
- namespaces
- configmaps
verbs: ["get"]
- nonResourceURLs: ["/metrics", "/metrics/resources"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: vmagent
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: vmagent
subjects:
- kind: ServiceAccount
name: vmagent
namespace: monit
---
# vmagent-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: vmagent-config
namespace: monit
data:
scrape.yml: |
global:
scrape_interval: 30s
scrape_timeout: 30s
external_labels:
origin_prometheus: prom-master
scrape_configs:
- job_name: 'vmagent'
static_configs:
- targets: ['localhost:8429']
- job_name: 'vmalert'
static_configs:
- targets: ['vmalert.monit:8080']
- job_name: 'alertmanager'
static_configs:
- targets: ['alertmanager.monit:9093']
- job_name: 'victoria-metrics'
static_configs:
- targets: ['victoria-metrics.monit:8428']
basic_auth:
username: ops
password: wEFHr41Pa
- job_name: 'grafana'
static_configs:
- targets: ['grafana.monit:3000']
- job_name: 'k8s-node-exporter'
kubernetes_sd_configs:
- role: node
relabel_configs:
- source_labels: [__address__]
regex: '(.*):10250'
replacement: '${1}:9100'
target_label: __address__
action: replace
- action: replace
regex: (.*)
replacement: $1
source_labels: [__meta_kubernetes_node_name]
target_label: kubernetes_node
- job_name: 'k8s-kubelet'
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- target_label: __address__
replacement: kubernetes.default.svc:443
- source_labels: [__meta_kubernetes_node_name]
regex: (.+)
target_label: __metrics_path__
replacement: /api/v1/nodes/${1}/proxy/metrics
- job_name: 'k8s-cadvisor'
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- target_label: __address__
replacement: kubernetes.default.svc:443
- source_labels: [__meta_kubernetes_node_name]
regex: (.+)
target_label: __metrics_path__
replacement: /api/v1/nodes/${1}/proxy/metrics/cadvisor
metric_relabel_configs:
- source_labels: [instance]
separator: ;
regex: (.+)
target_label: node
replacement: $1
action: replace
- job_name: 'kube-state-metrics'
kubernetes_sd_configs:
- role: endpoints
namespaces:
names:
- monit
relabel_configs:
- source_labels: [__meta_kubernetes_service_label_app_kubernetes_io_name]
regex: kube-state-metrics
replacement: $1
action: keep
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: vmagent
namespace: monit
labels:
app: vmagent
spec:
selector:
matchLabels:
app: vmagent
template:
metadata:
labels:
app: vmagent
spec:
serviceAccountName: vmagent
containers:
- name: vmagent
image: "victoriametrics/vmagent:latest"
imagePullPolicy: IfNotPresent
args:
- -promscrape.config=/config/scrape.yml
- -remoteWrite.url=http://ops:[email protected]:8428/api/v1/write
- -promscrape.maxScrapeSize=500MB
- -remoteWrite.disableOnDiskQueue
- -loggerTimezone=Asia/Shanghai
#- -remoteWrite.dropSamplesOnOverload
env:
- name: TZ
value: Asia/Shanghai
ports:
- name: http
containerPort: 8429
volumeMounts:
- name: config
mountPath: /config
resources:
limits:
cpu: '2'
memory: 2Gi
requests:
cpu: 100m
memory: 256Mi
volumes:
- name: config
configMap:
name: vmagent-config
---
apiVersion: v1
kind: Service
metadata:
name: vmagent
namespace: monit
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8429"
spec:
selector:
app: vmagent
ports:
- name: http
port: 8429
targetPort: http
type: NodePort