Skip to content

Commit

Permalink
map river configs
Browse files Browse the repository at this point in the history
  • Loading branch information
thepalbi committed Dec 6, 2023
1 parent 7d2e197 commit fcf3ca8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Main (unreleased)
- Added links between compatible components in the documentation to make it
easier to discover them. (@thampiotr)

- Added support for `loki.write` to flush WAL on agent shutdown. (@thepalbi)

### Bugfixes

- Update `pyroscope.ebpf` to fix a logical bug causing to profile to many kthreads instead of regular processes https://github.com/grafana/pyroscope/pull/2778 (@korniltsev)
Expand Down
3 changes: 3 additions & 0 deletions component/loki/write/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type WalArguments struct {
MaxSegmentAge time.Duration `river:"max_segment_age,attr,optional"`
MinReadFrequency time.Duration `river:"min_read_frequency,attr,optional"`
MaxReadFrequency time.Duration `river:"max_read_frequency,attr,optional"`
DrainTimeout time.Duration `river:"drain_timeout,attr,optional"`
}

func (wa *WalArguments) Validate() error {
Expand All @@ -58,6 +59,7 @@ func (wa *WalArguments) SetToDefault() {
MaxSegmentAge: wal.DefaultMaxSegmentAge,
MinReadFrequency: wal.DefaultWatchConfig.MinReadFrequency,
MaxReadFrequency: wal.DefaultWatchConfig.MaxReadFrequency,
DrainTimeout: wal.DefaultWatchConfig.DrainTimeout,
}
}

Expand Down Expand Up @@ -163,6 +165,7 @@ func (c *Component) Update(args component.Arguments) error {
WatchConfig: wal.WatchConfig{
MinReadFrequency: newArgs.WAL.MinReadFrequency,
MaxReadFrequency: newArgs.WAL.MaxReadFrequency,
DrainTimeout: newArgs.WAL.DrainTimeout,
},
}

Expand Down
4 changes: 4 additions & 0 deletions component/loki/write/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestUnmarshallWalAttrributes(t *testing.T) {
MaxSegmentAge: wal.DefaultMaxSegmentAge,
MinReadFrequency: wal.DefaultWatchConfig.MinReadFrequency,
MaxReadFrequency: wal.DefaultWatchConfig.MaxReadFrequency,
DrainTimeout: wal.DefaultWatchConfig.DrainTimeout,
},
},
"wal enabled with defaults": {
Expand All @@ -90,19 +91,22 @@ func TestUnmarshallWalAttrributes(t *testing.T) {
MaxSegmentAge: wal.DefaultMaxSegmentAge,
MinReadFrequency: wal.DefaultWatchConfig.MinReadFrequency,
MaxReadFrequency: wal.DefaultWatchConfig.MaxReadFrequency,
DrainTimeout: wal.DefaultWatchConfig.DrainTimeout,
},
},
"wal enabled with some overrides": {
raw: `
enabled = true
max_segment_age = "10m"
min_read_frequency = "11ms"
drain_timeout = "5m"
`,
expected: WalArguments{
Enabled: true,
MaxSegmentAge: time.Minute * 10,
MinReadFrequency: time.Millisecond * 11,
MaxReadFrequency: wal.DefaultWatchConfig.MaxReadFrequency,
DrainTimeout: time.Minute * 5,
},
},
} {
Expand Down
1 change: 1 addition & 0 deletions docs/sources/flow/reference/components/loki.write.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ Name | Type | Description
`max_segment_age` | `duration` | Maximum time a WAL segment should be allowed to live. Segments older than this setting will be eventually deleted. | `"1h"` | no
`min_read_frequency` | `duration` | Minimum backoff time in the backup read mechanism. | `"250ms"` | no
`max_read_frequency` | `duration` | Maximum backoff time in the backup read mechanism. | `"1s"` | no
`max_read_frequency` | `duration` | Maximum backoff time in the backup read mechanism. | `"1s"` | no

[run]: {{< relref "../cli/run.md" >}}

Expand Down

0 comments on commit fcf3ca8

Please sign in to comment.