render

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2015 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UncontainedID    = "uncontained"
	UncontainedMajor = "Uncontained"

	TheInternetID    = "theinternet"
	TheInternetMajor = "The Internet"

	AmazonECSContainerNameLabel = "com.amazonaws.ecs.container-name"
)

Constants are used in the tests.

View Source
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

View Source
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)
	})
)
View Source
var AddressRenderer = Map{
	MapFunc:  MapAddressIdentity,
	Renderer: SelectAddress,
}

AddressRenderer is a Renderer which produces a renderable address graph from the address topology.

View Source
var ContainerHostnameRenderer = Map{
	MapFunc: MapCountContainers,
	Renderer: Map{
		MapFunc:  MapContainer2Hostname,
		Renderer: ContainerRenderer,
	},
}

ContainerHostnameRenderer is a Renderer which produces a renderable container by hostname graph..

View Source
var ContainerImageRenderer = Map{
	MapFunc: MapCountContainers,
	Renderer: Map{
		MapFunc: MapContainerImage2Name,
		Renderer: MakeReduce(
			Map{
				MapFunc:  MapContainer2ContainerImage,
				Renderer: ContainerRenderer,
			},
			Map{
				MapFunc:  MapContainerImageIdentity,
				Renderer: SelectContainerImage,
			},
		),
	},
}

ContainerImageRenderer is a Renderer which produces a renderable container image graph by merging the container graph and the container image topology.

View Source
var ContainerRenderer = MakeReduce(
	Filter{
		FilterFunc: func(n RenderableNode) bool {
			_, inContainer := n.Node.Metadata[docker.ContainerID]
			_, isConnected := n.Node.Metadata[IsConnected]
			return inContainer || isConnected
		},
		Renderer: ColorConnected(Map{
			MapFunc:  MapProcess2Container,
			Renderer: ProcessRenderer,
		}),
	},

	Map{
		MapFunc:  MapContainerIdentity,
		Renderer: SelectContainer,
	},

	FilterUnconnected(Map{
		MapFunc: MapIP2Container,
		Renderer: MakeReduce(
			Map{
				MapFunc:  MapContainer2IP,
				Renderer: SelectContainer,
			},
			Map{
				MapFunc:  MapEndpoint2IP,
				Renderer: SelectEndpoint,
			},
		),
	}),
)

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.

View Source
var ContainerWithImageNameRenderer = containerWithImageNameRenderer{ContainerRenderer}

ContainerWithImageNameRenderer is a Renderer which produces a container graph where the ranks are the image names, not their IDs

View Source
var EndpointRenderer = Map{
	MapFunc:  MapEndpointIdentity,
	Renderer: SelectEndpoint,
}

EndpointRenderer is a Renderer which produces a renderable endpoint graph.

View Source
var HostRenderer = MakeReduce(
	Map{
		MapFunc:  MapAddress2Host,
		Renderer: AddressRenderer,
	},
	Map{
		MapFunc:  MapHostIdentity,
		Renderer: SelectHost,
	},
)

HostRenderer is a Renderer which produces a renderable host graph from the host topology and address graph.

View Source
var PodRenderer = Map{
	MapFunc: MapCountContainers,
	Renderer: MakeReduce(
		Map{
			MapFunc:  MapPodIdentity,
			Renderer: SelectPod,
		},
		Map{
			MapFunc:  MapContainer2Pod,
			Renderer: ContainerRenderer,
		},
	),
}

PodRenderer is a Renderer which produces a renderable kubernetes graph by merging the container graph and the pods topology.

View Source
var PodServiceRenderer = Map{
	MapFunc: MapCountPods,
	Renderer: MakeReduce(
		Map{
			MapFunc:  MapPod2Service,
			Renderer: PodRenderer,
		},
		Map{
			MapFunc:  MapServiceIdentity,
			Renderer: SelectService,
		},
	),
}

PodServiceRenderer is a Renderer which produces a renderable kubernetes services graph by merging the pods graph and the services topology.

View Source
var ProcessNameRenderer = Map{
	MapFunc: MapCountProcessName,
	Renderer: Map{
		MapFunc:  MapProcess2Name,
		Renderer: ProcessRenderer,
	},
}

ProcessNameRenderer is a Renderer which produces a renderable process name graph by munging the progess graph.

View Source
var ProcessRenderer = MakeReduce(
	Map{
		MapFunc:  MapEndpoint2Process,
		Renderer: EndpointRenderer,
	},
	Map{
		MapFunc:  MapProcessIdentity,
		Renderer: SelectProcess,
	},
)

ProcessRenderer is a Renderer which produces a renderable process graph by merging the endpoint graph and the process topology.

View Source
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

func GetRenderableContainerName(nmd report.Node) (string, bool)

GetRenderableContainerName obtains a user-friendly container name, to render in the UI

func LocalNetworks

func LocalNetworks(r report.Report) report.Networks

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

func MakeAddressID(hostID, addr string) string

MakeAddressID makes an address node ID for rendered nodes.

func MakeEndpointID

func MakeEndpointID(hostID, addr, port string) string

MakeEndpointID makes an endpoint node ID for rendered nodes.

func MakeHostID

func MakeHostID(hostID string) string

MakeHostID makes a host node ID for rendered nodes.

func MakeProcessID

func MakeProcessID(hostID, pid string) string

MakeProcessID makes a process node ID for rendered nodes.

func MakePseudoNodeID

func MakePseudoNodeID(parts ...string) string

MakePseudoNodeID produces a pseudo node ID from its composite parts, for use in rendered nodes.

Types

type ControlInstance added in v0.10.0

type ControlInstance struct {
	ProbeID string `json:"probeId"`
	NodeID  string `json:"nodeId"`
	report.Control
}

ControlInstance contains a control description, and all the info needed to execute it.

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

Render implements Renderer

type DetailedNode

type DetailedNode struct {
	ID         string            `json:"id"`
	LabelMajor string            `json:"label_major"`
	LabelMinor string            `json:"label_minor,omitempty"`
	Pseudo     bool              `json:"pseudo,omitempty"`
	Tables     []Table           `json:"tables"`
	Controls   []ControlInstance `json:"controls"`
}

DetailedNode is the data type that's yielded to the JavaScript layer when we want deep information about an individual node.

func MakeDetailedNode

func MakeDetailedNode(r report.Report, n RenderableNode) DetailedNode

MakeDetailedNode transforms a renderable node to a detailed node. It uses aggregate metadata, plus the set of origin node IDs, to produce tables.

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.

func (Filter) Render added in v0.7.0

func (f Filter) Render(rpt report.Report) RenderableNodes

Render implements Renderer

func (Filter) Stats added in v0.8.0

func (f Filter) Stats(rpt report.Report) Stats

Stats implements Renderer

type Map

type Map struct {
	MapFunc
	Renderer
}

Map is a Renderer which produces a set of RenderableNodes from the set of RenderableNodes produced by another Renderer.

func (Map) EdgeMetadata added in v0.6.0

func (m Map) EdgeMetadata(rpt report.Report, srcRenderableID, dstRenderableID string) report.EdgeMetadata

EdgeMetadata gives the metadata of an edge from the perspective of the srcRenderableID. Since an edgeID can have multiple edges on the address level, it uses the supplied mapping function to translate address IDs to renderable node (mapped) IDs.

func (Map) Render

func (m Map) Render(rpt report.Report) RenderableNodes

Render transforms a set of RenderableNodes produces by another Renderer. using a map function

func (Map) Stats added in v0.8.0

func (m Map) Stats(rpt report.Report) Stats

Stats implements Renderer

type MapFunc

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.

func (Reduce) EdgeMetadata added in v0.6.0

func (r Reduce) EdgeMetadata(rpt report.Report, localID, remoteID string) report.EdgeMetadata

EdgeMetadata produces an EdgeMetadata for a given edge.

func (Reduce) Render

func (r Reduce) Render(rpt report.Report) RenderableNodes

Render produces a set of RenderableNodes given a Report.

func (Reduce) Stats added in v0.8.0

func (r Reduce) Stats(rpt report.Report) Stats

Stats implements Renderer

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
	Origins     report.IDList `json:"origins,omitempty"`     // Core node IDs that contributed information
	ControlNode string        `json:"-"`                     // ID of node from which to show the controls in the UI

	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, rn 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

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

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 MapAddress2Host

func MapAddress2Host(n RenderableNode, _ report.Networks) RenderableNodes

MapAddress2Host maps address RenderableNodes to host RenderableNodes.

Otherthan pseudo nodes, we can assume all nodes have a HostID

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 (RenderableNodes) Copy added in v0.7.0

func (rns RenderableNodes) Copy() RenderableNodes

Copy produces a deep copy of the RenderableNodes

func (RenderableNodes) Merge

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

type Renderer interface {
	Render(report.Report) RenderableNodes
	EdgeMetadata(rpt report.Report, localID, remoteID string) report.EdgeMetadata
	Stats(report.Report) Stats
}

Renderer is something that can render a report to a set of RenderableNodes.

func ColorConnected added in v0.7.0

func ColorConnected(r Renderer) Renderer

ColorConnected colors nodes with the IsConnected key if they have edges to or from them.

func FilterNoop added in v0.10.0

func FilterNoop(in Renderer) Renderer

FilterNoop does nothing.

func FilterStopped added in v0.10.0

func FilterStopped(r Renderer) Renderer

FilterStopped filters out stopped containers.

func FilterSystem added in v0.7.0

func FilterSystem(r Renderer) Renderer

FilterSystem is a Renderer which filters out system nodes.

func FilterUnconnected

func FilterUnconnected(r Renderer) Renderer

FilterUnconnected produces a renderer that filters unconnected nodes from the given renderer

func MakeReduce

func MakeReduce(renderers ...Renderer) Renderer

MakeReduce is the only sane way to produce a Reduce Renderer.

type Row

type Row struct {
	Key        string         `json:"key"`                   // e.g. Ingress
	ValueMajor string         `json:"value_major"`           // e.g. 25
	ValueMinor string         `json:"value_minor,omitempty"` // e.g. KB/s
	Expandable bool           `json:"expandable,omitempty"`  // Whether it can be expanded (hidden by default)
	ValueType  string         `json:"value_type,omitempty"`  // e.g. sparkline
	Metric     *report.Metric `json:"metric,omitempty"`      // e.g. sparkline data samples
}

Row is a single entry in a Table dataset.

type Stats added in v0.8.0

type Stats struct {
	FilteredNodes int
}

Stats is the type returned by Renderer.Stats

type Table

type Table struct {
	Title   string `json:"title"`   // e.g. Bandwidth
	Numeric bool   `json:"numeric"` // should the major column be right-aligned?
	Rank    int    `json:"-"`       // used to sort tables; not emitted.
	Rows    []Row  `json:"rows"`
}

Table is a dataset associated with a node. It will be displayed in the detail panel when a user clicks on a node.

func OriginTable

func OriginTable(r report.Report, originID string, addHostTags bool, addContainerTags bool) (Table, bool)

OriginTable produces a table (to be consumed directly by the UI) based on an origin ID, which is (optimistically) a node ID in one of our topologies.

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) EdgeMetadata added in v0.7.0

func (t TopologySelector) EdgeMetadata(rpt report.Report, srcID, dstID string) report.EdgeMetadata

EdgeMetadata implements Renderer

func (TopologySelector) Render added in v0.7.0

Render implements Renderer

func (TopologySelector) Stats added in v0.8.0

func (t TopologySelector) Stats(r report.Report) Stats

Stats implements Renderer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL