diff --git a/probe/docker/container.go b/probe/docker/container.go index 24727b46c..a559ba4b9 100644 --- a/probe/docker/container.go +++ b/probe/docker/container.go @@ -27,6 +27,7 @@ const ( ContainerCommand = "docker_container_command" ContainerPorts = "docker_container_ports" ContainerCreated = "docker_container_created" + ContainerNetworks = "docker_container_networks" ContainerIPs = "docker_container_ips" ContainerHostname = "docker_container_hostname" ContainerIPsWithScopes = "docker_container_ips_with_scopes" @@ -309,17 +310,29 @@ func addScopeToIPs(hostID string, ips []string) []string { func (c *container) NetworkInfo(localAddrs []net.IP) report.Sets { c.RLock() defer c.RUnlock() + + // For now, for the proof-of-concept, we just add networks as a set of + // names. For the next iteration, we will probably want to create a new + // Network topology, populate the network nodes with all of the details + // here, and provide foreign key links from nodes to networks. + networks := make([]string, 0, len(c.container.NetworkSettings.Networks)) + for name := range c.container.NetworkSettings.Networks { + networks = append(networks, name) + } + ips := c.container.NetworkSettings.SecondaryIPAddresses if c.container.NetworkSettings.IPAddress != "" { ips = append(ips, c.container.NetworkSettings.IPAddress) } + // Treat all Docker IPs as local scoped. ipsWithScopes := addScopeToIPs(c.hostID, ips) + return report.EmptySets. + Add(ContainerNetworks, report.MakeStringSet(networks...)). Add(ContainerPorts, c.ports(localAddrs)). Add(ContainerIPs, report.MakeStringSet(ips...)). Add(ContainerIPsWithScopes, report.MakeStringSet(ipsWithScopes...)) - } func (c *container) memoryUsageMetric(stats []docker.Stats) report.Metric { diff --git a/probe/docker/reporter.go b/probe/docker/reporter.go index 640689707..8fdbedfaf 100644 --- a/probe/docker/reporter.go +++ b/probe/docker/reporter.go @@ -26,9 +26,10 @@ var ( ImageID: {ID: ImageID, Label: "Image ID", From: report.FromLatest, Truncate: 12, Priority: 11}, ContainerUptime: {ID: ContainerUptime, Label: "Uptime", From: report.FromLatest, Priority: 12}, ContainerRestartCount: {ID: ContainerRestartCount, Label: "Restart #", From: report.FromLatest, Priority: 13}, - ContainerIPs: {ID: ContainerIPs, Label: "IPs", From: report.FromSets, Priority: 14}, - ContainerPorts: {ID: ContainerPorts, Label: "Ports", From: report.FromSets, Priority: 15}, - ContainerCreated: {ID: ContainerCreated, Label: "Created", From: report.FromLatest, Priority: 16}, + ContainerNetworks: {ID: ContainerNetworks, Label: "Networks", From: report.FromSets, Priority: 14}, + ContainerIPs: {ID: ContainerIPs, Label: "IPs", From: report.FromSets, Priority: 15}, + ContainerPorts: {ID: ContainerPorts, Label: "Ports", From: report.FromSets, Priority: 16}, + ContainerCreated: {ID: ContainerCreated, Label: "Created", From: report.FromLatest, Priority: 17}, } ContainerMetricTemplates = report.MetricTemplates{