Skip to content

Commit

Permalink
Fix issue where application ID of cloudfoundry.access events is incor…
Browse files Browse the repository at this point in the history
…rect. (#17847) (#17876)

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

* Add changelog entry.

* Add unit tests for cloudfoundry events.

(cherry picked from commit 08e1b2b)
  • Loading branch information
blakerouse authored Apr 21, 2020
1 parent 73d8b95 commit 1d4b29d
Show file tree
Hide file tree
Showing 3 changed files with 416 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,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]
- Fix issue 17734 to retry on rate-limit error in the Filebeat httpjson input. {issue}17734[17734] {pull}17735[17735]
- Remove migrationVersion map 7.7.0 reference from Kibana dashboard file to fix backward compatibility issues. {pull}17425[17425]
- 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

0 comments on commit 1d4b29d

Please sign in to comment.