Documentation ¶
Index ¶
- Constants
- Variables
- func AddLocalBridge(name string) error
- func AddressIDAddresser(id string) net.IP
- func EndpointIDAddresser(id string) net.IP
- func ExtractHostID(m NodeMetadata) string
- func MakeAddressNodeID(hostID, address string) string
- func MakeAdjacencyID(srcNodeID string) string
- func MakeContainerNodeID(hostID, containerID string) string
- func MakeEdgeID(srcNodeID, dstNodeID string) string
- func MakeEndpointNodeID(hostID, address, port string) string
- func MakeHostNodeID(hostID string) string
- func MakeOverlayNodeID(peerName string) string
- func MakeProcessNodeID(hostID, pid string) string
- func ParseAdjacencyID(adjacencyID string) (string, bool)
- func ParseEdgeID(edgeID string) (srcNodeID, dstNodeID string, ok bool)
- func ParseEndpointNodeID(endpointNodeID string) (hostID, address, port string, ok bool)
- func ParseNodeID(nodeID string) (hostID string, remainder string, ok bool)
- type Adjacency
- type EdgeMetadata
- type EdgeMetadatas
- type IDAddresser
- type IDList
- type Interface
- type Networks
- type NodeMetadata
- type NodeMetadatas
- type Report
- type Sampling
- type Topology
- type TopologySelector
Constants ¶
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.
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" )
const TheInternet = "theinternet"
TheInternet is used as a node ID to indicate a remote IP.
Variables ¶
var ( LocalNetworks = Networks{} InterfaceByNameStub = func(name string) (Interface, error) { return net.InterfaceByName(name) } )
Variables exposed for testing. TODO this design is broken, make it consistent with probe networks.
Functions ¶
func AddLocalBridge ¶ added in v0.4.0
AddLocalBridge records the subnet address associated with the bridge name supplied, such that MakeAddressNodeID will scope addresses in this subnet as local.
func AddressIDAddresser ¶ added in v0.3.0
AddressIDAddresser converts an address node ID to an IP.
func EndpointIDAddresser ¶ added in v0.3.0
EndpointIDAddresser converts an endpoint node ID to an IP.
func ExtractHostID ¶ added in v0.4.0
func ExtractHostID(m NodeMetadata) string
ExtractHostID extracts the host id from NodeMetadata
func MakeAddressNodeID ¶ added in v0.3.0
MakeAddressNodeID produces an address node ID from its composite parts.
func MakeAdjacencyID ¶ added in v0.3.0
MakeAdjacencyID produces an adjacency ID from a node id.
func MakeContainerNodeID ¶ added in v0.3.0
MakeContainerNodeID produces a container node ID from its composite parts.
func MakeEdgeID ¶ added in v0.3.0
MakeEdgeID produces an edge ID from composite parts.
func MakeEndpointNodeID ¶ added in v0.3.0
MakeEndpointNodeID produces an endpoint node ID from its composite parts.
func MakeHostNodeID ¶ added in v0.3.0
MakeHostNodeID produces a host node ID from its composite parts.
func MakeOverlayNodeID ¶ added in v0.4.0
MakeOverlayNodeID produces an overlay topology node ID from a router peer's name, which is assumed to be globally unique.
func MakeProcessNodeID ¶ added in v0.3.0
MakeProcessNodeID produces a process node ID from its composite parts.
func ParseAdjacencyID ¶ added in v0.3.0
ParseAdjacencyID produces a node ID from an adjancency ID.
func ParseEdgeID ¶ added in v0.3.0
ParseEdgeID splits an edge ID to its composite parts.
func ParseEndpointNodeID ¶ added in v0.5.0
ParseEndpointNodeID produces the host ID, address, and port and remainder (typically an address) from an endpoint node ID. Note that hostID may be blank.
Types ¶
type Adjacency ¶
Adjacency is an adjacency-list encoding of the topology. Keys are node IDs, as produced by the relevant MappingFunc for the topology.
type EdgeMetadata ¶
type EdgeMetadata struct { EgressPacketCount *uint64 `json:"egress_packet_count,omitempty"` IngressPacketCount *uint64 `json:"ingress_packet_count,omitempty"` EgressByteCount *uint64 `json:"egress_byte_count,omitempty"` // Transport layer IngressByteCount *uint64 `json:"ingress_byte_count,omitempty"` // Transport layer MaxConnCountTCP *uint64 `json:"max_conn_count_tcp,omitempty"` }
EdgeMetadata describes a superset of the metadata that probes can possibly collect about a directed edge between two nodes in any topology.
func (*EdgeMetadata) Flatten ¶
func (m *EdgeMetadata) Flatten(other EdgeMetadata)
Flatten sums two EdgeMetadatas. Their windows should be the same duration; they 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.
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 ¶
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
MakeIDList makes a new IDList.
type NodeMetadata ¶
NodeMetadata describes a superset of the metadata that probes can collect about a given node in a given topology.
func MakeNodeMetadata ¶ added in v0.6.0
func MakeNodeMetadata() NodeMetadata
MakeNodeMetadata creates a new NodeMetadata with no initial metadata.
func MakeNodeMetadataWith ¶ added in v0.6.0
func MakeNodeMetadataWith(m map[string]string) NodeMetadata
MakeNodeMetadataWith creates a new NodeMetadata with the supplied map.
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 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 containter id, name, image id etc. // Edges are not present. Container Topology // ContainerImages nodes represent all Docker containers images on // hosts running probes. Metadata includes things like image id, name etc. // Edges are not present. ContainerImage 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 // Overlay nodes are active peers in any software-defined network that's // overlaid on the infrastructure. The information is scraped by polling // their status endpoints. Edges could be present, but aren't currently. Overlay Topology // Sampling data for this report. Sampling Sampling // Window is the amount of time that this report purports to represent. // Windows must be carefully merged. They should only be added when // reports cover non-overlapping periods of time. By default, we assume // that's true, and add windows in merge operations. When that's not true, // such as in the app, we expect the component to overwrite the window // before serving it to consumers. Window time.Duration }
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) Merge ¶
Merge merges another Report into the receiver. Pass addWindows true if the reports represent distinct (non-overlapping) periods of time.
func (Report) Topologies ¶ added in v0.3.0
Topologies returns a slice of Topologies in this report
type Sampling ¶ added in v0.6.0
Sampling describes how the packet data sources for this report were sampled. It can be used to calculate effective sample rates. We can't just put the rate here, because that can't be accurately merged. Counts in e.g. edge metadata structures have already been adjusted to compensate for the sample rate.
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 SelectAddress ¶ added in v0.3.0
SelectAddress selects the address topology.
func SelectContainer ¶ added in v0.3.0
SelectContainer selects the container topology.
func SelectContainerImage ¶ added in v0.4.0
SelectContainerImage selects the container image topology.
func SelectEndpoint ¶ added in v0.3.0
SelectEndpoint selects the endpoint topology.
func SelectHost ¶ added in v0.4.0
SelectHost selects the address topology.
func SelectProcess ¶ added in v0.4.0
SelectProcess selects the process topology.
type TopologySelector ¶ added in v0.3.0
TopologySelector selects a single topology from a report.