Skip to content

Commit c36648c

Browse files
Carlos Pérez-Aradros Hercevjsamuel
andauthored
Add client address to events from http server module (#18336) (#18374)
(cherry picked from commit da1ba72) Co-authored-by: Vijay Samuel <[email protected]>
1 parent d3bfed7 commit c36648c

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
500500
- Collect new `bulk` indexing metrics from Elasticsearch when `xpack.enabled:true` is set. {issue} {pull}17992[17992]
501501
- Remove requirement to connect as sysdba in Oracle module {issue}15846[15846] {pull}18182[18182]
502502
- Update MSSQL module to fix some SSPI authentication and add brackets to USE statements {pull}17862[17862]]
503+
- Add client address to events from http server module {pull}18336[18336]
503504

504505
*Packetbeat*
505506

metricbeat/helper/server/http/http.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ func (h *HttpServer) handleFunc(writer http.ResponseWriter, req *http.Request) {
138138
switch req.Method {
139139
case "POST":
140140
meta := server.Meta{
141-
"path": req.URL.String(),
141+
"path": req.URL.String(),
142+
"address": req.RemoteAddr,
142143
}
143144

144145
contentType := req.Header.Get("Content-Type")

metricbeat/module/http/server/server.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ func (m *MetricSet) Run(reporter mb.PushReporterV2) {
8080
if err != nil {
8181
reporter.Error(err)
8282
} else {
83-
event := mb.Event{}
83+
meta := msg.GetMeta()
84+
event := mb.Event{
85+
Host: meta["address"].(string),
86+
}
8487
ns, ok := fields[mb.NamespaceKey].(string)
8588
if ok {
8689
ns = fmt.Sprintf("http.%s", ns)

0 commit comments

Comments
 (0)