report

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ScopeDelim is a general-purpose delimiter used within node IDs to
	// separate different contextual scopes. Different topologies have
	// different key structures.
	ScopeDelim = ";"

	// EdgeDelim separates two node IDs when they need to exist in the same key.
	// Concretely, it separates node IDs in keys that represent edges.
	EdgeDelim = "|"
)

Delimiters are used to separate parts of node IDs, to guarantee uniqueness in particular contexts.

View Source
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"
)
View Source
const (
	// HostNodeID is a metadata foreign key, linking a node in any topology to
	// a node in the host topology. That host node is the origin host, where
	// the node was originally detected.
	HostNodeID = "host_node_id"
)
View Source
const TheInternet = "theinternet"

TheInternet is used as a node ID to indicate a remote IP.

Variables

This section is empty.

Functions

func AddressIDAddresser added in v0.3.0

func AddressIDAddresser(id string) net.IP

AddressIDAddresser converts an address node ID to an IP.

func EndpointIDAddresser added in v0.3.0

func EndpointIDAddresser(id string) net.IP

EndpointIDAddresser converts an endpoint node ID to an IP.

func MakeAddressNodeID added in v0.3.0

func MakeAddressNodeID(hostID, address string) string

MakeAddressNodeID produces an address node ID from its composite parts.

func MakeAdjacencyID added in v0.3.0

func MakeAdjacencyID(srcNodeID string) string

MakeAdjacencyID produces an adjacency ID from a node id.

func MakeContainerNodeID added in v0.3.0

func MakeContainerNodeID(hostID, containerID string) string

MakeContainerNodeID produces a container node ID from its composite parts.

func MakeEdgeID added in v0.3.0

func MakeEdgeID(srcNodeID, dstNodeID string) string

MakeEdgeID produces an edge ID from composite parts.

func MakeEndpointNodeID added in v0.3.0

func MakeEndpointNodeID(hostID, address, port string) string

MakeEndpointNodeID produces an endpoint node ID from its composite parts.

func MakeHostNodeID added in v0.3.0

func MakeHostNodeID(hostID string) string

MakeHostNodeID produces a host node ID from its composite parts.

func MakeProcessNodeID added in v0.3.0

func MakeProcessNodeID(hostID, pid string) string

MakeProcessNodeID produces a process node ID from its composite parts.

func MakePseudoNodeID added in v0.3.0

func MakePseudoNodeID(parts ...string) string

MakePseudoNodeID produces a pseudo node ID from its composite parts.

func PanicIDAddresser added in v0.3.0

func PanicIDAddresser(id string) net.IP

PanicIDAddresser will panic if it's ever called. It's used in topologies where there are never any edges, and so it's nonsensical to try and extract IPs from the node IDs.

func ParseAdjacencyID added in v0.3.0

func ParseAdjacencyID(adjacencyID string) (string, bool)

ParseAdjacencyID produces a node ID from an adjancency ID.

func ParseEdgeID added in v0.3.0

func ParseEdgeID(edgeID string) (srcNodeID, dstNodeID string, ok bool)

ParseEdgeID splits an edge ID to its composite parts.

func ParseNodeID added in v0.3.0

func ParseNodeID(nodeID string) (hostID string, remainder string, ok bool)

ParseNodeID produces the host ID and remainder (typically an address) from a node ID. Note that hostID may be blank.

Types

type Adjacency

type Adjacency map[string]IDList

Adjacency is an adjacency-list encoding of the topology. Keys are node IDs, as produced by the relevant MappingFunc for the topology.

func (*Adjacency) Merge

func (a *Adjacency) Merge(other Adjacency)

Merge merges another Adjacency list into the receiver.

type AggregateMetadata

type AggregateMetadata map[string]int

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 (*AggregateMetadata) Merge

func (r *AggregateMetadata) Merge(other AggregateMetadata)

Merge adds the fields from AggregateMetadata to r. r must be initialized.

type ByID

type ByID []RenderableNode

ByID is a sort interface for a RenderableNode slice.

func (ByID) Len

func (r ByID) Len() int

func (ByID) Less

func (r ByID) Less(i, j int) bool

func (ByID) Swap

func (r ByID) Swap(i, j int)

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 added in v0.3.0

