-
Notifications
You must be signed in to change notification settings - Fork 5k
Add integration/system tests for Kafka JMX metricsets #14677
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
51caad1
wip
ChrsMark 1fbbab5
Add integration tests for Kafka JMX metricsets
ChrsMark f2fb85b
Add system tests
ChrsMark d7ad564
Use paremeterized in system_tests
ChrsMark 7df6775
Increase timeout time in system tests
ChrsMark dfe4c10
Remove home path in beat start call
ChrsMark 7afd014
Fix permissions env
ChrsMark 81facf9
Move permission flag to python test
ChrsMark 46442e0
Make env setting default
ChrsMark f0d9a37
fix integration test
ChrsMark 9d229cd
Merge remote-tracking branch 'upstream/master' into add_jmx_kafka_tests
ChrsMark 83421f1
Add max_lag missing field
ChrsMark c34d0cc
Add final missing fields
ChrsMark d9944bd
Make use of NewFetcher in integration tests
ChrsMark 44e0c74
Update fields to follow naming conventions
ChrsMark 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 hidden or 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 hidden or 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 hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,12 @@ | |||||
| - name: request.fetch.failed_per_second | ||||||
| description: The rate of client fetch request failures per second | ||||||
| type: float | ||||||
| - name: request.produce.failed | ||||||
| description: The number of failed produce requests | ||||||
| type: float | ||||||
| - name: request.fetch.failed | ||||||
| description: The number of client fetch request failures | ||||||
| type: float | ||||||
| - name: replication.leader_elections | ||||||
| description: The leader election rate | ||||||
| type: float | ||||||
|
|
@@ -37,14 +43,26 @@ | |||||
| description: The log flush rate | ||||||
| type: float | ||||||
| - name: topic.net.bytes_in | ||||||
| description: The incoming byte rate | ||||||
| description: The incoming byte rate per topic | ||||||
| type: float | ||||||
| - name: topic.net.bytes_out | ||||||
| description: The outgoing byte rate | ||||||
| description: The outgoing byte rate per topic | ||||||
| type: float | ||||||
| - name: topic.net.bytes_rejected | ||||||
| description: The rejected byte rate | ||||||
| description: The rejected byte rate per topic | ||||||
| type: float | ||||||
| - name: topic.messages_in | ||||||
| description: The incoming message rate per topic | ||||||
| type: float | ||||||
| - name: net.bytes_in | ||||||
| description: The incoming byte rate | ||||||
| type: float | ||||||
| - name: net.bytes_out | ||||||
|
Contributor
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. And:
Suggested change
|
||||||
| description: The outgoing byte rate | ||||||
| type: float | ||||||
| - name: net.bytes_rejected | ||||||
|
Contributor
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. And:
Suggested change
|
||||||
| description: The rejected byte rate | ||||||
| type: float | ||||||
| - name: messages_in | ||||||
| description: The incoming message rate | ||||||
| type: float | ||||||
This file contains hidden or 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,66 @@ | ||
| // Licensed to Elasticsearch B.V. under one or more contributor | ||
| // license agreements. See the NOTICE file distributed with | ||
| // this work for additional information regarding copyright | ||
| // ownership. Elasticsearch B.V. licenses this file to you under | ||
| // the Apache License, Version 2.0 (the "License"); you may | ||
| // not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| // +build integration | ||
|
|
||
| package broker | ||
|
|
||
| import ( | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/elastic/beats/libbeat/tests/compose" | ||
| mbtest "github.com/elastic/beats/metricbeat/mb/testing" | ||
| // Register input module and metricset | ||
| _ "github.com/elastic/beats/metricbeat/module/jolokia" | ||
| _ "github.com/elastic/beats/metricbeat/module/jolokia/jmx" | ||
| ) | ||
|
|
||
| func TestData(t *testing.T) { | ||
| service := compose.EnsureUp(t, "kafka", | ||
| compose.UpWithTimeout(600*time.Second), | ||
| compose.UpWithAdvertisedHostEnvFileForPort(9092), | ||
| ) | ||
|
|
||
| ms := mbtest.NewReportingMetricSetV2Error(t, getConfig(service.HostForPort(8779))) | ||
| err := mbtest.WriteEventsReporterV2Error(ms, t, "") | ||
| if err != nil { | ||
| t.Fatal("write", err) | ||
| } | ||
|
ChrsMark marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| func TestFetch(t *testing.T) { | ||
| service := compose.EnsureUp(t, "kafka", | ||
| compose.UpWithTimeout(600*time.Second), | ||
| compose.UpWithAdvertisedHostEnvFileForPort(9092), | ||
| ) | ||
| reporter := &mbtest.CapturingReporterV2{} | ||
|
|
||
| metricSet := mbtest.NewReportingMetricSetV2Error(t, getConfig(service.HostForPort(8779))) | ||
|
ChrsMark marked this conversation as resolved.
Outdated
|
||
| metricSet.Fetch(reporter) | ||
|
|
||
| e := mbtest.StandardizeEvent(metricSet, reporter.GetEvents()[0]) | ||
| t.Logf("%s/%s event: %+v", metricSet.Module().Name(), metricSet.Name(), e.Fields.StringToPrint()) | ||
| } | ||
|
|
||
| func getConfig(host string) map[string]interface{} { | ||
| return map[string]interface{}{ | ||
| "module": "kafka", | ||
| "metricsets": []string{"broker"}, | ||
| "hosts": []string{host}, | ||
| } | ||
| } | ||
This file contains hidden or 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,33 @@ | ||
| // Licensed to Elasticsearch B.V. under one or more contributor | ||
| // license agreements. See the NOTICE file distributed with | ||
| // this work for additional information regarding copyright | ||
| // ownership. Elasticsearch B.V. licenses this file to you under | ||
| // the Apache License, Version 2.0 (the "License"); you may | ||
| // not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| package broker | ||
|
|
||
| import ( | ||
| "os" | ||
|
|
||
| "github.com/elastic/beats/metricbeat/mb" | ||
| // Register input module and metricset | ||
| _ "github.com/elastic/beats/metricbeat/module/jolokia" | ||
| _ "github.com/elastic/beats/metricbeat/module/jolokia/jmx" | ||
| ) | ||
|
|
||
| func init() { | ||
| // To be moved to some kind of helper | ||
| os.Setenv("BEAT_STRICT_PERMS", "false") | ||
| mb.Registry.SetSecondarySource(mb.NewLightModulesSource("../../../module")) | ||
| } |
This file contains hidden or 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 hidden or 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.
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.
Following field conventions this should probably be:
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.
@sorantis is this ok from product perspective or we should strictly follow the naming provided in the initial issue?
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.
there's no strict requirement on the naming. The field names were taken from the ER attached to the original issue. Do we have the mentioned naming convention somewhere?
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.
You can find the conventions here: https://www.elastic.co/guide/en/beats/devguide/7.5/event-conventions.html