Skip to content

test: add snapshot tests for recommended default agent config #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions internal/commands/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ type snapshotTest struct {
}

var allSnapshotTests = []snapshotTest{
// Tests with default agent config
{
agentConfigPath: "test/snap0-default-agent-config.yaml",
outputPath: "test/snap0-docker-output.yaml",
packageType: Docker,
},
{
agentConfigPath: "test/snap0-default-agent-config.yaml",
outputPath: "test/snap0-linux-output.yaml",
packageType: Linux,
},
{
agentConfigPath: "test/snap0-default-agent-config.yaml",
outputPath: "test/snap0-macos-output.yaml",
packageType: MacOS,
},
{
agentConfigPath: "test/snap0-default-agent-config.yaml",
outputPath: "test/snap0-windows-output.yaml",
packageType: Windows,
},
// Tests with full agent config
{
agentConfigPath: "test/snap1-full-agent-config.yaml",
Expand Down
24 changes: 24 additions & 0 deletions internal/commands/config/test/snap0-default-agent-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Target Observe collection url
observe_url: https://123456789.collect.observe-eng.com/

# Observe data token
token: abcdefghijklmnopqrst:OWt0SXV4YTlqYUhpSHZjSlhXUDVkRXpl

# These are the recommended defaults for new users.
forwarding:
enabled: true
metrics:
output_format: otel

self_monitoring:
enabled: true

host_monitoring:
enabled: true
logs:
enabled: true
metrics:
host:
enabled: true
process:
enabled: false
340 changes: 340 additions & 0 deletions internal/commands/config/test/snap0-docker-output.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,340 @@
connectors:
count: null
exporters:
debug: null
nop: null
otlphttp/observe:
compression: zstd
endpoint: https://123456789.collect.observe-eng.com/v2/otel
headers:
authorization: Bearer abcdefghijklmnopqrst:OWt0SXV4YTlqYUhpSHZjSlhXUDVkRXpl
x-observe-target-package: Host Explorer
retry_on_failure:
enabled: true
sending_queue:
num_consumers: 4
queue_size: 100
otlphttp/observemetrics:
compression: zstd
endpoint: https://123456789.collect.observe-eng.com/v2/otel
headers:
authorization: Bearer abcdefghijklmnopqrst:OWt0SXV4YTlqYUhpSHZjSlhXUDVkRXpl
x-observe-target-package: Metrics
retry_on_failure:
enabled: true
sending_queue:
num_consumers: 4
queue_size: 100
otlphttp/observetracing:
compression: zstd
endpoint: https://123456789.collect.observe-eng.com/v2/otel
headers:
authorization: Bearer abcdefghijklmnopqrst:OWt0SXV4YTlqYUhpSHZjSlhXUDVkRXpl
x-observe-target-package: Tracing
retry_on_failure:
enabled: true
sending_queue:
num_consumers: 4
queue_size: 100
prometheusremotewrite/observe:
endpoint: https://123456789.collect.observe-eng.com/v1/prometheus
headers:
authorization: Bearer abcdefghijklmnopqrst:OWt0SXV4YTlqYUhpSHZjSlhXUDVkRXpl
x-observe-target-package: Host Explorer
max_batch_request_parallelism: 5
remote_write_queue:
num_consumers: 5
resource_to_telemetry_conversion:
enabled: true
send_metadata: true
extensions:
cgroupruntime:
gomaxprocs:
enabled: true
file_storage:
directory: /var/lib/observe-agent/filestorage
health_check:
endpoint: localhost:13133
path: /status
processors:
batch:
timeout: 5s
deltatocumulative: null
filter/count:
error_mode: ignore
metrics:
metric:
- IsMatch(name, ".*")
memory_limiter:
check_interval: 1s
limit_percentage: 80
spike_limit_percentage: 20
resourcedetection:
detectors:
- env
- system
system:
hostname_sources:
- dns
- os
resource_attributes:
host.arch:
enabled: true
host.cpu.cache.l2.size:
enabled: true
host.cpu.family:
enabled: true
host.cpu.model.id:
enabled: true
host.cpu.model.name:
enabled: true
host.cpu.stepping:
enabled: true
host.cpu.vendor.id:
enabled: true
host.id:
enabled: false
host.name:
enabled: true
os.description:
enabled: true
os.type:
enabled: true
resourcedetection/cloud:
detectors:
- gcp
- ecs
- ec2
- azure
override: false
timeout: 2s
transform/truncate:
log_statements:
- context: log
statements:
- truncate_all(attributes, 4095)
- truncate_all(resource.attributes, 4095)
trace_statements:
- context: span
statements:
- truncate_all(attributes, 4095)
- truncate_all(resource.attributes, 4095)
receivers:
filelog/host_monitoring:
include:
- /hostfs/var/log/**/*.log
- /hostfs/var/log/syslog
include_file_path: true
max_log_size: 4MiB
operators:
- expr: body matches "otel-contrib"
type: filter
retry_on_failure:
enabled: true
storage: file_storage
filestats/agent:
collection_interval: 5m
include: /etc/observe-agent/observe-agent.yaml
initial_delay: 60s
hostmetrics/host-monitoring-host:
collection_interval: 60s
root_path: /hostfs
scrapers:
cpu:
metrics:
system.cpu.frequency:
enabled: true
system.cpu.logical.count:
enabled: true
system.cpu.physical.count:
enabled: true
system.cpu.utilization:
enabled: true
disk: null
filesystem:
metrics:
system.filesystem.utilization:
enabled: true
load: null
memory:
metrics:
system.linux.memory.available:
enabled: true
system.memory.utilization:
enabled: true
network: null
paging:
metrics:
system.paging.utilization:
enabled: true
processes: null
journald/agent:
priority: info
units:
- observe-agent
journald/host_monitoring:
priority: info
units:
- cron
- ssh
- systemd-networkd
- systemd-resolved
- systemd-login
- multipathd
- systemd-user-sessions
- ufw
- observe-agent
nop: null
otlp:
protocols:
grpc:
endpoint: localhost:4317
http:
endpoint: localhost:4318
prometheus/agent:
config:
scrape_configs:
- job_name: otelcol
metric_relabel_configs:
- action: drop
regex: .*grpc_io.*
source_labels:
- __name__
scrape_interval: 10s
static_configs:
- targets:
- 0.0.0.0:8888
service:
extensions:
- health_check
- file_storage
- cgroupruntime
pipelines:
logs/agent-config:
exporters:
- nop
receivers:
- nop
logs/agent-journald:
exporters:
- otlphttp/observe
- count
processors:
- memory_limiter
- transform/truncate
- resourcedetection
- resourcedetection/cloud
- batch
receivers:
- journald/agent
logs/forward:
exporters:
- otlphttp/observe
- count
processors:
- memory_limiter
- transform/truncate
- resourcedetection
- resourcedetection/cloud
- batch
receivers:
- otlp
logs/host_monitoring-file:
exporters:
- otlphttp/observe
- count
processors:
- memory_limiter
- transform/truncate
- resourcedetection
- resourcedetection/cloud
- batch
receivers:
- filelog/host_monitoring
logs/host_monitoring-journald:
exporters:
- otlphttp/observe
- count
processors:
- memory_limiter
- transform/truncate
- resourcedetection
- resourcedetection/cloud
- batch
receivers:
- journald/host_monitoring
metrics/agent-filestats:
exporters:
- prometheusremotewrite/observe
processors:
- memory_limiter
- resourcedetection
- resourcedetection/cloud
- batch
receivers:
- filestats/agent
metrics/agent-internal:
exporters:
- prometheusremotewrite/observe
processors:
- memory_limiter
- transform/truncate
- resourcedetection
- resourcedetection/cloud
- deltatocumulative
- batch
receivers:
- prometheus/agent
- count
metrics/count-nop-in:
exporters:
- count
receivers:
- nop
metrics/count-nop-out:
exporters:
- nop
receivers:
- count
metrics/forward:
exporters:
- otlphttp/observemetrics
processors:
- memory_limiter
- resourcedetection
- resourcedetection/cloud
- batch
receivers:
- otlp
metrics/host_monitoring_host:
exporters:
- prometheusremotewrite/observe
processors:
- memory_limiter
- resourcedetection
- resourcedetection/cloud
- batch
receivers:
- hostmetrics/host-monitoring-host
traces/forward:
exporters:
- otlphttp/observetracing
processors:
- memory_limiter
- transform/truncate
- resourcedetection
- resourcedetection/cloud
- batch
receivers:
- otlp
telemetry:
logs:
level: INFO
metrics:
level: detailed
readers:
- pull:
exporter:
prometheus:
host: localhost
port: 8888
Loading
Loading