func MakeDetailedNode(r 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 EdgeMetadata

type EdgeMetadata struct {
	WithBytes    bool `json:"with_bytes,omitempty"`
	BytesIngress uint `json:"bytes_ingress,omitempty"` // dst -> src
	BytesEgress  uint `json:"bytes_egress,omitempty"`  // src -> dst

	WithConnCountTCP bool `json:"with_conn_count_tcp,omitempty"`
	MaxConnCountTCP  uint `json:"max_conn_count_tcp,omitempty"`
}

EdgeMetadata describes a superset of the metadata that probes can conceivably (and usefully) collect about an edge between two nodes in any topology.

func (*EdgeMetadata) Flatten

func (m *EdgeMetadata) Flatten(other EdgeMetadata)

Flatten sums two EdgeMetadatas, their 'Window's should be the same size. The two EdgeMetadatas should represent different edges at the same time.

func (*EdgeMetadata) Merge

func (m *EdgeMetadata) Merge(other EdgeMetadata)

Merge merges another EdgeMetadata into the receiver. The two edge metadatas should represent the same edge on different times.

func (EdgeMetadata) Transform

func (md EdgeMetadata) Transform() AggregateMetadata

Transform calculates a AggregateMetadata from an EdgeMetadata.

type EdgeMetadatas

type EdgeMetadatas map[string]EdgeMetadata

EdgeMetadatas collect metadata about each edge in a topology. Keys are a concatenation of node IDs.

func (*EdgeMetadatas) Merge

func (e *EdgeMetadatas) Merge(other EdgeMetadatas)

Merge merges another EdgeMetadatas into the receiver. If other is from another probe this is the union of both metadatas. Keys present in both are summed.

type IDAddresser

type IDAddresser func(string) net.IP

IDAddresser tries to convert a node ID to a net.IP, if possible.

type IDList

type IDList []string

IDList is a list of string IDs, which are always sorted and unique.

func MakeIDList added in v0.3.0

func MakeIDList(ids ...string) IDList

MakeIDList makes a new IDList.

func (IDList) Add

func (a IDList) Add(ids ...string) IDList

Add is the only correct way to add ids to an IDList.

func (IDList) Contains added in v0.3.0

func (a IDList) Contains(id string) bool

Contains returns true if id is in the list.

type MapFunc

type MapFunc func(string, NodeMetadata) (MappedNode, bool)

MapFunc 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 MappedNode

type MappedNode struct {
	ID    string
	Major string
	Minor string
	Rank  string
}

MappedNode is returned by the MapFuncs.

func GenericGroupedPseudoNode added in v0.1.0

func GenericGroupedPseudoNode(src string, srcMapped RenderableNode, dst string) (MappedNode, bool)

GenericGroupedPseudoNode contains heuristics for building sensible pseudo nodes. It should go away.

func GenericPseudoNode added in v0.1.0

func GenericPseudoNode(src string, srcMapped RenderableNode, dst string) (MappedNode, bool)

GenericPseudoNode contains heuristics for building sensible pseudo nodes. It should go away.

func InternetOnlyPseudoNode added in v0.1.0

func InternetOnlyPseudoNode(_ string, _ RenderableNode, dst string) (MappedNode, bool)

InternetOnlyPseudoNode never creates a pseudo node, unless it's the Internet.

func MapContainerIdentity added in v0.3.0

func MapContainerIdentity(_ string, m NodeMetadata) (MappedNode, bool)

MapContainerIdentity maps container topology node to container mapped nodes.

func MapEndpoint2Container added in v0.3.0

func MapEndpoint2Container(_ string, m NodeMetadata) (MappedNode, bool)

MapEndpoint2Container maps endpoint topology nodes to the containers they run in. We consider container and image IDs to be globally unique, and so don't scope them further by e.g. host. If no container metadata is found, nodes are grouped into the Uncontained node.

func NetworkHostname

func NetworkHostname(_ string, m NodeMetadata) (MappedNode, bool)

NetworkHostname takes a node NodeMetadata and returns a representation based on the hostname. Major label is the hostname, the minor label is the domain, if any.

func ProcessContainerImage added in v0.1.0

func ProcessContainerImage(_ string, m NodeMetadata) (MappedNode, bool)

ProcessContainerImage maps topology nodes to the container images they run on. If no container metadata is found, nodes are grouped into the Uncontained node.

func ProcessName

func ProcessName(_ string, m NodeMetadata) (MappedNode, bool)

ProcessName takes a node NodeMetadata from a topology, and returns a representation with the ID based on the process name (grouping all processes with the same name together).

func ProcessPID

func ProcessPID(_ string, m NodeMetadata) (MappedNode, bool)

ProcessPID takes a node NodeMetadata from topology, and returns a representation with the ID based on the process PID and the labels based on the process name.

type NodeMetadata

type NodeMetadata map[string]string

NodeMetadata describes a superset of the metadata that probes can collect about a given node in a given topology. Right now it's a weakly-typed map, which should probably change (see comment on type MapFunc).

func (NodeMetadata) Copy added in v0.3.0

func (nm NodeMetadata) Copy() NodeMetadata

Copy returns a value copy, useful for tests.

func (NodeMetadata) Merge added in v0.3.0

func (nm NodeMetadata) Merge(other NodeMetadata) NodeMetadata

Merge merges two node metadata maps together. In case of conflict, the other (right-hand) side wins. Always reassign the result of merge to the destination. Merge is defined on the value-type, but node metadata map is itself a reference type, so if you want to maintain immutability, use copy.

type NodeMetadatas

type NodeMetadatas map[string]NodeMetadata

NodeMetadatas collect metadata about each node in a topology. Keys are node IDs.

func (*NodeMetadatas) Merge

func (m *NodeMetadatas) Merge(other NodeMetadatas)

Merge merges another NodeMetadatas into the receiver.

type PseudoFunc added in v0.1.0

type PseudoFunc func(srcNodeID string, srcNode RenderableNode, dstNodeID string) (MappedNode, bool)

PseudoFunc creates MappedNode 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.

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  IDList            `json:"adjacency,omitempty"`   // Node IDs (in the same topology domain)
	Origins    IDList            `json:"origins,omitempty"`     // Core node IDs that contributed information
	Metadata   AggregateMetadata `json:"metadata"`              // Numeric sums
}

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 (*RenderableNode) Merge added in v0.3.0

func (rn *RenderableNode) Merge(other RenderableNode)

Merge merges in another RenderableNode

type RenderableNodes added in v0.3.0

type RenderableNodes map[string]RenderableNode

RenderableNodes is a set of RenderableNodes

func (RenderableNodes) Merge added in v0.3.0

func (rns RenderableNodes) Merge(other RenderableNodes)

Merge merges two sets of RenderableNodes

type Report

type Report struct {
	// Endpoint nodes are individual (address, port) tuples on each host.
	// They come from inspecting active connections and can (theoretically)
	// be traced back to a process. Edges are present.
	Endpoint Topology

	// Address nodes are addresses (e.g. ifconfig) on each host. Certain
	// information may be present in this topology that can't be mapped to
	// endpoints (e.g. ICMP). Edges are present.
	Address Topology

	// Process nodes are processes on each host. Edges are not present.
	Process Topology

	// Container nodes represent all Docker containers on hosts running probes.
	// Metadata includes things like Docker image, name etc.
	// Edges are not present.
	Container Topology

	// Host nodes are physical hosts that run probes. Metadata includes things
	// like operating system, load, etc. The information is scraped by the
	// probes with each published report. Edges are not present.
	Host Topology
}

Report is the core data type. It's produced by probes, and consumed and stored by apps. It's composed of multiple topologies, each representing a different (related, but not equivalent) view of the network.

func MakeReport added in v0.3.0

func MakeReport() Report

MakeReport makes a clean report, ready to Merge() other reports into.

func (Report) LocalNetworks added in v0.3.0

func (r Report) LocalNetworks() []*net.IPNet

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 (*Report) Merge

func (r *Report) Merge(other Report)

Merge merges another Report into the receiver.

func (Report) Squash added in v0.3.0

func (r Report) Squash() Report

Squash squashes all non-local nodes in the report to a super-node called the Internet.

func (Report) Topologies added in v0.3.0

func (r Report) Topologies() []Topology

Topologies returns a slice of Topologies in this report

func (Report) Validate added in v0.3.0

func (r Report) Validate() error

Validate checks the report for various inconsistencies.

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?
	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 added in v0.3.0

func OriginTable(r Report, originID string) (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 Topology

type Topology struct {
	Adjacency
	EdgeMetadatas
	NodeMetadatas
}

Topology describes a specific view of a network. It consists of nodes and edges, represented by Adjacency, and metadata about those nodes and edges, represented by EdgeMetadatas and NodeMetadatas respectively.

func NewTopology

func NewTopology() Topology

NewTopology gives you a Topology.

func SelectAddress added in v0.3.0

func SelectAddress(r Report) Topology

SelectAddress selects the address topology.

func SelectContainer added in v0.3.0

func SelectContainer(r Report) Topology

SelectContainer selects the container topology.

func SelectEndpoint added in v0.3.0

func SelectEndpoint(r Report) Topology

SelectEndpoint selects the endpoint topology.

func (Topology) EdgeMetadata

func (t Topology) EdgeMetadata(mapFunc MapFunc, srcRenderableID, dstRenderableID string) 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 (*Topology) Merge

func (t *Topology) Merge(other Topology)

Merge merges another Topology into the receiver.

func (Topology) RenderBy

func (t Topology) RenderBy(mapFunc MapFunc, pseudoFunc PseudoFunc) RenderableNodes

RenderBy transforms a given Topology 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.

RenderBy takes a a MapFunc, which defines how to group and label nodes. Npdes with the same mapped IDs will be merged.

func (Topology) Squash added in v0.3.0

func (t Topology) Squash(f IDAddresser, localNets []*net.IPNet) Topology

Squash squashes all non-local nodes in the topology to a super-node called the Internet. We rely on the values in the t.Adjacency lists being valid keys in t.NodeMetadata (or t.Adjacency).

func (Topology) Validate added in v0.3.0

func (t Topology) Validate() error

Validate checks the topology for various inconsistencies.

type TopologySelector added in v0.3.0

type TopologySelector func(r Report) Topology

TopologySelector selects a single topology from a report.

Jump to

Keyboard shortcuts

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