Skip to content

Centralized port config in environment#2276

Open
rafaelwestphal wants to merge 5 commits intomasterfrom
westphalrafael/port-config-env
Open

Centralized port config in environment#2276
rafaelwestphal wants to merge 5 commits intomasterfrom
westphalrafael/port-config-env

Conversation

@rafaelwestphal
Copy link
Copy Markdown
Contributor

@rafaelwestphal rafaelwestphal commented Apr 22, 2026

Description

Expose an environment variable that allows customer to set sub-agent ports.

Related issue

b/236599678

How has this been tested?

Integration test.

Checklist:

  • Unit tests
    • Unit tests do not apply.
    • Unit tests have been added/modified and passed for this PR.
  • Integration tests
    • Integration tests do not apply.
    • Integration tests have been added/modified and passed for this PR.
  • Documentation
    • This PR introduces no user visible changes.
    • This PR introduces user visible changes and the corresponding documentation change has been made.
  • Minor version bump
    • This PR introduces no new features.
    • This PR introduces new features, and there is a separate PR to bump the minor version since the last release already.
    • This PR bumps the version.

This commit implements the prototype for environment variable port configuration
in the Ops Agent. It allows users to set independent metrics ports for Fluent Bit
and OpenTelemetry Collector using environment variables:
- OPS_AGENT_FLUENT_BIT_METRICS_PORT
- OPS_AGENT_OTEL_METRICS_PORT

- Added methods to UnifiedConfig to read ports from env vars.
- Updated confgenerator and otel/modular to use these ports.
- Added unit tests to verify behavior.

TAG=agy
CONV=062b1ae6-6d88-486e-a584-a82f970e5ae4
@rafaelwestphal rafaelwestphal changed the title Westphalrafael/port config env Option 3: Centralized port config in environment Apr 22, 2026
@rafaelwestphal rafaelwestphal changed the title Option 3: Centralized port config in environment Prototype Option 3: Centralized port config in environment Apr 22, 2026
@rafaelwestphal rafaelwestphal changed the title Prototype Option 3: Centralized port config in environment Centralized port config in environment Apr 24, 2026
@rafaelwestphal rafaelwestphal marked this pull request as ready for review April 24, 2026 15:42
Comment thread confgenerator/config.go
}

func (uc *UnifiedConfig) GetFluentBitMetricsPort() uint16 {
if portStr := os.Getenv("OPS_AGENT_FLUENT_BIT_METRICS_PORT"); portStr != "" {
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 like Quentin's suggestion to make these env vars prefixed with EXPERIMENTAL (EXPERIMENT? whatever our convention is).

Might also be good to make the environment variable names a constant, that way the tests can use the constant too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants