Documentation ¶
Index ¶
- Constants
- Variables
- func LocalNetworks(r report.Report) report.Networks
- func MakeAddressID(hostID, addr string) string
- func MakeEndpointID(hostID, addr, port string) string
- func MakeHostID(hostID string) string
- func MakeProcessID(hostID, pid string) string
- func MakePseudoNodeID(parts ...string) string
- type AggregateMetadata
- type DetailedNode
- type Diff
- type FilterUnconnected
- type LeafMap
- type LeafMapFunc
- type Map
- type MapFunc
- type PseudoFunc
- type Reduce
- type RenderableNode
- func MapAddress2Host(n RenderableNode) (RenderableNode, bool)
- func MapAddressIdentity(m report.NodeMetadata) (RenderableNode, bool)
- func MapContainer2ContainerImage(n RenderableNode) (RenderableNode, bool)
- func MapContainerIdentity(m report.NodeMetadata) (RenderableNode, bool)
- func MapContainerImageIdentity(m report.NodeMetadata) (RenderableNode, bool)
- func MapEndpoint2Process(n RenderableNode) (RenderableNode, bool)
- func MapEndpointIdentity(m report.NodeMetadata) (RenderableNode, bool)
- func MapHostIdentity(m report.NodeMetadata) (RenderableNode, bool)
- func MapProcess2Container(n RenderableNode) (RenderableNode, bool)
- func MapProcess2Name(n RenderableNode) (RenderableNode, bool)
- func MapProcessIdentity(m report.NodeMetadata) (RenderableNode, bool)
- func NewRenderableNode(id, major, minor, rank string, nmd report.NodeMetadata) RenderableNode
- func PanicPseudoNode(src string, srcMapped RenderableNode, dst string, local report.Networks) (RenderableNode, bool)
- type RenderableNodes
- type Renderer
- type Row
- type Table
Constants ¶
const ( UncontainedID = "uncontained" UncontainedMajor = "Uncontained" TheInternetID = "theinternet" TheInternetMajor = "The Internet" )
Constants are used in the tests.
const ( // KeyBytesIngress is the aggregate metadata key for the total count of // ingress bytes. KeyBytesIngress = "ingress_bytes" // KeyBytesEgress is the aggregate metadata key for the total count of // egress bytes. KeyBytesEgress = "egress_bytes" // KeyMaxConnCountTCP is the aggregate metadata key for the maximum number // of simultaneous observed TCP connections in the window. KeyMaxConnCountTCP = "max_conn_count_tcp" )
Variables ¶
var AddressRenderer = LeafMap{ Selector: report.SelectAddress, Mapper: MapAddressIdentity, Pseudo: GenericPseudoNode(report.AddressIDAddresser), }
AddressRenderer is a Renderer which produces a renderable address graph from the address topology.
var ContainerImageRenderer = MakeReduce( Map{ MapFunc: MapContainer2ContainerImage, Renderer: ContainerRenderer, }, LeafMap{ Selector: report.SelectContainerImage, Mapper: MapContainerImageIdentity, Pseudo: PanicPseudoNode, }, )
ContainerImageRenderer is a Renderer which produces a renderable container image graph by merging the container graph and the container image topology.
var ContainerRenderer = MakeReduce( Map{ MapFunc: MapProcess2Container, Renderer: ProcessRenderer, }, LeafMap{ Selector: report.SelectContainer, Mapper: MapContainerIdentity, Pseudo: PanicPseudoNode, }, )
ContainerRenderer is a Renderer which produces a renderable container graph by merging the process graph and the container topology.
var EndpointRenderer = LeafMap{ Selector: report.SelectEndpoint, Mapper: MapEndpointIdentity, Pseudo: GenericPseudoNode(report.EndpointIDAddresser), }
EndpointRenderer is a Renderer which produces a renderable endpoint graph.
var HostRenderer = MakeReduce( Map{ MapFunc: MapAddress2Host, Renderer: AddressRenderer, }, LeafMap{ Selector: report.SelectHost, Mapper: MapHostIdentity, Pseudo: PanicPseudoNode, }, )
HostRenderer is a Renderer which produces a renderable host graph from the host topology and address graph.
var ProcessNameRenderer = Map{ MapFunc: MapProcess2Name, Renderer: ProcessRenderer, }
ProcessRenderer is a Renderer which produces a renderable process name graph by munging the progess graph.
var ProcessRenderer = MakeReduce( Map{ MapFunc: MapEndpoint2Process, Renderer: EndpointRenderer, }, LeafMap{ Selector: report.SelectProcess, Mapper: MapProcessIdentity, Pseudo: PanicPseudoNode, }, )
ProcessRenderer is a Renderer which produces a renderable process graph by merging the endpoint graph and the process topology.
Functions ¶
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 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.
Types ¶
type AggregateMetadata ¶
AggregateMetadata is a composable version of an EdgeMetadata. It's used when we want to merge nodes/edges for any reason.
Even though we base it on EdgeMetadata, we can apply it to nodes, by summing up (merging) all of the {ingress, egress} metadatas of the {incoming, outgoing} edges to the node.
func AggregateMetadataOf ¶
func AggregateMetadataOf(md report.EdgeMetadata) AggregateMetadata
AggregateMetadataOf calculates a AggregateMetadata from an EdgeMetadata.
func (*AggregateMetadata) Merge ¶
func (r *AggregateMetadata) Merge(other AggregateMetadata)
Merge adds the fields from AggregateMetadata to r. r must be initialized.
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"` }
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 FilterUnconnected ¶
type FilterUnconnected struct {
Renderer
}
FilterUnconnected is a Renderer which filters out unconnected nodes.
func (FilterUnconnected) Render ¶
func (f FilterUnconnected) Render(rpt report.Report) RenderableNodes
Render produces a set of RenderableNodes given a Report
type LeafMap ¶
type LeafMap struct { Selector report.TopologySelector Mapper LeafMapFunc Pseudo PseudoFunc }
LeafMap is a Renderer which produces a set of RenderableNodes from a report.Topology by using a map function and topology selector.
func (LeafMap) AggregateMetadata ¶
func (m LeafMap) AggregateMetadata(rpt report.Report, srcRenderableID, dstRenderableID string) AggregateMetadata
AggregateMetadata 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 (LeafMap) Render ¶
func (m LeafMap) Render(rpt report.Report) RenderableNodes
Render transforms a given Report into a set of RenderableNodes, which the UI will render collectively as a graph. Note that a RenderableNode will always be rendered with other nodes, and therefore contains limited detail.
Nodes with the same mapped IDs will be merged.
type LeafMapFunc ¶
type LeafMapFunc func(report.NodeMetadata) (RenderableNode, bool)
LeafMapFunc is anything which can take an arbitrary NodeMetadata, which is always one-to-one with nodes in a topology, and return a specific representation of the referenced node, in the form of a node ID and a human-readable major and minor labels.
A single NodeMetadata can yield arbitrary many representations, including representations that reduce the cardinality of the set of nodes.
If the final output parameter is false, the node shall be omitted from the rendered topology.
type Map ¶
Map is a Renderer which produces a set of RenderableNodes from the set of RenderableNodes produced by another Renderer.
func (Map) AggregateMetadata ¶
func (m Map) AggregateMetadata(rpt report.Report, srcRenderableID, dstRenderableID string) AggregateMetadata
AggregateMetadata 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.
type MapFunc ¶
type MapFunc func(RenderableNode) (RenderableNode, bool)
MapFunc is anything which can take an arbitrary RenderableNode and return another RenderableNode.
As with LeafMapFunc, if the final output parameter is false, the node shall be omitted from the rendered topology.
type PseudoFunc ¶
type PseudoFunc func(srcNodeID string, srcNode RenderableNode, dstNodeID string, local report.Networks) (RenderableNode, bool)
PseudoFunc creates RenderableNode representing pseudo nodes given the dstNodeID. The srcNode renderable node is essentially from MapFunc, representing one of the rendered nodes this pseudo node refers to. srcNodeID and dstNodeID are node IDs prior to mapping.
func GenericPseudoNode ¶
func GenericPseudoNode(addresser func(id string) net.IP) PseudoFunc
GenericPseudoNode makes a PseudoFunc given an addresser. The returned PseudoFunc will produce Internet pseudo nodes for addresses not in the report's local networks. Otherwise, the returned function will produce a single pseudo node per (dst address, src address, src port).
type Reduce ¶
type Reduce []Renderer
Reduce renderer is a Renderer which merges together the output of several other renderers.
func (Reduce) AggregateMetadata ¶
func (r Reduce) AggregateMetadata(rpt report.Report, localID, remoteID string) AggregateMetadata
AggregateMetadata produces an AggregateMetadata for a given edge.
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 Adjacency report.IDList `json:"adjacency,omitempty"` // Node IDs (in the same topology domain) Origins report.IDList `json:"origins,omitempty"` // Core node IDs that contributed information AggregateMetadata `json:"metadata"` // Numeric sums report.NodeMetadata `json:"-"` // merged NodeMetadata of the nodes used to build this }
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 MapAddress2Host ¶
func MapAddress2Host(n RenderableNode) (RenderableNode, bool)
MapAddress2Host maps address RenderableNodes to host RenderableNodes.
Otherthan pseudo nodes, we can assume all nodes have a HostID
func MapAddressIdentity ¶
func MapAddressIdentity(m report.NodeMetadata) (RenderableNode, bool)
MapAddressIdentity maps a address topology node to address RenderableNode node. As it is only ever run on address topology nodes, we can safely assume the presence of certain keys.
func MapContainer2ContainerImage ¶
func MapContainer2ContainerImage(n RenderableNode) (RenderableNode, bool)
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 MapContainerIdentity ¶
func MapContainerIdentity(m report.NodeMetadata) (RenderableNode, bool)
MapContainerIdentity maps a container topology node to a container RenderableNode node. As it is only ever run on container topology nodes, we can safely assume the presences of certain keys.
func MapContainerImageIdentity ¶
func MapContainerImageIdentity(m report.NodeMetadata) (RenderableNode, bool)
MapContainerImageIdentity maps a container image topology node to container image RenderableNode node. As it is only ever run on container image topology nodes, we can safely assume the presences of certain keys.
func MapEndpoint2Process ¶
func MapEndpoint2Process(n RenderableNode) (RenderableNode, bool)
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 report.NodeMetadata) (RenderableNode, bool)
MapEndpointIdentity maps a endpoint topology node to endpoint RenderableNode node. As it is only ever run on endpoint topology nodes, we can safely assume the presence of certain keys.
func MapHostIdentity ¶
func MapHostIdentity(m report.NodeMetadata) (RenderableNode, bool)
MapHostIdentity maps a host topology node to host RenderableNode node. As it is only ever run on host topology nodes, we can safely assume the presence of certain keys.
func MapProcess2Container ¶
func MapProcess2Container(n RenderableNode) (RenderableNode, bool)
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) (RenderableNode, bool)
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 report.NodeMetadata) (RenderableNode, bool)
MapProcessIdentity maps a process topology node to process RenderableNode node. As it is only ever run on process topology nodes, we can safely assume the presence of certain keys.
func NewRenderableNode ¶
func NewRenderableNode(id, major, minor, rank string, nmd report.NodeMetadata) RenderableNode
NewRenderableNode makes a new RenderableNode
func PanicPseudoNode ¶
func PanicPseudoNode(src string, srcMapped RenderableNode, dst string, local report.Networks) (RenderableNode, bool)
PanicPseudoNode just panics; it is for Topologies without edges
func (*RenderableNode) Merge ¶
func (rn *RenderableNode) Merge(other RenderableNode)
Merge merges in another RenderableNode
type RenderableNodes ¶
type RenderableNodes map[string]RenderableNode
RenderableNodes is a set of RenderableNodes
func OnlyConnected ¶
func OnlyConnected(input RenderableNodes) RenderableNodes
OnlyConnected filters out unconnected RenderedNodes
func (RenderableNodes) Merge ¶
func (rns RenderableNodes) Merge(other RenderableNodes)
Merge merges two sets of RenderableNodes
type Renderer ¶
type Renderer interface { Render(report.Report) RenderableNodes AggregateMetadata(rpt report.Report, localID, remoteID string) AggregateMetadata }
Renderer is something that can render a report to a set of RenderableNodes.
func MakeReduce ¶
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 }
Row is a single entry in a Table dataset.
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.