Skip to content

Add root-level cluster_name and standardize collection_interval for OpenTelemetry features#2189

Open
Paamicky wants to merge 9 commits into
mainfrom
zeus-V2-json-configs
Open

Add root-level cluster_name and standardize collection_interval for OpenTelemetry features#2189
Paamicky wants to merge 9 commits into
mainfrom
zeus-V2-json-configs

Conversation

@Paamicky

@Paamicky Paamicky commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description of the issue

The OpenTelemetry config section had two inconsistencies: cluster_name was required per-component, forcing customers to repeat the same cluster value for every feature, and the collection interval field name differed across features (metrics_collection_interval vs collection_interval). This has been updated to use the newer version collection_interval.

Description of changes

  • Root-level cluster_name: Moved to opentelemetry.cluster_name. A single value now applies to all features (Container Insights, Prometheus, Host Metrics, OTLP). Container Insights and Prometheus require it; Host Metrics and OTLP apply it when present.
  • Standardized collection_interval: All OpenTelemetry features now use collection_interval with a 30-second default. Host Metrics renamed from metrics_collection_interval. Database Insights retains its own hardcoded intervals.
  • Centralized validation: ClusterNameRegex moved to the common package. GetOtelClusterName and GetCollectionInterval added as shared helpers.
  • Schema updated: schema.json reflects the new root-level cluster_name field and standardized collection_interval across features.
  • Renamed mode to role in the Container Insights JSON config field (opentelemetry.collect.container_insights.role) to align with the CWAGENT_ROLE environment
    variable naming.

Tests

  • Unit tests for GetOtelClusterName verifies root-level reads, env var is not used as fallback, empty config returns empty
  • Unit tests for GetCollectionInterval verifies feature-level override, 30s default, zero/negative values ignored
  • Updated golden file tests and confirm set_cluster_name processor appears in all applicable pipelines
  • All existing translator tests pass

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Paamicky Paamicky added the ready for testing Indicates this PR is ready for integration tests to run label Jul 9, 2026
@Paamicky Paamicky marked this pull request as ready for review July 9, 2026 16:17
@Paamicky Paamicky requested a review from a team as a code owner July 9, 2026 16:17
@Paamicky Paamicky changed the title Add root-level cluster_name and standardize collection_interval for … Add root-level cluster_name and standardize collection_interval for OpenTelemetry features Jul 9, 2026
@Paamicky Paamicky removed the request for review from a team July 10, 2026 16:54
Comment on lines +1020 to +1029
transform/set_cluster_name:
error_mode: ignore
flatten_data: false
log_statements:
- context: resource
error_mode: ignore
statements:
- set(resource.attributes["k8s.cluster.name"], "TestCluster")
metric_statements: []
trace_statements: []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this have resource statements for each of the resource types? I see the same processor is being used in metric pipelines as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. otlp logs now uses its own processor (transform/set_cluster_name_logs) so it doesn't overwrite the metric_statements used by the metrics pipelines

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't they share a single transform processor?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. set_cluster_name now registers with both metric_statements and log_statements in a single processor. Pipelines will use statements relevant to its signal.

WithTraceResourceStatements is not yet supported in the transform processor.

// Traces are not handled: WithTraceResourceStatements is not yet supported.
// Traces sent via OTLP on EKS should include k8s.cluster.name from the SDK.

This will need a separate PR if we want to add it.

@Paamicky Paamicky force-pushed the zeus-V2-json-configs branch from fa8f4e5 to 23cab82 Compare July 10, 2026 19:58
@Paamicky Paamicky force-pushed the zeus-V2-json-configs branch from 23cab82 to 59cea26 Compare July 10, 2026 20:25
mitali-salvi
mitali-salvi previously approved these changes Jul 13, 2026

// GetCollectionInterval returns the collection interval for an OpenTelemetry feature.
// It checks the feature-specific collection_interval field. Default is 30s.
func GetCollectionInterval(conf *confmap.Conf, featureKey string) time.Duration {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does the exact same thing as GetOrDefaultDuration

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah removed to use the already existing function: GetOrDefaultDuration


// GetOtelClusterName returns the cluster name for OpenTelemetry-based features.
// It reads exclusively from opentelemetry::cluster_name.
func GetOtelClusterName(conf *confmap.Conf) string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a separate function for this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the function wrapper and defined inline at each call site.

}

// DefaultCollectionInterval is the default collection interval for OpenTelemetry-based features.
const DefaultCollectionInterval = 30 * time.Second

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't define this here. It doesn't apply to all cases of collection interval. It's only for the opentelemetry pipelines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to a local constant in each package that uses it.

@Paamicky Paamicky force-pushed the zeus-V2-json-configs branch from d7d65ea to 23ade6b Compare July 14, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for testing Indicates this PR is ready for integration tests to run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants