Skip to content
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

Allow autodiscover to monitor unexposed ports #6727

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di
- Set `service` as default metricset in Windows module. {pull}6675[6675]
- Set all metricsets as default metricsets in uwsgi module. {pull}6688[6688]
- Mark kubernetes.event metricset as beta. {pull}[]
- Allow autodiscover to monitor unexposed ports {pull}6727[6727]

*Packetbeat*

Expand Down
4 changes: 3 additions & 1 deletion metricbeat/autodiscover/builder/hints/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ func (m *metricHints) getHostsWithPort(hints common.MapStr, port int) []string {
// Only pick hosts that have ${data.port} or the port on current event. This will make
// sure that incorrect meta mapping doesn't happen
for _, h := range thosts {
if strings.Contains(h, "data.port") || strings.Contains(h, fmt.Sprintf(":%d", port)) {
if strings.Contains(h, "data.port") || strings.Contains(h, fmt.Sprintf(":%d", port)) ||
// Use the event that has no port config if there is a ${data.host}:9090 like input
(port == 0 && strings.Contains(h, "data.host")) {
result = append(result, h)
}
}
Expand Down
4 changes: 3 additions & 1 deletion metricbeat/autodiscover/builder/hints/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func TestGenerateHints(t *testing.T) {
},
},
{
message: "Module, namespace, host hint should return valid config without port should not return hosts",
message: "Module, namespace, host hint should return valid config with port should return hosts for " +
"docker host network scenario",
event: bus.Event{
"host": "1.2.3.4",
"hints": common.MapStr{
Expand All @@ -128,6 +129,7 @@ func TestGenerateHints(t *testing.T) {
"timeout": "3s",
"period": "1m",
"enabled": true,
"hosts": []interface{}{"1.2.3.4:9090"},
},
},
{
Expand Down