From fa949e3d2ee9c612982d0f0e3b97a23f9d8d505b Mon Sep 17 00:00:00 2001 From: Ravishankar Date: Thu, 12 Dec 2024 22:08:26 +0530 Subject: [PATCH] Change the config name --- CHANGELOG.md | 2 +- .../reference/components/local/local.file_match.md | 10 +++++----- internal/component/local/file_match/file.go | 12 ++++++------ internal/component/local/file_match/file_test.go | 2 +- internal/component/local/file_match/watch.go | 8 ++++---- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db1f09022..85f476187 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,7 +45,7 @@ Main (unreleased) - Add perf_schema quantile columns to collector - Add three new stdlib functions to_base64, from_URLbase64 and to_URLbase64 (@ravishankar15) -- Add `ignore_older` option for local.file_match (@ravishankar15) +- Add `ignore_older_than` option for local.file_match (@ravishankar15) ### Bugfixes diff --git a/docs/sources/reference/components/local/local.file_match.md b/docs/sources/reference/components/local/local.file_match.md index 0f8dd4782..6e27fcf9b 100644 --- a/docs/sources/reference/components/local/local.file_match.md +++ b/docs/sources/reference/components/local/local.file_match.md @@ -24,11 +24,11 @@ local.file_match "LABEL" { The following arguments are supported: -Name | Type | Description | Default | Required ---------------- | ------------------- | ------------------------------------------------------------------------------------------ |---------| -------- -`path_targets` | `list(map(string))` | Targets to expand; looks for glob patterns on the `__path__` and `__path_exclude__` keys. | | yes -`sync_period` | `duration` | How often to sync filesystem and targets. | `"10s"` | no -`ignore_older` | `duration` | Ignores files which are modified before this duration | | no +Name | Type | Description | Default | Required +--------------- | ------------------- | ------------------------------------------------------------------------------------------ |---------| -------- +`path_targets` | `list(map(string))` | Targets to expand; looks for glob patterns on the `__path__` and `__path_exclude__` keys. | | yes +`sync_period` | `duration` | How often to sync filesystem and targets. | `"10s"` | no +`ignore_older_than` | `duration` | Ignores files which are modified before this duration | | no `path_targets` uses [doublestar][] style paths. * `/tmp/**/*.log` will match all subfolders of `tmp` and include any files that end in `*.log`. diff --git a/internal/component/local/file_match/file.go b/internal/component/local/file_match/file.go index f757dec1e..102f81bee 100644 --- a/internal/component/local/file_match/file.go +++ b/internal/component/local/file_match/file.go @@ -26,9 +26,9 @@ func init() { // Arguments holds values which are used to configure the local.file_match // component. type Arguments struct { - PathTargets []discovery.Target `alloy:"path_targets,attr"` - SyncPeriod time.Duration `alloy:"sync_period,attr,optional"` - IgnoreOlder time.Duration `alloy:"ignore_older,attr,optional"` + PathTargets []discovery.Target `alloy:"path_targets,attr"` + SyncPeriod time.Duration `alloy:"sync_period,attr,optional"` + IgnoreOlderThan time.Duration `alloy:"ignore_older_than,attr,optional"` } var _ component.Component = (*Component)(nil) @@ -81,9 +81,9 @@ func (c *Component) Update(args component.Arguments) error { c.watches = c.watches[:0] for _, v := range c.args.PathTargets { c.watches = append(c.watches, watch{ - target: v, - log: c.opts.Logger, - ignoreOlder: c.args.IgnoreOlder, + target: v, + log: c.opts.Logger, + ignoreOlderThan: c.args.IgnoreOlderThan, }) } diff --git a/internal/component/local/file_match/file_test.go b/internal/component/local/file_match/file_test.go index cd0d83a8b..63645315b 100644 --- a/internal/component/local/file_match/file_test.go +++ b/internal/component/local/file_match/file_test.go @@ -76,7 +76,7 @@ func TestFileIgnoreOlder(t *testing.T) { ct, ccl := context.WithTimeout(ct, 5*time.Second) defer ccl() c.args.SyncPeriod = 10 * time.Millisecond - c.args.IgnoreOlder = 100 * time.Millisecond + c.args.IgnoreOlderThan = 100 * time.Millisecond c.Update(c.args) go c.Run(ct) diff --git a/internal/component/local/file_match/watch.go b/internal/component/local/file_match/watch.go index 05a28935c..1b98b2b26 100644 --- a/internal/component/local/file_match/watch.go +++ b/internal/component/local/file_match/watch.go @@ -15,9 +15,9 @@ import ( // watch handles a single discovery.target for file watching. type watch struct { - target discovery.Target - log log.Logger - ignoreOlder time.Duration + target discovery.Target + log log.Logger + ignoreOlderThan time.Duration } func (w *watch) getPaths() ([]discovery.Target, error) { @@ -51,7 +51,7 @@ func (w *watch) getPaths() ([]discovery.Target, error) { continue } - if w.ignoreOlder != 0 && fi.ModTime().Before(time.Now().Add(-w.ignoreOlder)) { + if w.ignoreOlderThan != 0 && fi.ModTime().Before(time.Now().Add(-w.ignoreOlderThan)) { continue }