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

Fix issue where application ID of cloudfoundry.access events is incorrect. #17847

Merged
merged 3 commits into from
Apr 21, 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 @@ -111,6 +111,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fixed activemq module causing "regular expression has redundant nested repeat operator" warning in Elasticsearch. {pull}17428[17428]
- Remove migrationVersion map 7.7.0 reference from Kibana dashboard file to fix backward compatibility issues. {pull}17425[17425]
- Fix issue 17734 to retry on rate-limit error in the Filebeat httpjson input. {issue}17734[17734] {pull}17735[17735]
- Fixed `cloudfoundry.access` to have the correct `cloudfoundry.app.id` contents. {pull}17847[17847]

*Heartbeat*

Expand Down
19 changes: 13 additions & 6 deletions x-pack/libbeat/common/cloudfoundry/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package cloudfoundry

import (
"encoding/binary"
"fmt"
"net/url"
"strings"
Expand Down Expand Up @@ -377,18 +378,14 @@ func newEventBase(env *events.Envelope) eventBase {

func newEventHttpAccess(env *events.Envelope) *EventHttpAccess {
msg := env.GetHttpStartStop()
appID := ""
if msg.ApplicationId != nil {
appID = msg.ApplicationId.String()
}
return &EventHttpAccess{
eventAppBase: eventAppBase{
eventBase: newEventBase(env),
appGuid: appID,
appGuid: formatUUID(msg.ApplicationId),
},
startTimestamp: time.Unix(0, *msg.StartTimestamp),
stopTimestamp: time.Unix(0, *msg.StopTimestamp),
requestID: msg.RequestId.String(),
requestID: formatUUID(msg.RequestId),
peerType: strings.ToLower(msg.PeerType.String()),
method: msg.Method.String(),
uri: *msg.Uri,
Expand Down Expand Up @@ -525,3 +522,13 @@ func urlMap(uri string) common.MapStr {
"domain": u.Hostname(),
}
}

func formatUUID(uuid *events.UUID) string {
if uuid == nil {
return ""
}
var uuidBytes [16]byte
binary.LittleEndian.PutUint64(uuidBytes[:8], uuid.GetLow())
binary.LittleEndian.PutUint64(uuidBytes[8:], uuid.GetHigh())
return fmt.Sprintf("%x-%x-%x-%x-%x", uuidBytes[0:4], uuidBytes[4:6], uuidBytes[6:8], uuidBytes[8:10], uuidBytes[10:])
}
Loading