Skip to content

feat: add named component templates for pipeline sources, transforms, and sinks#223

Open
sakateka wants to merge 1 commit into
kaasops:mainfrom
sakateka:config-defaults
Open

feat: add named component templates for pipeline sources, transforms, and sinks#223
sakateka wants to merge 1 commit into
kaasops:mainfrom
sakateka:config-defaults

Conversation

@sakateka

Copy link
Copy Markdown
Contributor

Hi! Thanks for the great project - we use it actively. As the number of pipelines grows, managing configs becomes painful: changing a shared default (e.g. a sink) means editing every pipeline.

I explored a templating approach - not sure it’s the best possible design, but I don’t see a cleaner option yet. Would love your feedback.

Proposal: named component templates on the Vector CR

Platform admins define reusable component bodies once on Vector / VectorAggregator via spec.agent.componentTemplates (also available on aggregators through VectorCommon):

  • sources, transforms, sinks - maps of template name -> Go text/template body
  • rendered output must be valid YAML for a single Vector component

Pipelines reference a template explicitly:

  • sourceTemplate / transformTemplate / sinkTemplate: { name, params }
  • template params are available as {{ .paramName }} with strict policy missing key => error
  • a component is either inline (type: …) or templated - both together is rejected
  • the template replaces the whole component (no merge with inline fields)
  • for transforms/sinks, inputs from the pipeline override whatever the template rendered

Example - platform defines the sink once (batching, headers, encoding):

spec:
  agent:
    componentTemplates:
      sinks:
        opentelemetry-http: |
          type: opentelemetry
          protocol: http
          uri: "{{ .uri }}"
          method: post
          encoding:
            codec: json
          compression: gzip
          request:
            headers:
              X-Tenant-ID: "{{ .tenant }}"
            timeout_secs: 30
          batch:
            max_events: {{ or (index . "maxEvents") 500 }}
            timeout_secs: 5
          buffer:
            type: disk
            max_size: 268435456
          acknowledgements:
            enabled: true

Each pipeline only passes what actually differs:

sinks:
  app-logs:
    inputs: [parse-logs]
    sinkTemplate:
      name: opentelemetry-http
      params:
        uri: https://otel-prod.example/v1/logs
        tenant: team-payments


  audit-logs:
    inputs: [audit-transform]
    sinkTemplate:
      name: opentelemetry-http
      params:
        uri: https://otel-prod.example/v1/logs
        tenant: team-security
        maxEvents: 100

Change batch size, TLS, headers, or compression once on the Vector CR - all pipelines pick it up on the next reconcile. Pipelines without template refs behave unchanged.

Applied during config build for both agent and aggregator paths.

I haven’t used this code in production or on a test/staging environment yet.

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.

1 participant