Skip to content

Commit 5b116f2

Browse files
feat: enable filelog receiver in windows if include is specified
1 parent f6c4b24 commit 5b116f2

File tree

4 files changed

+176
-0
lines changed

4 files changed

+176
-0
lines changed

internal/commands/config/config_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type snapshotTest struct {
3737
}
3838

3939
var allSnapshotTests = []snapshotTest{
40+
// Tests with full agent config
4041
{
4142
agentConfigPath: "test/snap1-full-agent-config.yaml",
4243
outputPath: "test/snap1-docker-output.yaml",
@@ -52,12 +53,18 @@ var allSnapshotTests = []snapshotTest{
5253
outputPath: "test/snap1-windows-output.yaml",
5354
packageType: Windows,
5455
},
56+
// Tests with minimal agent config
5557
{
5658
agentConfigPath: "test/snap2-empty-agent-config.yaml",
5759
otelConfigPath: "test/snap2-otel-config.yaml",
5860
outputPath: "test/snap2-with-otel-output.yaml",
5961
packageType: MacOS,
6062
},
63+
{
64+
agentConfigPath: "test/snap2-empty-agent-config.yaml",
65+
outputPath: "test/snap2-windows-output.yaml",
66+
packageType: Windows,
67+
},
6168
}
6269

6370
func Test_RenderOtelConfig(t *testing.T) {

internal/commands/config/test/snap1-windows-output.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,25 @@ receivers:
115115
line_end_pattern: ENDOFLINEPATTERN
116116
poll_interval: 5m
117117
start_at: beginning
118+
filelog/host_monitoring:
119+
exclude:
120+
- exclude1
121+
- exclude2
122+
include:
123+
- include1
124+
- include2
125+
include_file_path: true
126+
max_log_size: 4MiB
127+
operators:
128+
- expr: body matches "otel-contrib"
129+
type: filter
130+
- combine_field: body
131+
id: multiline-recombine
132+
is_first_entry: body matches "^(\\d{4}[-/]\\d{2}[-/]\\d{2} \\d{2}:\\d{2}:\\d{2}|\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z?|[A-Za-z]+ \\d{1,2} \\d{2}:\\d{2}:\\d{2})"
133+
type: recombine
134+
retry_on_failure:
135+
enabled: true
136+
storage: file_storage
118137
filestats/agent:
119138
collection_interval: 5m
120139
include: C:\Program Files\Observe\observe-agent\connections\common\base.yaml.tmpl
@@ -230,6 +249,20 @@ service:
230249
- batch
231250
receivers:
232251
- otlp
252+
logs/host_monitoring-file:
253+
exporters:
254+
- otlphttp/observe
255+
- count
256+
processors:
257+
- memory_limiter
258+
- transform/truncate
259+
- resourcedetection
260+
- resourcedetection/cloud
261+
- attributes/observe_global_attributes
262+
- resource/observe_global_resource_attributes
263+
- batch
264+
receivers:
265+
- filelog/host_monitoring
233266
logs/host_monitoring-windowsevents:
234267
exporters:
235268
- otlphttp/observe
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
connectors:
2+
count: null
3+
exporters:
4+
debug: null
5+
nop: null
6+
otlphttp/observe:
7+
compression: zstd
8+
endpoint: https://test.collect.observeinc.com/v2/otel
9+
headers:
10+
authorization: Bearer 12345678901234567890:abcdefghijklmnopqrstuvwxyzABCDEF
11+
x-observe-target-package: Host Explorer
12+
retry_on_failure:
13+
enabled: true
14+
sending_queue:
15+
num_consumers: 4
16+
queue_size: 100
17+
prometheusremotewrite/observe:
18+
endpoint: https://test.collect.observeinc.com/v1/prometheus
19+
headers:
20+
authorization: Bearer 12345678901234567890:abcdefghijklmnopqrstuvwxyzABCDEF
21+
x-observe-target-package: Host Explorer
22+
max_batch_request_parallelism: 5
23+
remote_write_queue:
24+
num_consumers: 5
25+
resource_to_telemetry_conversion:
26+
enabled: true
27+
send_metadata: true
28+
extensions:
29+
file_storage:
30+
directory: C:\ProgramData\Observe\observe-agent\filestorage
31+
processors:
32+
batch:
33+
timeout: 5s
34+
deltatocumulative: null
35+
filter/count:
36+
error_mode: ignore
37+
metrics:
38+
metric:
39+
- IsMatch(name, ".*")
40+
memory_limiter:
41+
check_interval: 1s
42+
limit_percentage: 80
43+
spike_limit_percentage: 20
44+
resourcedetection:
45+
detectors:
46+
- env
47+
- system
48+
system:
49+
hostname_sources:
50+
- os
51+
resource_attributes:
52+
host.id:
53+
enabled: true
54+
resourcedetection/cloud:
55+
detectors:
56+
- gcp
57+
- ecs
58+
- ec2
59+
- azure
60+
override: false
61+
timeout: 2s
62+
transform/truncate:
63+
log_statements:
64+
- context: log
65+
statements:
66+
- truncate_all(attributes, 4095)
67+
- truncate_all(resource.attributes, 4095)
68+
trace_statements:
69+
- context: span
70+
statements:
71+
- truncate_all(attributes, 4095)
72+
- truncate_all(resource.attributes, 4095)
73+
receivers:
74+
nop: null
75+
service:
76+
extensions:
77+
- health_check
78+
- file_storage
79+
pipelines:
80+
metrics/count-nop-in:
81+
exporters:
82+
- count
83+
receivers:
84+
- nop
85+
metrics/count-nop-out:
86+
exporters:
87+
- nop
88+
receivers:
89+
- count

packaging/windows/connections/host_monitoring/logs.yaml.tmpl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,35 @@ receivers:
1414
retry_on_failure:
1515
enabled: true
1616

17+
{{- if .HostMonitoring.Logs.Include }}
18+
filelog/host_monitoring:
19+
include:
20+
{{- range .HostMonitoring.Logs.Include }}
21+
- {{ . }}
22+
{{- end }}
23+
{{- if .HostMonitoring.Logs.Exclude }}
24+
exclude:
25+
{{- range .HostMonitoring.Logs.Exclude }}
26+
- {{ . }}
27+
{{- end }}
28+
{{- end }}
29+
include_file_path: true
30+
storage: file_storage
31+
retry_on_failure:
32+
enabled: true
33+
max_log_size: 4MiB
34+
operators:
35+
- type: filter
36+
expr: 'body matches "otel-contrib"'
37+
{{- if .HostMonitoring.Logs.AutoMultilineDetection }}
38+
- id: multiline-recombine
39+
type: recombine
40+
combine_field: body
41+
# Regex is just 3 different pattern's OR'd together to match the 4 timestamp formats `2021-03-28 13:45:30`, `2023-03-28T14:33:53.743350Z`, `Jun 14 15:16:01`, `2024/05/16 19:46:15`
42+
is_first_entry: body matches "^(\\d{4}[-/]\\d{2}[-/]\\d{2} \\d{2}:\\d{2}:\\d{2}|\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z?|[A-Za-z]+ \\d{1,2} \\d{2}:\\d{2}:\\d{2})"
43+
{{- end }}
44+
{{- end }}
45+
1746
service:
1847
pipelines:
1948
logs/host_monitoring-windowsevents:
@@ -31,3 +60,21 @@ service:
3160
{{- end }}
3261
- batch
3362
exporters: [otlphttp/observe, count]
63+
64+
{{- if .HostMonitoring.Logs.Include }}
65+
logs/host_monitoring-file:
66+
receivers: [filelog/host_monitoring]
67+
processors:
68+
- memory_limiter
69+
- transform/truncate
70+
- resourcedetection
71+
- resourcedetection/cloud
72+
{{- if .HasAttributes }}
73+
- attributes/observe_global_attributes
74+
{{- end }}
75+
{{- if .HasResourceAttributes }}
76+
- resource/observe_global_resource_attributes
77+
{{- end }}
78+
- batch
79+
exporters: [otlphttp/observe, count]
80+
{{- end }}

0 commit comments

Comments
 (0)