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

Cherry-pick #18336 to 7.x: Add client address to events from http server module #18374

Merged
merged 1 commit into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Collect new `bulk` indexing metrics from Elasticsearch when `xpack.enabled:true` is set. {issue} {pull}17992[17992]
- Remove requirement to connect as sysdba in Oracle module {issue}15846[15846] {pull}18182[18182]
- Update MSSQL module to fix some SSPI authentication and add brackets to USE statements {pull}17862[17862]]
- Add client address to events from http server module {pull}18336[18336]

*Packetbeat*

Expand Down
3 changes: 2 additions & 1 deletion metricbeat/helper/server/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ func (h *HttpServer) handleFunc(writer http.ResponseWriter, req *http.Request) {
switch req.Method {
case "POST":
meta := server.Meta{
"path": req.URL.String(),
"path": req.URL.String(),
"address": req.RemoteAddr,
}

contentType := req.Header.Get("Content-Type")
Expand Down
5 changes: 4 additions & 1 deletion metricbeat/module/http/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ func (m *MetricSet) Run(reporter mb.PushReporterV2) {
if err != nil {
reporter.Error(err)
} else {
event := mb.Event{}
meta := msg.GetMeta()
event := mb.Event{
Host: meta["address"].(string),
}
ns, ok := fields[mb.NamespaceKey].(string)
if ok {
ns = fmt.Sprintf("http.%s", ns)
Expand Down