Skip to content

Commit

Permalink
Remove container_name from Metricbeat autodiscover eventID
Browse files Browse the repository at this point in the history
In Metricbeat we don't want to have different eventIDs for
containers within the same Pod, since these containers
share the same IP and handling them seperately can lead in
launching hint based modules for all of the containers.

Signed-off-by: chrismark <[email protected]>
  • Loading branch information
ChrsMark committed Nov 26, 2019
1 parent 87c49ac commit c79a817
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libbeat/autodiscover/providers/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ func (p *Provider) emitEvents(pod *kubernetes.Pod, flag string, containers []kub

// This must be an id that doesn't depend on the state of the container
// so it works also on `stop` if containers have been already deleted.
eventID := fmt.Sprintf("%s.%s", pod.GetObjectMeta().GetUID(), c.Name)
eventID := fmt.Sprintf("%s", pod.GetObjectMeta().GetUID())
if p.bus.GetName() != "metricbeat" {
eventID = fmt.Sprintf("%s.%s", eventID, c.Name)
}

cmeta := common.MapStr{
"id": cid,
Expand Down
8 changes: 8 additions & 0 deletions libbeat/common/bus/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ type Event common.MapStr

// Bus provides a common channel to emit and listen for Events
type Bus interface {
// New initializes a new bus with the given name and returns it
GetName() string

// Publish an event to the bus
Publish(Event)

Expand Down Expand Up @@ -76,6 +79,11 @@ func NewBusWithStore(name string, size int) Bus {
}
}

// GetName returns the name of the bus
func (b *bus) GetName() string {
return b.name
}

func (b *bus) Publish(e Event) {
b.RLock()
defer b.RUnlock()
Expand Down

0 comments on commit c79a817

Please sign in to comment.