-
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] Migrate Ceph monitor_health to use ReporterV2 interface #11012
Merged
sayden
merged 5 commits into
elastic:master
from
sayden:migration/mb/reporterv2/ceph/monitor_health
Apr 3, 2019
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions
3
metricbeat/module/ceph/monitor_health/_meta/testdata/config.yml
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type: http | ||
url: "/api/v0.1/health" | ||
suffix: plain |
1 change: 1 addition & 0 deletions
1
metricbeat/module/ceph/monitor_health/_meta/testdata/input.plain
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{"status": "OK", "output": {"detail": [], "timechecks": {"round_status": "finished", "epoch": 3, "round": 0}, "health": {"health_services": [{"mons": [{"last_updated": "2019-03-13 11:21:24.667025", "name": "26c372192772", "avail_percent": 82, "kb_total": 936145620, "kb_avail": 773013080, "health": "HEALTH_OK", "kb_used": 115509168, "store_stats": {"bytes_total": 4195407, "bytes_log": 4128768, "last_updated": "0.000000", "bytes_misc": 65552, "bytes_sst": 1087}}]}]}, "overall_status": "HEALTH_OK", "summary": []}} | ||
48 changes: 48 additions & 0 deletions
48
metricbeat/module/ceph/monitor_health/_meta/testdata/input.plain-expected.json
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[ | ||
{ | ||
"ceph": { | ||
"monitor_health": { | ||
"available": { | ||
"kb": 773013080, | ||
"pct": 82 | ||
}, | ||
"health": "HEALTH_OK", | ||
"last_updated": "2019-03-13T11:21:24.667025Z", | ||
"name": "26c372192772", | ||
"store_stats": { | ||
"last_updated": "0.000000", | ||
"log": { | ||
"bytes": 4128768 | ||
}, | ||
"misc": { | ||
"bytes": 65552 | ||
}, | ||
"sst": { | ||
"bytes": 1087 | ||
}, | ||
"total": { | ||
"bytes": 4195407 | ||
} | ||
}, | ||
"total": { | ||
"kb": 936145620 | ||
}, | ||
"used": { | ||
"kb": 115509168 | ||
} | ||
} | ||
}, | ||
"event": { | ||
"dataset": "ceph.monitor_health", | ||
"duration": 115000, | ||
"module": "ceph" | ||
}, | ||
"metricset": { | ||
"name": "monitor_health" | ||
}, | ||
"service": { | ||
"address": "127.0.0.1:55555", | ||
"type": "ceph" | ||
} | ||
} | ||
] |
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
65 changes: 0 additions & 65 deletions
65
metricbeat/module/ceph/monitor_health/monitor_health_integration_test.go
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -32,6 +32,7 @@ import ( | |
|
||
func TestFetchEventContents(t *testing.T) { | ||
absPath, err := filepath.Abs("../_meta/testdata/") | ||
assert.NoError(t, 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. 👍 |
||
|
||
response, err := ioutil.ReadFile(absPath + "/sample_response.json") | ||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
|
@@ -47,12 +48,13 @@ func TestFetchEventContents(t *testing.T) { | |
"hosts": []string{server.URL}, | ||
} | ||
|
||
f := mbtest.NewEventsFetcher(t, config) | ||
events, err := f.Fetch() | ||
if err != nil { | ||
t.Fatal(err) | ||
f := mbtest.NewReportingMetricSetV2Error(t, config) | ||
events, errs := mbtest.ReportingFetchV2Error(f) | ||
if len(errs) > 0 { | ||
t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs) | ||
} | ||
event := events[0] | ||
assert.NotEmpty(t, events) | ||
event := events[0].MetricSetFields | ||
|
||
t.Logf("%s/%s event: %+v", f.Module().Name(), f.Name(), event.StringToPrint()) | ||
|
||
|
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.
Why is the suffix of this
.plain
? Looks like json to me.If you rename this to
docs.json
and remove thesuffix
config inconfig.yml
and then run-generate
, this should directly als update thedata.json
file.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.
@sayden I see you went now with
input.json
instead ofdocs.json
as recommended above to have thedata.json
generated. Could you elaborate?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.
I thought that you mean
docs.json
likefoo.json
and that name didn't matter 😅 In any case,input
ordoc
, it won't generate adata.json
named file but adocs.json-expected.json
, right? Now I'm not sure if I'm missing something elseThere 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.
yes: https://github.com/elastic/beats/blob/master/metricbeat/mb/testing/data/data_test.go#L179
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.
Ah! Now I understand, I misunderstood completely at the beginning. Thanks for the clarification :)