Documentation ¶
Index ¶
- Constants
- Variables
- func GetRenderableContainerName(nmd report.Node) (string, bool)
- func ImageNameWithoutVersion(name string) string
- func LocalNetworks(r report.Report) report.Networks
- func MakeAddressID(hostID, addr string) string
- func MakeContainerID(containerID string) string
- func MakeContainerImageID(imageID string) string
- func MakeEndpointID(hostID, addr, port string) string
- func MakeHostID(hostID string) string
- func MakePodID(podID string) string
- func MakeProcessID(hostID, pid string) string
- func MakePseudoNodeID(parts ...string) string
- func MakeServiceID(serviceID string) string
- func ResetCache()
- type CustomRenderer
- type Diff
- type Filter
- type Map
- type MapFunc
- type Reduce
- type RenderableNode
- type RenderableNodes
- func MakeRenderableNodes(t report.Topology) RenderableNodes
- func MapAddressIdentity(m RenderableNode, local report.Networks) RenderableNodes
- func MapContainer2ContainerImage(n RenderableNode, _ report.Networks) RenderableNodes
- func MapContainer2Hostname(n RenderableNode, _ report.Networks) RenderableNodes
- func MapContainer2IP(m RenderableNode, _ report.Networks) RenderableNodes
- func MapContainer2Pod(n RenderableNode, _ report.Networks) RenderableNodes
- func MapContainerIdentity(m RenderableNode, _ report.Networks) RenderableNodes
- func MapContainerImage2Name(n RenderableNode, _ report.Networks) RenderableNodes
- func MapContainerImageIdentity(m RenderableNode, _ report.Networks) RenderableNodes
- func MapCountContainers(n RenderableNode, _ report.Networks) RenderableNodes
- func MapCountPods(n RenderableNode, _ report.Networks) RenderableNodes
- func MapCountProcessName(n RenderableNode, _ report.Networks) RenderableNodes
- func MapEndpoint2IP(m RenderableNode, local report.Networks) RenderableNodes
- func MapEndpoint2Process(n RenderableNode, _ report.Networks) RenderableNodes
- func MapEndpointIdentity(m RenderableNode, local report.Networks) RenderableNodes
- func MapHostIdentity(m RenderableNode, _ report.Networks) RenderableNodes
- func MapIP2Container(n RenderableNode, _ report.Networks) RenderableNodes
- func MapPod2Service(n RenderableNode, _ report.Networks) RenderableNodes
- func MapPodIdentity(m RenderableNode, _ report.Networks) RenderableNodes
- func MapProcess2Container(n RenderableNode, _ report.Networks) RenderableNodes
- func MapProcess2Name(n RenderableNode, _ report.Networks) RenderableNodes
- func MapProcessIdentity(m RenderableNode, _ report.Networks) RenderableNodes
- func MapServiceIdentity(m RenderableNode, _ report.Networks) RenderableNodes
- func MapX2Host(n RenderableNode, _ report.Networks) RenderableNodes
- type Renderer
- func ColorConnected(r Renderer) Renderer
- func FilterNoop(in Renderer) Renderer
- func FilterPseudo(r Renderer) Renderer
- func FilterStopped(r Renderer) Renderer
- func FilterSystem(r Renderer) Renderer
- func FilterUnconnected(r Renderer) Renderer
- func MakeFilter(f func(RenderableNode) bool, r Renderer) Renderer
- func MakeMap(f MapFunc, r Renderer) Renderer
- func MakeReduce(renderers ...Renderer) Renderer
- func Memoise(r Renderer) Renderer
- type Stats
- type TopologySelector
Constants ¶
const ( UncontainedID = "uncontained" UncontainedMajor = "Uncontained" TheInternetID = "theinternet" TheInternetMajor = "The Internet" ContainersKey = "containers" AmazonECSContainerNameLabel = "com.amazonaws.ecs.container-name" KubernetesContainerNameLabel = "io.kubernetes.container.name" )
Constants are used in the tests.
const ( Circle = "circle" Square = "square" Heptagon = "heptagon" Hexagon = "hexagon" Cloud = "cloud" )
Shapes that are allowed
const IsConnected = "is_connected"
IsConnected is the key added to Node.Metadata by ColorConnected to indicate a node has an edge pointing to it or from it
Variables ¶
var ( // SelectEndpoint selects the endpoint topology. SelectEndpoint = TopologySelector(func(r report.Report) RenderableNodes { return MakeRenderableNodes(r.Endpoint) }) // SelectProcess selects the process topology. SelectProcess = TopologySelector(func(r report.Report) RenderableNodes { return MakeRenderableNodes(r.Process) }) // SelectContainer selects the container topology. SelectContainer = TopologySelector(func(r report.Report) RenderableNodes { return MakeRenderableNodes(r.Container) }) // SelectContainerImage selects the container image topology. SelectContainerImage = TopologySelector(func(r report.Report) RenderableNodes { return MakeRenderableNodes(r.ContainerImage) }) // SelectAddress selects the address topology. SelectAddress = TopologySelector(func(r report.Report) RenderableNodes { return MakeRenderableNodes(r.Address) }) // SelectHost selects the address topology. SelectHost = TopologySelector(func(r report.Report) RenderableNodes { return MakeRenderableNodes(r.Host) }) // SelectPod selects the pod topology. SelectPod = TopologySelector(func(r report.Report) RenderableNodes { return MakeRenderableNodes(r.Pod) }) // SelectService selects the service topology. SelectService = TopologySelector(func(r report.Report) RenderableNodes { return MakeRenderableNodes(r.Service) }) )
var AddressRenderer = MakeMap( MapAddressIdentity, SelectAddress, )
AddressRenderer is a Renderer which produces a renderable address graph from the address topology.
var ContainerHostnameRenderer = MakeMap( MapCountContainers, MakeMap( MapContainer2Hostname, ContainerRenderer, ), )
ContainerHostnameRenderer is a Renderer which produces a renderable container by hostname graph..
var ContainerImageRenderer = MakeMap( MapCountContainers, MakeMap( MapContainerImage2Name, MakeReduce( MakeMap( MapContainer2ContainerImage, ContainerRenderer, ), MakeMap( MapContainerImageIdentity, SelectContainerImage, ), ), ), )
ContainerImageRenderer is a Renderer which produces a renderable container image graph by merging the container graph and the container image topology.
var ContainerRenderer = MakeReduce( MakeFilter( func(n RenderableNode) bool { _, inContainer := n.Node.Latest.Lookup(docker.ContainerID) _, isConnected := n.Node.Latest.Lookup(IsConnected) return inContainer || isConnected }, MakeMap( MapProcess2Container, ColorConnected(ProcessRenderer), ), ), FilterUnconnected(MakeMap( MapIP2Container, MakeReduce( MakeMap( MapContainer2IP, SelectContainer, ), MakeMap( MapEndpoint2IP, SelectEndpoint, ), ), )), MakeMap( MapContainerIdentity, SelectContainer, ), )
ContainerRenderer is a Renderer which produces a renderable container graph by merging the process graph and the container topology. NB We only want processes in container _or_ processes with network connections but we need to be careful to ensure we only include each edge once, by only including the ProcessRenderer once.
var ContainerWithHostIPsRenderer = containerWithHostIPsRenderer{ContainerRenderer}
ContainerWithHostIPsRenderer is a Renderer which produces a container graph enriched with host IPs on containers where NetworkMode is Host
var ContainerWithImageNameRenderer = containerWithImageNameRenderer{ContainerWithHostIPsRenderer}
ContainerWithImageNameRenderer is a Renderer which produces a container graph where the ranks are the image names, not their IDs
var EndpointRenderer = MakeMap( MapEndpointIdentity, SelectEndpoint, )
EndpointRenderer is a Renderer which produces a renderable endpoint graph.
var HostRenderer = MakeReduce( MakeMap( MapX2Host, FilterPseudo(ContainerImageRenderer), ), MakeMap( MapX2Host, MakeMap( MapPodIdentity, SelectPod, ), ), MakeMap( MapX2Host, AddressRenderer, ), MakeMap( MapHostIdentity, SelectHost, ), )
HostRenderer is a Renderer which produces a renderable host graph from the host topology and address graph.
var PodRenderer = MakeMap( MapCountContainers, MakeReduce( MakeMap( MapContainer2Pod, ContainerRenderer, ), MakeMap( MapPodIdentity, SelectPod, ), ), )
PodRenderer is a Renderer which produces a renderable kubernetes graph by merging the container graph and the pods topology.
var PodServiceRenderer = MakeMap( MapCountPods, MakeReduce( MakeMap( MapPod2Service, PodRenderer, ), MakeMap( MapServiceIdentity, SelectService, ), ), )
PodServiceRenderer is a Renderer which produces a renderable kubernetes services graph by merging the pods graph and the services topology.
var ProcessNameRenderer = MakeMap( MapCountProcessName, MakeMap( MapProcess2Name, ProcessRenderer, ), )
ProcessNameRenderer is a Renderer which produces a renderable process name graph by munging the progess graph.
var ProcessRenderer = MakeReduce( MakeMap( MapEndpoint2Process, EndpointRenderer, ), MakeMap( MapProcessIdentity, SelectProcess, ), )
ProcessRenderer is a Renderer which produces a renderable process graph by merging the endpoint graph and the process topology.
var ProcessWithContainerNameRenderer = processWithContainerNameRenderer{ProcessRenderer}
ProcessWithContainerNameRenderer is a Renderer which produces a process graph enriched with container names where appropriate
Functions ¶
func GetRenderableContainerName ¶ added in v0.7.0
GetRenderableContainerName obtains a user-friendly container name, to render in the UI
func ImageNameWithoutVersion ¶ added in v0.12.0
ImageNameWithoutVersion splits the image name apart, returning the name without the version, if possible
func LocalNetworks ¶
LocalNetworks returns a superset of the networks (think: CIDRs) that are "local" from the perspective of each host represented in the report. It's used to determine which nodes in the report are "remote", i.e. outside of our infrastructure.
func MakeAddressID ¶
MakeAddressID makes an address node ID for rendered nodes.
func MakeContainerID ¶ added in v0.12.0
MakeContainerID makes a container node ID for rendered nodes.
func MakeContainerImageID ¶ added in v0.12.0
MakeContainerImageID makes a container image node ID for rendered nodes.
func MakeEndpointID ¶
MakeEndpointID makes an endpoint node ID for rendered nodes.
func MakeHostID ¶
MakeHostID makes a host node ID for rendered nodes.
func MakeProcessID ¶
MakeProcessID makes a process node ID for rendered nodes.
func MakePseudoNodeID ¶
MakePseudoNodeID produces a pseudo node ID from its composite parts, for use in rendered nodes.
func MakeServiceID ¶ added in v0.12.0
MakeServiceID makes a service node ID for rendered nodes.
Types ¶
type CustomRenderer ¶ added in v0.7.0
type CustomRenderer struct { RenderFunc func(RenderableNodes) RenderableNodes Renderer }
CustomRenderer allow for mapping functions that recived the entire topology in one call - useful for functions that need to consider the entire graph. We should minimise the use of this renderer type, as it is very inflexible.
func (CustomRenderer) Render ¶ added in v0.7.0
func (c CustomRenderer) Render(rpt report.Report) RenderableNodes
Render implements Renderer
type Diff ¶
type Diff struct { Add []RenderableNode `json:"add"` Update []RenderableNode `json:"update"` Remove []string `json:"remove"` }
Diff is returned by TopoDiff. It represents the changes between two RenderableNode maps.
func TopoDiff ¶
func TopoDiff(a, b RenderableNodes) Diff
TopoDiff gives you the diff to get from A to B.
type Filter ¶ added in v0.7.0
type Filter struct { Renderer FilterFunc func(RenderableNode) bool }
Filter removes nodes from a view based on a predicate.
type Map ¶
Map is a Renderer which produces a set of RenderableNodes from the set of RenderableNodes produced by another Renderer.
type MapFunc ¶
type MapFunc func(RenderableNode, report.Networks) RenderableNodes
MapFunc is anything which can take an arbitrary RenderableNode and return a set of other RenderableNodes.
If the output is empty, the node shall be omitted from the rendered topology.
type Reduce ¶
type Reduce []Renderer
Reduce renderer is a Renderer which merges together the output of several other renderers.
type RenderableNode ¶
type RenderableNode struct { ID string `json:"id"` // LabelMajor string `json:"label_major"` // e.g. "process", human-readable LabelMinor string `json:"label_minor,omitempty"` // e.g. "hostname", human-readable, optional Rank string `json:"rank"` // to help the layout engine Pseudo bool `json:"pseudo,omitempty"` // sort-of a placeholder node, for rendering purposes Children report.NodeSet `json:"children,omitempty"` // Nodes which have been grouped into this one ControlNode string `json:"-"` // ID of node from which to show the controls in the UI Shape string `json:"shape"` // Shape node should be rendered as Stack bool `json:"stack"` // Should UI render this node as a stack? report.EdgeMetadata `json:"metadata"` // Numeric sums report.Node }
RenderableNode is the data type that's yielded to the JavaScript layer as an element of a topology. It should contain information that's relevant to rendering a node when there are many nodes visible at once.
func NewDerivedNode ¶ added in v0.7.0
func NewDerivedNode(id string, node RenderableNode) RenderableNode
NewDerivedNode create a renderable node based on node, but with a new ID
func NewRenderableNode ¶
func NewRenderableNode(id string) RenderableNode
NewRenderableNode makes a new RenderableNode
func NewRenderableNodeWith ¶ added in v0.7.0
func NewRenderableNodeWith(id, major, minor, rank string, node RenderableNode) RenderableNode
NewRenderableNodeWith makes a new RenderableNode with some fields filled in
func (RenderableNode) Copy ¶ added in v0.7.0
func (rn RenderableNode) Copy() RenderableNode
Copy makes a deep copy of rn
func (RenderableNode) Merge ¶
func (rn RenderableNode) Merge(other RenderableNode) RenderableNode
Merge merges rn with other and returns a new RenderableNode
func (RenderableNode) Prune ¶ added in v0.7.0
func (rn RenderableNode) Prune() RenderableNode
Prune returns a copy of the RenderableNode with all information not strictly necessary for rendering nodes and edges stripped away. Specifically, that means cutting out parts of the Node.
func (RenderableNode) WithNode ¶ added in v0.7.0
func (rn RenderableNode) WithNode(n report.Node) RenderableNode
WithNode creates a new RenderableNode based on rn, with n
func (RenderableNode) WithParents ¶ added in v0.12.0
func (rn RenderableNode) WithParents(p report.Sets) RenderableNode
WithParents creates a new RenderableNode based on rn, where n has the given parents set
type RenderableNodes ¶
type RenderableNodes map[string]RenderableNode
RenderableNodes is a set of RenderableNodes
func MakeRenderableNodes ¶ added in v0.7.0
func MakeRenderableNodes(t report.Topology) RenderableNodes
MakeRenderableNodes converts a topology to a set of RenderableNodes
func MapAddressIdentity ¶
func MapAddressIdentity(m RenderableNode, local report.Networks) RenderableNodes
MapAddressIdentity maps an address topology node to an address renderable node. As it is only ever run on address topology nodes, we expect that certain keys are present.
func MapContainer2ContainerImage ¶
func MapContainer2ContainerImage(n RenderableNode, _ report.Networks) RenderableNodes
MapContainer2ContainerImage maps container RenderableNodes to container image RenderableNodes.
If this function is given a node without a docker_image_id (including other pseudo nodes), it will produce an "Uncontained" pseudo node.
Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.
func MapContainer2Hostname ¶ added in v0.9.0
func MapContainer2Hostname(n RenderableNode, _ report.Networks) RenderableNodes
MapContainer2Hostname maps container RenderableNodes to 'hostname' renderabled nodes..
func MapContainer2IP ¶ added in v0.7.0
func MapContainer2IP(m RenderableNode, _ report.Networks) RenderableNodes
MapContainer2IP maps container nodes to their IP addresses (outputs multiple nodes). This allows container to be joined directly with the endpoint topology.
func MapContainer2Pod ¶ added in v0.9.0
func MapContainer2Pod(n RenderableNode, _ report.Networks) RenderableNodes
MapContainer2Pod maps container RenderableNodes to pod RenderableNodes.
If this function is given a node without a kubernetes_pod_id (including other pseudo nodes), it will produce an "Unmanaged" pseudo node.
Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.
func MapContainerIdentity ¶
func MapContainerIdentity(m RenderableNode, _ report.Networks) RenderableNodes
MapContainerIdentity maps a container topology node to a container renderable node. As it is only ever run on container topology nodes, we expect that certain keys are present.
func MapContainerImage2Name ¶ added in v0.5.0
func MapContainerImage2Name(n RenderableNode, _ report.Networks) RenderableNodes
MapContainerImage2Name maps container images RenderableNodes to RenderableNodes for each container image name.
This mapper is unlike the other foo2bar mappers as the intention is not to join the information with another topology. Therefore it outputs a properly-formed node with labels etc.
func MapContainerImageIdentity ¶
func MapContainerImageIdentity(m RenderableNode, _ report.Networks) RenderableNodes
MapContainerImageIdentity maps a container image topology node to container image renderable node. As it is only ever run on container image topology nodes, we expect that certain keys are present.
func MapCountContainers ¶ added in v0.7.0
func MapCountContainers(n RenderableNode, _ report.Networks) RenderableNodes
MapCountContainers maps 1:1 container image nodes, counting the number of containers grouped together and putting that info in the minor label.
func MapCountPods ¶ added in v0.9.0
func MapCountPods(n RenderableNode, _ report.Networks) RenderableNodes
MapCountPods maps 1:1 service nodes, counting the number of pods grouped together and putting that info in the minor label.
func MapCountProcessName ¶ added in v0.7.0
func MapCountProcessName(n RenderableNode, _ report.Networks) RenderableNodes
MapCountProcessName maps 1:1 process name nodes, counting the number of processes grouped together and putting that info in the minor label.
func MapEndpoint2IP ¶ added in v0.7.0
func MapEndpoint2IP(m RenderableNode, local report.Networks) RenderableNodes
MapEndpoint2IP maps endpoint nodes to their IP address, for joining with container nodes. We drop endpoint nodes with pids, as they will be joined to containers through the process topology, and we don't want to double count edges.
func MapEndpoint2Process ¶
func MapEndpoint2Process(n RenderableNode, _ report.Networks) RenderableNodes
MapEndpoint2Process maps endpoint RenderableNodes to process RenderableNodes.
If this function is given a pseudo node, then it will just return it; Pseudo nodes will never have pids in them, and therefore will never be able to be turned into a Process node.
Otherwise, this function will produce a node with the correct ID format for a process, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a process graph to get that info.
func MapEndpointIdentity ¶
func MapEndpointIdentity(m RenderableNode, local report.Networks) RenderableNodes
MapEndpointIdentity maps an endpoint topology node to a single endpoint renderable node. As it is only ever run on endpoint topology nodes, we expect that certain keys are present.
func MapHostIdentity ¶
func MapHostIdentity(m RenderableNode, _ report.Networks) RenderableNodes
MapHostIdentity maps a host topology node to a host renderable node. As it is only ever run on host topology nodes, we expect that certain keys are present.
func MapIP2Container ¶ added in v0.7.0
func MapIP2Container(n RenderableNode, _ report.Networks) RenderableNodes
MapIP2Container maps IP nodes produced from MapContainer2IP back to container nodes. If there is more than one container with a given IP, it is dropped.
func MapPod2Service ¶ added in v0.9.0
func MapPod2Service(n RenderableNode, _ report.Networks) RenderableNodes
MapPod2Service maps pod RenderableNodes to service RenderableNodes.
If this function is given a node without a kubernetes_pod_id (including other pseudo nodes), it will produce an "Uncontained" pseudo node.
Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a pod graph to get that info.
func MapPodIdentity ¶ added in v0.9.0
func MapPodIdentity(m RenderableNode, _ report.Networks) RenderableNodes
MapPodIdentity maps a pod topology node to pod renderable node. As it is only ever run on pod topology nodes, we expect that certain keys are present.
func MapProcess2Container ¶
func MapProcess2Container(n RenderableNode, _ report.Networks) RenderableNodes
MapProcess2Container maps process RenderableNodes to container RenderableNodes.
If this function is given a node without a docker_container_id (including other pseudo nodes), it will produce an "Uncontained" pseudo node.
Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.
func MapProcess2Name ¶
func MapProcess2Name(n RenderableNode, _ report.Networks) RenderableNodes
MapProcess2Name maps process RenderableNodes to RenderableNodes for each process name.
This mapper is unlike the other foo2bar mappers as the intention is not to join the information with another topology. Therefore it outputs a properly-formed node with labels etc.
func MapProcessIdentity ¶
func MapProcessIdentity(m RenderableNode, _ report.Networks) RenderableNodes
MapProcessIdentity maps a process topology node to a process renderable node. As it is only ever run on process topology nodes, we expect that certain keys are present.
func MapServiceIdentity ¶ added in v0.9.0
func MapServiceIdentity(m RenderableNode, _ report.Networks) RenderableNodes
MapServiceIdentity maps a service topology node to service renderable node. As it is only ever run on service topology nodes, we expect that certain keys are present.
func MapX2Host ¶ added in v0.12.0
func MapX2Host(n RenderableNode, _ report.Networks) RenderableNodes
MapX2Host maps any RenderableNodes to host RenderableNodes.
If this function is given a node without a hostname (including other pseudo nodes), it will drop the node.
Otherwise, this function will produce a node with the correct ID format for a container, but without any Major or Minor labels. It does not have enough info to do that, and the resulting graph must be merged with a container graph to get that info.
func (RenderableNodes) Copy ¶ added in v0.7.0
func (rns RenderableNodes) Copy() RenderableNodes
Copy produces a deep copy of the RenderableNodes
func (RenderableNodes) Merge ¶
func (rns RenderableNodes) Merge(other RenderableNodes) RenderableNodes
Merge merges two sets of RenderableNodes, returning a new set.
func (RenderableNodes) Prune ¶ added in v0.7.0
func (rns RenderableNodes) Prune() RenderableNodes
Prune returns a copy of the RenderableNodes with all information not strictly necessary for rendering nodes and edges in the UI cut away.
type Renderer ¶
Renderer is something that can render a report to a set of RenderableNodes.
func ColorConnected ¶ added in v0.7.0
ColorConnected colors nodes with the IsConnected key if they have edges to or from them. Edges to/from yourself are not counted here (see #656).
func FilterPseudo ¶ added in v0.12.0
FilterPseudo produces a renderer that removes pseudo nodes from the given renderer
func FilterStopped ¶ added in v0.10.0
FilterStopped filters out stopped containers.
func FilterSystem ¶ added in v0.7.0
FilterSystem is a Renderer which filters out system nodes.
func FilterUnconnected ¶
FilterUnconnected produces a renderer that filters unconnected nodes from the given renderer
func MakeFilter ¶ added in v0.12.0
func MakeFilter(f func(RenderableNode) bool, r Renderer) Renderer
MakeFilter makes a new Filter.
func MakeReduce ¶
MakeReduce is the only sane way to produce a Reduce Renderer.
type Stats ¶ added in v0.8.0
type Stats struct {
FilteredNodes int
}
Stats is the type returned by Renderer.Stats
type TopologySelector ¶ added in v0.7.0
type TopologySelector func(r report.Report) RenderableNodes
TopologySelector selects a single topology from a report. NB it is also a Renderer!
func (TopologySelector) Render ¶ added in v0.7.0
func (t TopologySelector) Render(r report.Report) RenderableNodes
Render implements Renderer