-
Notifications
You must be signed in to change notification settings - Fork 67
/
collector.yaml
295 lines (283 loc) · 10.4 KB
/
collector.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
---
apiVersion: v1
kind: ConfigMap
metadata:
name: collector-config
namespace: nr-host-monitoring
labels:
app.kubernetes.io/name: collector-config
data:
collector-config: |
receivers:
# Keep configuration in sync with: https://github.com/newrelic/opentelemetry-collector-releases/blob/main/configs/nr-otel-collector-agent-linux.yaml
hostmetrics:
root_path: /hostfs
# Default collection interval is 60s. Lower if you need finer granularity.
collection_interval: 60s
scrapers:
cpu:
metrics:
system.cpu.time:
enabled: false
system.cpu.utilization:
enabled: true
load:
memory:
metrics:
system.memory.utilization:
enabled: true
paging:
metrics:
system.paging.utilization:
enabled: false
system.paging.faults:
enabled: false
filesystem:
metrics:
system.filesystem.utilization:
enabled: true
# Reading /containers/services causes error running in docker.
# Delete for production deployments.
exclude_mount_points:
mount_points: ["/containers/services"]
match_type: strict
disk:
metrics:
system.disk.merged:
enabled: false
system.disk.pending_operations:
enabled: false
system.disk.weighted_io_time:
enabled: false
network:
metrics:
system.network.connections:
enabled: false
# Uncomment to enable process metrics, which can be noisy but valuable.
# processes:
# process:
# metrics:
# process.cpu.utilization:
# enabled: true
# process.cpu.time:
# enabled: false
# Mute various errors reading process metrics running locally in docker.
# Delete for production deployments.
# mute_process_exe_error: true
# mute_process_user_error: true
# mute_process_io_error: true
filelog:
include:
- /var/log/alternatives.log
- /var/log/cloud-init.log
- /var/log/auth.log
- /var/log/dpkg.log
- /var/log/syslog
- /var/log/messages
- /var/log/secure
- /var/log/yum.log
otlp:
protocols:
http:
grpc:
processors:
batch:
# group system.cpu metrics by cpu
metricstransform:
transforms:
- include: system.cpu.utilization
action: update
operations:
- action: aggregate_labels
label_set: [ state ]
aggregation_type: mean
- include: system.paging.operations
action: update
operations:
- action: aggregate_labels
label_set: [ direction ]
aggregation_type: sum
# remove system.cpu metrics for states
filter/exclude_cpu_utilization:
metrics:
datapoint:
- 'metric.name == "system.cpu.utilization" and attributes["state"] == "interrupt"'
- 'metric.name == "system.cpu.utilization" and attributes["state"] == "nice"'
- 'metric.name == "system.cpu.utilization" and attributes["state"] == "softirq"'
filter/exclude_memory_utilization:
metrics:
datapoint:
- 'metric.name == "system.memory.utilization" and attributes["state"] == "slab_unreclaimable"'
- 'metric.name == "system.memory.utilization" and attributes["state"] == "inactive"'
- 'metric.name == "system.memory.utilization" and attributes["state"] == "cached"'
- 'metric.name == "system.memory.utilization" and attributes["state"] == "buffered"'
- 'metric.name == "system.memory.utilization" and attributes["state"] == "slab_reclaimable"'
filter/exclude_memory_usage:
metrics:
datapoint:
- 'metric.name == "system.memory.usage" and attributes["state"] == "slab_unreclaimable"'
- 'metric.name == "system.memory.usage" and attributes["state"] == "inactive"'
filter/exclude_filesystem_utilization:
metrics:
datapoint:
- 'metric.name == "system.filesystem.utilization" and attributes["type"] == "squashfs"'
filter/exclude_filesystem_usage:
metrics:
datapoint:
- 'metric.name == "system.filesystem.usage" and attributes["type"] == "squashfs"'
- 'metric.name == "system.filesystem.usage" and attributes["state"] == "reserved"'
filter/exclude_filesystem_inodes_usage:
metrics:
datapoint:
- 'metric.name == "system.filesystem.inodes.usage" and attributes["type"] == "squashfs"'
- 'metric.name == "system.filesystem.inodes.usage" and attributes["state"] == "reserved"'
filter/exclude_system_disk:
metrics:
datapoint:
- 'metric.name == "system.disk.operations" and IsMatch(attributes["device"], "^loop.*") == true'
- 'metric.name == "system.disk.merged" and IsMatch(attributes["device"], "^loop.*") == true'
- 'metric.name == "system.disk.io" and IsMatch(attributes["device"], "^loop.*") == true'
- 'metric.name == "system.disk.io_time" and IsMatch(attributes["device"], "^loop.*") == true'
- 'metric.name == "system.disk.operation_time" and IsMatch(attributes["device"], "^loop.*") == true'
filter/exclude_system_paging:
metrics:
datapoint:
- 'metric.name == "system.paging.usage" and attributes["state"] == "cached"'
- 'metric.name == "system.paging.operations" and attributes["type"] == "cached"'
filter/exclude_network:
metrics:
datapoint:
- 'IsMatch(metric.name, "^system.network.*") == true and attributes["device"] == "lo"'
attributes/exclude_system_paging:
include:
match_type: strict
metric_names:
- system.paging.operations
actions:
- key: type
action: delete
cumulativetodelta:
transform:
metric_statements:
- context: metric
statements:
- set(description, "")
- set(unit, "")
resourcedetection:
detectors: ["env", "system"]
system:
hostname_sources: ["os"]
resource_attributes:
host.id:
enabled: true
resourcedetection/cloud:
detectors: ["gcp", "ec2", "azure"]
timeout: 2s
ec2:
resource_attributes:
host.name:
enabled: false
exporters:
debug:
verbosity: detailed
otlphttp:
endpoint: ${NEW_RELIC_OTLP_ENDPOINT}
headers:
api-key: ${NEW_RELIC_API_KEY}
service:
pipelines:
metrics/host:
receivers: [hostmetrics]
processors:
- metricstransform
- filter/exclude_cpu_utilization
- filter/exclude_memory_utilization
- filter/exclude_memory_usage
- filter/exclude_filesystem_utilization
- filter/exclude_filesystem_usage
- filter/exclude_filesystem_inodes_usage
- filter/exclude_system_disk
- filter/exclude_network
- attributes/exclude_system_paging
- transform
- resourcedetection
- resourcedetection/cloud
- cumulativetodelta
- batch
exporters: [otlphttp]
logs/host:
receivers: [filelog]
processors: [resourcedetection, resourcedetection/cloud, batch]
exporters: [otlphttp]
traces:
receivers: [otlp]
processors: [resourcedetection, resourcedetection/cloud, batch]
exporters: [otlphttp]
metrics:
receivers: [otlp]
processors: [resourcedetection, resourcedetection/cloud, batch]
exporters: [otlphttp]
logs:
receivers: [otlp]
processors: [resourcedetection, resourcedetection/cloud, batch]
exporters: [otlphttp]
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: collector
namespace: nr-host-monitoring
labels:
app.kubernetes.io/name: collector
spec:
selector:
matchLabels:
name: collector
template:
metadata:
labels:
name: collector
spec:
containers:
- name: collector
image: otel/opentelemetry-collector-contrib:0.98.0
env:
# The default US endpoint is set here. You can change the endpoint and port based on your requirements if needed.
# docs: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/best-practices/opentelemetry-otlp/#configure-endpoint-port-protocol
- name: NEW_RELIC_OTLP_ENDPOINT
value: https://otlp.nr-data.net/
# The New Relic API key used to authenticate export requests.
# Defined in secrets.yaml
- name: NEW_RELIC_API_KEY
valueFrom:
secretKeyRef:
name: nr-host-monitoring-secret
key: NEW_RELIC_API_KEY
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
# host.id is required for NewRelic host entity synthesis and relationships, but is not included by any resourcedetection detector when running with docker on macOS.
# We enabled the "env" resource detector and set host.id to the name of the node via env var.
- name: OTEL_RESOURCE_ATTRIBUTES
value: host.id=$(NODE_NAME)
volumeMounts:
- name: collector-config-vol
mountPath: /etc/otelcol-contrib
- name: hostfs
mountPath: /hostfs
readOnly: true
mountPropagation: HostToContainer
ports:
- containerPort: 4318
hostPort: 4318
volumes:
- name: collector-config-vol
configMap:
name: collector-config
items:
- key: collector-config
path: config.yaml
- name: hostfs
hostPath:
path: /