-
Notifications
You must be signed in to change notification settings - Fork 5k
Initialize support for ignore_inactive in filestream input #25036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
77809ee
9d95880
1998177
c682900
3c6caf8
b1b5eb8
cbf9923
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,6 +239,8 @@ func NewBeat(name, indexPrefix, v string, elasticLicensed bool) (*Beat, error) { | |
| Name: hostname, | ||
| Hostname: hostname, | ||
| ID: id, | ||
| FirstStart: time.Now(), | ||
| StartTime: time.Now(), | ||
| EphemeralID: metrics.EphemeralID(), | ||
| }, | ||
| Fields: fields, | ||
|
|
@@ -695,7 +697,8 @@ func (b *Beat) configure(settings Settings) error { | |
|
|
||
| func (b *Beat) loadMeta(metaPath string) error { | ||
| type meta struct { | ||
| UUID uuid.UUID `json:"uuid"` | ||
| UUID uuid.UUID `json:"uuid"` | ||
| FirstStart time.Time `json:"first_start"` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will need some testing. the stdlib JSON encoder/decoder might not play well with that type.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my manual tests, it worked like a charm. What might be the problem? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My concern would be that timestamp serialization and parsing is not supported. If it works +1. We have some tests for loadMeta I think. Still would be nice to enhance the existing tests. |
||
| } | ||
|
|
||
| logp.Debug("beat", "Beat metadata path: %v", metaPath) | ||
|
|
@@ -713,14 +716,21 @@ func (b *Beat) loadMeta(metaPath string) error { | |
| } | ||
|
|
||
| f.Close() | ||
|
|
||
| if !m.FirstStart.IsZero() { | ||
| b.Info.FirstStart = m.FirstStart | ||
| } | ||
| valid := m.UUID != uuid.Nil | ||
| if valid { | ||
| b.Info.ID = m.UUID | ||
| } | ||
|
|
||
| if valid && !m.FirstStart.IsZero() { | ||
| return nil | ||
| } | ||
| } | ||
|
|
||
| // file does not exist or ID is invalid, let's create a new one | ||
| // file does not exist or ID is invalid or first start time is not defined, let's create a new one | ||
|
|
||
| // write temporary file first | ||
| tempFile := metaPath + ".new" | ||
|
|
@@ -729,7 +739,7 @@ func (b *Beat) loadMeta(metaPath string) error { | |
| return fmt.Errorf("Failed to create Beat meta file: %s", err) | ||
| } | ||
|
|
||
| encodeErr := json.NewEncoder(f).Encode(meta{UUID: b.Info.ID}) | ||
| encodeErr := json.NewEncoder(f).Encode(meta{UUID: b.Info.ID, FirstStart: b.Info.FirstStart}) | ||
| err = f.Sync() | ||
| if err != nil { | ||
| return fmt.Errorf("Beat meta file failed to write: %s", err) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.