Skip to content

feat(loki/stages): add JSON tags to loki process stage config structs#5999

Open
QuentinBisson wants to merge 1 commit intografana:mainfrom
QuentinBisson:feat/podlogs-stage-json-tags
Open

feat(loki/stages): add JSON tags to loki process stage config structs#5999
QuentinBisson wants to merge 1 commit intografana:mainfrom
QuentinBisson:feat/podlogs-stage-json-tags

Conversation

@QuentinBisson
Copy link
Copy Markdown
Contributor

@QuentinBisson QuentinBisson commented Apr 7, 2026

Summary

  • Adds json:"..." tags to all stage config structs in loki.process/stages/ so they can be serialised/deserialised as JSON.
  • Required by the loki.source.podlogs PodLogs CRD feature (#4738) which embeds pipeline stage configs in the Kubernetes CRD spec using JSON.
  • All changes are purely additive (new struct tags only); existing alloy tag behaviour and validation are unchanged.

Adds `json:"..."` tags to every stage configuration struct in
loki/process/stages and loki/process/metric. These tags are required to serialize stage configs to/from JSON for use in the PodLogs CRD (see grafana#4738).

Notable serialization choices:
- `time.Duration` fields (OlderThan, MaxIdle) are tagged `json:"-"` because Go serialises them as nanosecond int64 values, which are not human-readable in Kubernetes YAML. Users can rely on the default value.
- `units.Base2Bytes` already implements TextMarshaler/TextUnmarshaler and serialises as "5MiB", so it is exposed normally.

No behaviour change — the alloy:"..." tags that drive existing parsing are untouched; json tags are purely additive.

Refs: grafana#4738

fix(loki/stages): mark GeoIPConfig.Source as required in JSON

Remove omitempty from the Source field JSON tag so the field is never
silently dropped when serialising a PodLogs pipeline stage config.
Source is a required field (alloy:"source,attr") and omitting it in
JSON would leave a nil pointer that causes the stage to do nothing.

Refs: grafana#4738
Signed-off-by: QuentinBisson <quentin@giantswarm.io>
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