Add opentelemetry root level config section with host_metrics, prometheus, OTLP, container_insights, and database_insights pipelines - #2152
Conversation
…races exporters) Switch TestOtlpOtelConfig to use checkTranslation (like host_insights) so the TOML translator sets Global_Config.Region first, enabling the base export pipelines to generate. The golden YAML now includes otlphttp exporters, sigv4 auth, batch processors, and the complete pipeline routing.
…irectory Groups all opentelemetry.collect related golden files (host_insights, container_insights, dbi, prometheus, otlp) into a dedicated subdirectory for easier navigation.
… files - Switch host_insights, prometheus, otlp, dbi to checkTranslation (full TOML+YAML path) so golden files include complete pipeline output - Keep checkTranslationNoValidation only for container_insights (K8s service account token validation fails in unit tests) but improved it to run TOML translation first so region/base pipelines generate - Regenerate all opentelemetry golden YAML files with full pipeline output - Remove unused mapstructure/otel imports where not needed
Aligns the logs pipeline with metrics and traces pipelines which both have resourcedetection for EC2/EKS metadata enrichment.
Previously only host_insights had a schema validation test. Now all opentelemetry.collect features have valid/invalid sample JSON files and corresponding test functions.
Aligns all three base pipelines with consistent agent health reporting. - Metrics: agenthealth/otlphttp_metrics (already had it) - Logs: agenthealth/logs (wraps headerssetter auth chain) - Traces: agenthealth/traces (wraps sigv4/xray auth)
…tion The function was only used in one place. Inlined the logic directly into TestContainerInsightsConfig with a comment explaining why collector validation is skipped (K8s service account token path is root-owned).
Add sample configs demonstrating both traditional (metrics/logs/traces) and opentelemetry.collect sections working together: - EC2 config: all v1 features + host_insights, database_insights, prometheus, otlp - EKS config: all v1 features + all v2 features including container_insights Includes golden files, translation tests, and schema validation.
…statement-level
Pass the configured errorMode into buildStatements so statement-level
error_mode matches the top-level value. Previously buildStatements
hardcoded 'propagate' regardless of the WithErrorMode option.
Remove unnecessary WithErrorMode("ignore") from otlp_log_source and
logs_cleanup since their statements (set with where guard, delete_key)
cannot produce errors and propagate is the correct default.
23e5800 to
3213115
Compare
3213115 to
e547991
Compare
| "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/common" | ||
| ci "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/pipeline/opentelemetry/containerinsights" | ||
| dbi "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/pipeline/opentelemetry/databaseinsights" | ||
| hi "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/pipeline/opentelemetry/hostmetrics" |
| @@ -0,0 +1,217 @@ | |||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | |||
There was a problem hiding this comment.
nit: this file should be called translators.go to be consistent with the others.
| // CI logs pipelines are self-contained with dedicated exporters (compression: none) | ||
| // to match the helm chart behavior for FluentBit migration parity. They cannot share | ||
| // the base logs/opentelemetry exporter which uses gzip compression. See: | ||
| // https://github.com/aws-observability/helm-charts/blob/main/charts/amazon-cloudwatch-observability/templates/linux/_otel-container-insights-config.tpl |
There was a problem hiding this comment.
nit: This reference in the helm chart is going to disappear from main pretty soon, either pin it to the commit or copy over the actual reasoning from the helm chart in here - like to prevent a cpu spike etc.
| // - omitted: all pipelines | ||
| func NewTranslators(conf *confmap.Conf) common.PipelineTranslatorMap { | ||
| translators := common.NewTranslatorMap[*common.ComponentTranslators, pipeline.ID]() | ||
| mode := getMode(conf) |
There was a problem hiding this comment.
As discussed, we should consider aligning this to the CollectionRole we have today. It will allow us to use the same default config in our helm and tweak the behavior with an env var.
We could continue to do this flag in addition to the env var and have a fallthrough ordering, but lets make the naming consistent i.e. instead of mode, might wanna call this role or something.
| } | ||
|
|
||
| // Deployment metrics pipelines | ||
| if mode == "" || mode == "cluster" { |
There was a problem hiding this comment.
If mode is empty, itll end up doing the work for both cluster and node.. do we want that?
Might be safer to just do node level work if empty.
| Region: agent.Global_Config.Region, | ||
| CollectionInterval: collectionInterval.String(), | ||
| ScrapeTimeout: scrapeTimeout.String(), | ||
| NodeName: envOrPlaceholder("K8S_NODE_NAME"), |
There was a problem hiding this comment.
nit: While we set both, HOST_NAME is what we've historically used in the context of CI, so Id stick to that.
| keys = make([]string, 0, len(sectionMap)) | ||
| for k := range sectionMap { | ||
| keys = append(keys, k) | ||
| } |
There was a problem hiding this comment.
| keys = make([]string, 0, len(sectionMap)) | |
| for k := range sectionMap { | |
| keys = append(keys, k) | |
| } | |
| slices.Collect(maps.Keys(sectionMap)) |
| var scrapersWindowsConfig []byte | ||
|
|
||
| // Config is a serializable representation of | ||
| // hostmetricsreceiver.Config. The upstream type uses mapstructure:"-" on its |
There was a problem hiding this comment.
Can be a follow up but we should ideally update this in our fork instead of the below.
|
|
||
| var prometheusKey = common.ConfigKey(common.OpenTelemetryKey, common.CollectKey, common.PrometheusKey) | ||
| var configPathKey = common.ConfigKey(prometheusKey, "config_path") | ||
| var clusterNameKey = common.ConfigKey(prometheusKey, "cluster_name") |
There was a problem hiding this comment.
Can be a follow up, but some of these we should standerdize in this new schema. Like if cluster_name can be set here, why not for otlp.
| "auth_type": "serviceAccount", | ||
| "passthrough": false, | ||
| "filter": map[string]interface{}{ | ||
| "node_from_env_var": "K8S_NODE_NAME", |
There was a problem hiding this comment.
related to the other comment if we do end up changing that to HOST_NAME at some point
| MaxMetricsPerRequest = 1000 | ||
| MaxLogsPerRequest = 10000 | ||
| MaxSpansPerRequest = 10000 | ||
| BatchTimeout = 15 * time.Second |
There was a problem hiding this comment.
Should this be 15 or 30?
| } | ||
|
|
||
| func isLocalhostEndpoint(endpoint string) bool { | ||
| return strings.HasPrefix(endpoint, "localhost") || |
There was a problem hiding this comment.
nit: This seems a little fragile... consider parsing the host (net.SplitHostPort) and compare exactly.
| "host_metrics": { | ||
| "type": "object", | ||
| "properties": { | ||
| "metrics_collection_interval": { |
There was a problem hiding this comment.
nit: We should probably standardize and call it just collection_interval
66280f8 to
bc0d2a6
Compare
Summary
Adds the
opentelemetry.collectconfig translation pipeline, enabling users to configure OTel pipelines via JSON config instead of raw YAML. This is the unified feature branch containing all v2 OTel collect sub-features.Features
Architecture
Key Design Decisions
Testing
make lintclean)