Documentation ¶
Index ¶
- Constants
- Variables
- func AddLocalBridge(name string) error
- func ExtractHostID(m Node) string
- func LocalAddresses() ([]net.IP, error)
- func MakeAddressNodeID(hostID, address string) string
- func MakeContainerNodeID(hostID, containerID string) string
- func MakeEndpointNodeID(hostID, address, port string) string
- func MakeHostNodeID(hostID string) string
- func MakeOverlayNodeID(peerName string) string
- func MakePodNodeID(hostID, podID string) string
- func MakeProcessNodeID(hostID, pid string) string
- func MakeScopedAddressNodeID(hostID, address string) string
- func MakeScopedEndpointNodeID(hostID, address, port string) string
- func MakeServiceNodeID(namespaceID, serviceID string) string
- func ParseAddressNodeID(addressNodeID string) (hostID, address string, ok bool)
- func ParseContainerNodeID(containerNodeID string) (hostID, containerID string, ok bool)
- func ParseEndpointNodeID(endpointNodeID string) (hostID, address, port string, ok bool)
- func ParseNodeID(nodeID string) (hostID string, remainder string, ok bool)
- type Counters
- type EdgeMetadata
- type EdgeMetadatas
- type IDList
- type Interface
- type Metadata
- type Networks
- type Node
- type Nodes
- type Report
- type Sampling
- type Topology
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 ExtractHostID ¶ added in v0.4.0
ExtractHostID extracts the host id from Node
func LocalAddresses ¶ added in v0.9.0
LocalAddresses returns a list of the local IP addresses.
func MakeAddressNodeID ¶ added in v0.3.0
MakeAddressNodeID produces an address node ID from its composite parts.
func MakeContainerNodeID ¶ added in v0.3.0
MakeContainerNodeID produces a container node ID from its 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 MakePodNodeID ¶ added in v0.9.0
MakePodNodeID produces a pod node ID from its composite parts.
func MakeProcessNodeID ¶ added in v0.3.0
MakeProcessNodeID produces a process node ID from its composite parts.
func MakeScopedAddressNodeID ¶ added in v0.9.0
MakeScopedAddressNodeID is like MakeAddressNodeID, but it always prefixes the ID witha scope.
func MakeScopedEndpointNodeID ¶ added in v0.9.0
MakeScopedEndpointNodeID is like MakeEndpointNodeID, but it always prefixes the ID witha scope.
func MakeServiceNodeID ¶ added in v0.9.0
MakeServiceNodeID produces a service node ID from its composite parts.
func ParseAddressNodeID ¶ added in v0.7.0
ParseAddressNodeID produces the host ID, address from an address node ID.
func ParseContainerNodeID ¶ added in v0.7.0
ParseContainerNodeID produces the host and container id from an container node ID.
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 Counters ¶ added in v0.7.0
Counters is a string->int map.
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) Copy ¶ added in v0.7.0
func (e EdgeMetadata) Copy() EdgeMetadata
Copy returns a value copy of the EdgeMetadata.
func (EdgeMetadata) Flatten ¶
func (e EdgeMetadata) Flatten(other EdgeMetadata) EdgeMetadata
Flatten sums two EdgeMetadatas and returns the result. The receiver is not modified. The two edge metadata windows should be the same duration; they should represent different edges at the same time.
func (EdgeMetadata) Merge ¶
func (e EdgeMetadata) Merge(other EdgeMetadata) EdgeMetadata
Merge merges another EdgeMetadata into the receiver and returns the result. The receiver is not modified. The two edge metadatas should represent the same edge on different times.
func (EdgeMetadata) Reversed ¶ added in v0.8.0
func (e EdgeMetadata) Reversed() EdgeMetadata
Reversed returns a value copy of the EdgeMetadata, with the direction reversed.
type EdgeMetadatas ¶
type EdgeMetadatas map[string]EdgeMetadata
EdgeMetadatas collect metadata about each edge in a topology. Keys are the remote node IDs, as in Adjacency.
func (EdgeMetadatas) Copy ¶ added in v0.7.0
func (e EdgeMetadatas) Copy() EdgeMetadatas
Copy returns a value copy of the EdgeMetadatas.
func (EdgeMetadatas) Flatten ¶ added in v0.7.0
func (e EdgeMetadatas) Flatten() EdgeMetadata
Flatten flattens all the EdgeMetadatas in this set and returns the result. The original is not modified.
func (EdgeMetadatas) Merge ¶
func (e EdgeMetadatas) Merge(other EdgeMetadatas) EdgeMetadatas
Merge merges the other object into this one, and returns the result object. The original is not modified.
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 Metadata ¶ added in v0.7.0
Metadata is a string->string map.
type Node ¶ added in v0.7.0
type Node struct { Metadata `json:"metadata,omitempty"` Counters `json:"counters,omitempty"` Adjacency IDList `json:"adjacency"` Edges EdgeMetadatas `json:"edges,omitempty"` }
Node describes a superset of the metadata that probes can collect about a given node in a given topology, along with the edges emanating from the node and metadata about those edges.
func MakeNode ¶ added in v0.7.0
func MakeNode() Node
MakeNode creates a new Node with no initial metadata.
func MakeNodeWith ¶ added in v0.7.0
MakeNodeWith creates a new Node with the supplied map.
func (Node) Merge ¶ added in v0.7.0
Merge mergses the individual components of a node and returns a fresh node.
func (Node) WithAdjacent ¶ added in v0.7.0
WithAdjacent returns a fresh copy of n, with 'a' added to Adjacency
func (Node) WithCounters ¶ added in v0.7.0
WithCounters returns a fresh copy of n, with Counters c merged in.
type Nodes ¶ added in v0.7.0
Nodes is a collection of nodes in a topology. Keys are node IDs. TODO(pb): type Topology map[string]Node
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 // Pod nodes represent all Kubernetes pods running on hosts running probes. // Metadata includes things like pod id, name etc. Edges are not // present. Pod Topology // Service nodes represent all Kubernetes services running on hosts running probes. // Metadata includes things like service id, name etc. Edges are not // present. Service 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 and returns the result. The original is not modified.
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 {
Nodes // TODO(pb): remove Nodes intermediate type
}
Topology describes a specific view of a network. It consists of nodes and edges, and metadata about those nodes and edges, represented by EdgeMetadatas and Nodes respectively. Edges are directional, and embedded in the Node struct.
func (Topology) AddNode ¶ added in v0.7.0
AddNode adds node to the topology under key nodeID; if a node already exists for this key, nmd is merged with that node. The same topology is returned to enable chaining. This method is different from all the other similar methods in that it mutates the Topology, to solve issues of GC pressure.