-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[metricbeat] - Allow metricsets to report their status via v2 protocol #40025
Merged
VihasMakwana
merged 35 commits into
elastic:main
from
VihasMakwana:add-metricbeat-status-reporter
Jul 24, 2024
Merged
Changes from 33 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
f87e6bb
fix: initial commit
VihasMakwana 98108a1
tests: add integration test cases
VihasMakwana e37ef86
fix: expand testing scenarios
VihasMakwana 258c786
fix: add comments
VihasMakwana d7cecfe
fix: move integration tests to system/process
VihasMakwana feaa0fa
cleanup
VihasMakwana 5f35ae5
fix: ci
VihasMakwana ecdfa1e
fix: ci and typos
VihasMakwana 6c877bb
chore: update changelog
VihasMakwana 19b82c7
fix: add helper
VihasMakwana 52cd0ed
fix: remove extra space
VihasMakwana 735c611
Merge branch 'main' into add-metricbeat-status-reporter
VihasMakwana 2fa72c9
fix: ci
VihasMakwana 06c98f4
fix: move integration tests to x-pack
VihasMakwana bdd1464
fix: add null check
VihasMakwana c7b9766
fix: ci
VihasMakwana d0fc62c
Merge branch 'main' into add-metricbeat-status-reporter
pierrehilbert b6814a4
Merge branch 'forked/main' into add-metricbeat-status-reporter
VihasMakwana 6785fe7
fix: remove unused code
VihasMakwana a049950
fix: lint
VihasMakwana f3f137f
fix: lint and imports
VihasMakwana 4cb011b
Merge branch 'main' into add-metricbeat-status-reporter
VihasMakwana 5ffaa6a
fix: ci windows
VihasMakwana bb6800b
Merge branch 'main' into add-metricbeat-status-reporter
VihasMakwana 9d9bcda
inting for windows
VihasMakwana 8dd335a
fix lint linux
VihasMakwana 8dc7b96
fix: go imports
VihasMakwana c7bea06
Merge branch 'main' into add-metricbeat-status-reporter
VihasMakwana 071267c
Merge branch 'main' into add-metricbeat-status-reporter
pierrehilbert 6e88ac5
fix: switch to the generic way
VihasMakwana eaf18fa
chore: make error descriptive
VihasMakwana 959014d
fix: move status report after fetch
VihasMakwana 2f06c14
fix: typo
VihasMakwana abcb26a
Merge branch 'main' into add-metricbeat-status-reporter
VihasMakwana 6d5f22f
fix: remove nolint
VihasMakwana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import ( | |
|
||
"github.com/elastic/beats/v7/libbeat/beat" | ||
"github.com/elastic/beats/v7/libbeat/common" | ||
"github.com/elastic/beats/v7/libbeat/management/status" | ||
"github.com/elastic/beats/v7/metricbeat/mb" | ||
conf "github.com/elastic/elastic-agent-libs/config" | ||
"github.com/elastic/elastic-agent-libs/logp" | ||
|
@@ -146,6 +147,7 @@ func (mw *Wrapper) Start(done <-chan struct{}) <-chan beat.Event { | |
registry.Add(metricsPath, msw.Metrics(), monitoring.Full) | ||
monitoring.NewString(msw.Metrics(), "starttime").Set(common.Time(time.Now()).String()) | ||
|
||
msw.module.UpdateStatus(status.Starting, fmt.Sprintf("%s/%s is starting", msw.module.Name(), msw.Name())) | ||
msw.run(done, out) | ||
}(msw) | ||
} | ||
|
@@ -253,14 +255,20 @@ func (msw *metricSetWrapper) fetch(ctx context.Context, reporter reporter) { | |
err := fetcher.Fetch(reporter.V2()) | ||
if err != nil { | ||
reporter.V2().Error(err) | ||
msw.module.UpdateStatus(status.Degraded, fmt.Sprintf("Error fetching data for metricset %s.%s: %s", msw.module.Name(), msw.MetricSet.Name(), err)) | ||
logp.Err("Error fetching data for metricset %s.%s: %s", msw.module.Name(), msw.Name(), err) | ||
} else { | ||
msw.module.UpdateStatus(status.Running, "") | ||
} | ||
case mb.ReportingMetricSetV2WithContext: | ||
reporter.StartFetchTimer() | ||
err := fetcher.Fetch(ctx, reporter.V2()) | ||
if err != nil { | ||
reporter.V2().Error(err) | ||
msw.module.UpdateStatus(status.Degraded, fmt.Sprintf("Error fetching data for metricset %s.%s: %s", msw.module.Name(), msw.MetricSet.Name(), err)) | ||
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. nit: use %v for the err 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. @pkoutsovasilis I didn't see this. |
||
logp.Err("Error fetching data for metricset %s.%s: %s", msw.module.Name(), msw.Name(), err) | ||
} else { | ||
msw.module.UpdateStatus(status.Running, "") | ||
} | ||
default: | ||
panic(fmt.Sprintf("unexpected fetcher type for %v", msw)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use %v for the err