Skip to content

Commit b52a37e

Browse files
feat: add option to send forwarded metrics to Observe via OTLP
1 parent 7f8006d commit b52a37e

File tree

10 files changed

+121
-6
lines changed

10 files changed

+121
-6
lines changed

internal/commands/initconfig/initconfig.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var (
1919
observe_url string
2020
cloud_resource_detectors []string
2121
resource_attributes map[string]string
22+
forwarding_use_otlp bool
2223
self_monitoring_enabled bool
2324
host_monitoring_enabled bool
2425
host_monitoring_logs_enabled bool
@@ -87,6 +88,9 @@ func RegisterConfigFlags(cmd *cobra.Command, v *viper.Viper) {
8788
cmd.PersistentFlags().StringToStringVar(&resource_attributes, "resource_attributes", map[string]string{}, "The cloud environments from which to detect resources")
8889
v.BindPFlag("resource_attributes", cmd.PersistentFlags().Lookup("resource_attributes"))
8990

91+
cmd.PersistentFlags().BoolVar(&self_monitoring_enabled, "forwarding::otlp_metrics", false, "Forward app metrics to Observe using OTLP")
92+
v.BindPFlag("forwarding::otlp_metrics", cmd.PersistentFlags().Lookup("forwarding::otlp_metrics"))
93+
9094
cmd.PersistentFlags().BoolVar(&self_monitoring_enabled, "self_monitoring::enabled", true, "Enable self monitoring")
9195
v.BindPFlag("self_monitoring::enabled", cmd.PersistentFlags().Lookup("self_monitoring::enabled"))
9296
v.SetDefault("self_monitoring::enabled", true)

internal/config/configschema.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ type HealthCheckConfig struct {
4747
}
4848

4949
type ForwardingConfig struct {
50-
Enabled bool `yaml:"enabled" mapstructure:"enabled" default:"true"`
50+
Enabled bool `yaml:"enabled" mapstructure:"enabled" default:"true"`
51+
OtlpMetrics bool `yaml:"otlp_metrics,omitempty" mapstructure:"otlp_metrics"`
5152
}
5253

5354
type InternalTelemetryMetricsConfig struct {

packaging/docker/observe-agent/connections/common/forward.yaml.tmpl

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,24 @@ exporters:
1919
enabled: true
2020
compression: zstd
2121

22+
otlphttp/observemetrics:
23+
endpoint: ${env:OBSERVE_OTEL_ENDPOINT}
24+
headers:
25+
authorization: ${env:OBSERVE_AUTHORIZATION_HEADER}
26+
x-observe-target-package: "Metrics"
27+
sending_queue:
28+
num_consumers: 4
29+
queue_size: 100
30+
retry_on_failure:
31+
enabled: true
32+
compression: zstd
33+
2234
service:
2335
pipelines:
2436
metrics/forward:
2537
receivers: [otlp]
2638
processors:
39+
- memory_limiter
2740
- resourcedetection
2841
- resourcedetection/cloud
2942
{{- if .HasAttributes }}
@@ -32,13 +45,22 @@ service:
3245
{{- if .HasResourceAttributes }}
3346
- resource/observe_global_resource_attributes
3447
{{- end }}
48+
{{- if not .Forwarding.OtlpMetrics }}
3549
- deltatocumulative
50+
{{- end }}
3651
- batch
37-
exporters: [prometheusremotewrite/observe]
52+
exporters:
53+
{{- if .Forwarding.OtlpMetrics }}
54+
- otlphttp/observemetrics
55+
{{- else }}
56+
- prometheusremotewrite/observe
57+
{{- end }}
3858

3959
logs/forward:
4060
receivers: [otlp]
4161
processors:
62+
- memory_limiter
63+
- transform/truncate
4264
- resourcedetection
4365
- resourcedetection/cloud
4466
{{- if .HasAttributes }}
@@ -47,11 +69,14 @@ service:
4769
{{- if .HasResourceAttributes }}
4870
- resource/observe_global_resource_attributes
4971
{{- end }}
72+
- batch
5073
exporters: [otlphttp/observe, count]
5174

5275
traces/forward:
5376
receivers: [otlp]
5477
processors:
78+
- memory_limiter
79+
- transform/truncate
5580
- resourcedetection
5681
- resourcedetection/cloud
5782
{{- if .HasAttributes }}
@@ -60,4 +85,5 @@ service:
6085
{{- if .HasResourceAttributes }}
6186
- resource/observe_global_resource_attributes
6287
{{- end }}
88+
- batch
6389
exporters: [otlphttp/observetracing]

packaging/linux/config/observe-agent.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ observe_url: "<OBSERVE COLLECTION ENDPOINT>"
77
# Debug mode - Sets agent log level to debug
88
debug: false
99

10+
# Enable forwarding of local app metrics and traces
11+
forwarding:
12+
enabled: true
13+
otlp_metrics: true
14+
1015
# collect metrics and logs pertaining to the agent itself
1116
self_monitoring:
1217
enabled: true

packaging/linux/connections/common/forward.yaml.tmpl

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,24 @@ exporters:
1919
enabled: true
2020
compression: zstd
2121

22+
otlphttp/observemetrics:
23+
endpoint: ${env:OBSERVE_OTEL_ENDPOINT}
24+
headers:
25+
authorization: ${env:OBSERVE_AUTHORIZATION_HEADER}
26+
x-observe-target-package: "Metrics"
27+
sending_queue:
28+
num_consumers: 4
29+
queue_size: 100
30+
retry_on_failure:
31+
enabled: true
32+
compression: zstd
33+
2234
service:
2335
pipelines:
2436
metrics/forward:
2537
receivers: [otlp]
2638
processors:
39+
- memory_limiter
2740
- resourcedetection
2841
- resourcedetection/cloud
2942
{{- if .HasAttributes }}
@@ -32,13 +45,22 @@ service:
3245
{{- if .HasResourceAttributes }}
3346
- resource/observe_global_resource_attributes
3447
{{- end }}
48+
{{- if not .Forwarding.OtlpMetrics }}
3549
- deltatocumulative
50+
{{- end }}
3651
- batch
37-
exporters: [prometheusremotewrite/observe]
52+
exporters:
53+
{{- if .Forwarding.OtlpMetrics }}
54+
- otlphttp/observemetrics
55+
{{- else }}
56+
- prometheusremotewrite/observe
57+
{{- end }}
3858

3959
logs/forward:
4060
receivers: [otlp]
4161
processors:
62+
- memory_limiter
63+
- transform/truncate
4264
- resourcedetection
4365
- resourcedetection/cloud
4466
{{- if .HasAttributes }}
@@ -47,11 +69,14 @@ service:
4769
{{- if .HasResourceAttributes }}
4870
- resource/observe_global_resource_attributes
4971
{{- end }}
72+
- batch
5073
exporters: [otlphttp/observe, count]
5174

5275
traces/forward:
5376
receivers: [otlp]
5477
processors:
78+
- memory_limiter
79+
- transform/truncate
5580
- resourcedetection
5681
- resourcedetection/cloud
5782
{{- if .HasAttributes }}
@@ -60,4 +85,5 @@ service:
6085
{{- if .HasResourceAttributes }}
6186
- resource/observe_global_resource_attributes
6287
{{- end }}
88+
- batch
6389
exporters: [otlphttp/observetracing]

packaging/macos/connections/common/forward.yaml.tmpl

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,24 @@ exporters:
1919
enabled: true
2020
compression: zstd
2121

22+
otlphttp/observemetrics:
23+
endpoint: ${env:OBSERVE_OTEL_ENDPOINT}
24+
headers:
25+
authorization: ${env:OBSERVE_AUTHORIZATION_HEADER}
26+
x-observe-target-package: "Metrics"
27+
sending_queue:
28+
num_consumers: 4
29+
queue_size: 100
30+
retry_on_failure:
31+
enabled: true
32+
compression: zstd
33+
2234
service:
2335
pipelines:
2436
metrics/forward:
2537
receivers: [otlp]
2638
processors:
39+
- memory_limiter
2740
- resourcedetection
2841
- resourcedetection/cloud
2942
{{- if .HasAttributes }}
@@ -32,13 +45,22 @@ service:
3245
{{- if .HasResourceAttributes }}
3346
- resource/observe_global_resource_attributes
3447
{{- end }}
48+
{{- if not .Forwarding.OtlpMetrics }}
3549
- deltatocumulative
50+
{{- end }}
3651
- batch
37-
exporters: [prometheusremotewrite/observe]
52+
exporters:
53+
{{- if .Forwarding.OtlpMetrics }}
54+
- otlphttp/observemetrics
55+
{{- else }}
56+
- prometheusremotewrite/observe
57+
{{- end }}
3858

3959
logs/forward:
4060
receivers: [otlp]
4161
processors:
62+
- memory_limiter
63+
- transform/truncate
4264
- resourcedetection
4365
- resourcedetection/cloud
4466
{{- if .HasAttributes }}
@@ -47,11 +69,14 @@ service:
4769
{{- if .HasResourceAttributes }}
4870
- resource/observe_global_resource_attributes
4971
{{- end }}
72+
- batch
5073
exporters: [otlphttp/observe, count]
5174

5275
traces/forward:
5376
receivers: [otlp]
5477
processors:
78+
- memory_limiter
79+
- transform/truncate
5580
- resourcedetection
5681
- resourcedetection/cloud
5782
{{- if .HasAttributes }}
@@ -60,4 +85,5 @@ service:
6085
{{- if .HasResourceAttributes }}
6186
- resource/observe_global_resource_attributes
6287
{{- end }}
88+
- batch
6389
exporters: [otlphttp/observetracing]

packaging/windows/connections/common/forward.yaml.tmpl

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,24 @@ exporters:
1919
enabled: true
2020
compression: zstd
2121

22+
otlphttp/observemetrics:
23+
endpoint: ${env:OBSERVE_OTEL_ENDPOINT}
24+
headers:
25+
authorization: ${env:OBSERVE_AUTHORIZATION_HEADER}
26+
x-observe-target-package: "Metrics"
27+
sending_queue:
28+
num_consumers: 4
29+
queue_size: 100
30+
retry_on_failure:
31+
enabled: true
32+
compression: zstd
33+
2234
service:
2335
pipelines:
2436
metrics/forward:
2537
receivers: [otlp]
2638
processors:
2739
- memory_limiter
28-
- transform/truncate
2940
- resourcedetection
3041
- resourcedetection/cloud
3142
{{- if .HasAttributes }}
@@ -34,9 +45,16 @@ service:
3445
{{- if .HasResourceAttributes }}
3546
- resource/observe_global_resource_attributes
3647
{{- end }}
48+
{{- if not .Forwarding.OtlpMetrics }}
3749
- deltatocumulative
50+
{{- end }}
3851
- batch
39-
exporters: [prometheusremotewrite/observe]
52+
exporters:
53+
{{- if .Forwarding.OtlpMetrics }}
54+
- otlphttp/observemetrics
55+
{{- else }}
56+
- prometheusremotewrite/observe
57+
{{- end }}
4058

4159
logs/forward:
4260
receivers: [otlp]

packaging/windows/observe-agent.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ observe_url: "${OBSERVE_COLLECTION_ENDPOINT}"
77
# Debug mode - Sets agent log level to debug
88
debug: false
99

10+
# Enable forwarding of local app metrics and traces
11+
forwarding:
12+
enabled: true
13+
otlp_metrics: true
14+
1015
# collect metrics and logs pertaining to the agent itself
1116
self_monitoring:
1217
enabled: true

scripts/install_linux.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ else
120120
INIT_FLAGS="$INIT_FLAGS --host_monitoring::metrics::host::enabled=false"
121121
fi
122122
fi
123+
# Add default args
124+
INIT_FLAGS="$INIT_FLAGS --forwarding::otlp_metrics=true"
123125
sudo $agent_binary_path init-config $INIT_FLAGS
124126
sudo chown root:root $observeagent_config_dir/observe-agent.yaml
125127
fi

scripts/install_mac.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ else
127127
INIT_FLAGS="$INIT_FLAGS --host_monitoring::metrics::host::enabled=false"
128128
fi
129129
fi
130+
# Add default args
131+
INIT_FLAGS="$INIT_FLAGS --forwarding::otlp_metrics=true"
130132
sudo $observeagent_install_dir/observe-agent init-config $INIT_FLAGS
131133
sudo chown root:wheel $observeagent_install_dir/observe-agent.yaml
132134
fi

0 commit comments

Comments
 (0)