forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 1
/
data.go
38 lines (33 loc) · 818 Bytes
/
data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package image
import (
"time"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/metricbeat/module/docker"
dc "github.com/fsouza/go-dockerclient"
)
func eventsMapping(imagesList []dc.APIImages) []common.MapStr {
events := []common.MapStr{}
for _, image := range imagesList {
events = append(events, eventMapping(&image))
}
return events
}
func eventMapping(image *dc.APIImages) common.MapStr {
event := common.MapStr{
"id": common.MapStr{
"current": image.ID,
"parent": image.ParentID,
},
"created": common.Time(time.Unix(image.Created, 0)),
"size": common.MapStr{
"regular": image.Size,
"virtual": image.VirtualSize,
},
"tags": image.RepoTags,
}
labels := docker.DeDotLabels(image.Labels)
if len(labels) > 0 {
event["labels"] = labels
}
return event
}