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 Control
- type Controls
- type Counters
- type EdgeMetadata
- type EdgeMetadatas
- type IDList
- type Interface
- type LatestEntry
- type LatestMap
- func (m LatestMap) Copy() LatestMap
- func (m *LatestMap) GobDecode(input []byte) error
- func (m LatestMap) GobEncode() ([]byte, error)
- func (m LatestMap) Lookup(key string) (string, bool)
- func (m LatestMap) MarshalJSON() ([]byte, error)
- func (m LatestMap) Merge(newer LatestMap) LatestMap
- func (m LatestMap) Set(key string, timestamp time.Time, value string) LatestMap
- func (m *LatestMap) UnmarshalJSON(input []byte) error
- type Metadata
- type Metric
- func (m Metric) Add(t time.Time, v float64) Metric
- func (m Metric) Copy() Metric
- func (m Metric) Div(n float64) Metric
- func (m *Metric) GobDecode(input []byte) error
- func (m Metric) GobEncode() ([]byte, error)
- func (m Metric) LastSample() *Sample
- func (m Metric) Len() int
- func (m Metric) MarshalJSON() ([]byte, error)
- func (m Metric) Merge(other Metric) Metric
- func (m *Metric) UnmarshalJSON(input []byte) error
- func (m Metric) WithFirst(t time.Time) Metric
- type Metrics
- type Networks
- type Node
- func (n Node) Copy() Node
- func (n Node) Merge(other Node) Node
- func (n Node) WithAdjacent(a ...string) Node
- func (n Node) WithControls(cs ...string) Node
- func (n Node) WithCounters(c map[string]int) Node
- func (n Node) WithEdge(dst string, md EdgeMetadata) Node
- func (n Node) WithLatest(k string, ts time.Time, v string) Node
- func (n Node) WithMetadata(m map[string]string) Node
- func (n Node) WithMetric(key string, metric Metric) Node
- func (n Node) WithMetrics(metrics Metrics) Node
- func (n Node) WithSet(key string, set StringSet) Node
- func (n Node) WithSets(sets Sets) Node
- type NodeControls
- type Nodes
- type Report
- type Sample
- type Sampling
- type Sets
- type StringSet
- type Topology
- type WireMetrics
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" // ProbeID is the random ID of the probe which generated the specific node. ProbeID = "probe_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 Control ¶ added in v0.10.0
type Control struct { ID string `json:"id"` Human string `json:"human"` Icon string `json:"icon"` // from https://fortawesome.github.io/Font-Awesome/cheatsheet/ please }
A Control basically describes an RPC
type Controls ¶ added in v0.10.0
Controls describe the control tags within the Nodes
func (Controls) AddControl ¶ added in v0.10.0
AddControl returns a fresh Controls, c added to cs.
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 StringSet
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 LatestEntry ¶ added in v0.10.0
LatestEntry represents a timestamped value inside the LatestMap.
func (LatestEntry) String ¶ added in v0.10.0
func (e LatestEntry) String() string
type LatestMap ¶ added in v0.10.0
LatestMap is a persitent map which support latest-win merges. We have to embed ps.Map as its an interface. LatestMaps are immutable.
func MakeLatestMap ¶ added in v0.10.0
func MakeLatestMap() LatestMap
MakeLatestMap makes an empty LatestMap
func (LatestMap) MarshalJSON ¶ added in v0.10.0
MarshalJSON implements json.Marshaller
func (LatestMap) Merge ¶ added in v0.10.0
Merge produces a fresh LatestMap, container the kers from both inputs. When both inputs container the same key, the latter value is used.
func (*LatestMap) UnmarshalJSON ¶ added in v0.10.0
UnmarshalJSON implements json.Unmarshaler
type Metadata ¶ added in v0.7.0
Metadata is a string->string map.
type Metric ¶ added in v0.10.0
Metric is a list of timeseries data with some metadata. Clients must use the Add method to add values. Metrics are immutable.
func (Metric) Add ¶ added in v0.10.0
Add returns a new Metric with (t, v) added to its Samples. Add is the only valid way to grow a Metric.
func (Metric) Copy ¶ added in v0.10.0
Copy returns a value copy of the Metric. Metric is immutable, so we can skip this.
func (Metric) Div ¶ added in v0.10.0
Div returns a new copy of the metric, with each value divided by n.
func (Metric) LastSample ¶ added in v0.10.0
LastSample returns the last sample in the metric, or nil if there are no samples.
func (Metric) MarshalJSON ¶ added in v0.10.0
MarshalJSON implements json.Marshaller
func (*Metric) UnmarshalJSON ¶ added in v0.10.0
UnmarshalJSON implements json.Unmarshaler
type Metrics ¶ added in v0.10.0
Metrics is a string->metric map.
type Node ¶ added in v0.7.0
type Node struct { Metadata Metadata `json:"metadata,omitempty"` Counters Counters `json:"counters,omitempty"` Sets Sets `json:"sets,omitempty"` Adjacency IDList `json:"adjacency"` Edges EdgeMetadatas `json:"edges,omitempty"` Controls NodeControls `json:"controls,omitempty"` Latest LatestMap `json:"latest,omitempty"` Metrics Metrics `json:"metrics,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) WithControls ¶ added in v0.10.0
WithControls returns a fresh copy of n, with cs added to Controls.
func (Node) WithCounters ¶ added in v0.7.0
WithCounters returns a fresh copy of n, with Counters c merged in.
func (Node) WithEdge ¶ added in v0.7.0
func (n Node) WithEdge(dst string, md EdgeMetadata) Node
WithEdge returns a fresh copy of n, with 'dst' added to Adjacency and md added to EdgeMetadata.
func (Node) WithLatest ¶ added in v0.10.0
WithLatest produces a new Node with k mapped to v in the Latest metadata.
func (Node) WithMetadata ¶ added in v0.7.0
WithMetadata returns a fresh copy of n, with Metadata m merged in.
func (Node) WithMetric ¶ added in v0.10.0
WithMetric returns a fresh copy of n, with metric merged in at key.
func (Node) WithMetrics ¶ added in v0.10.0
WithMetrics returns a fresh copy of n, with metrics merged in.
type NodeControls ¶ added in v0.10.0
type NodeControls struct { Timestamp time.Time `json:"timestamp"` Controls StringSet `json:"controls,omitempty"` }
NodeControls represent the individual controls that are valid for a given node at a given point in time. Its is immutable. A zero-value for Timestamp indicated this NodeControls is 'not set'.
func MakeNodeControls ¶ added in v0.10.0
func MakeNodeControls() NodeControls
MakeNodeControls makes a new NodeControls
func (NodeControls) Add ¶ added in v0.10.0
func (nc NodeControls) Add(ids ...string) NodeControls
Add the new control IDs to this NodeControls, producing a fresh NodeControls.
func (NodeControls) Copy ¶ added in v0.10.0
func (nc NodeControls) Copy() NodeControls
Copy is a noop, as NodeControls is immutable
func (NodeControls) Merge ¶ added in v0.10.0
func (nc NodeControls) Merge(other NodeControls) NodeControls
Merge returns the newest of the two NodeControls; it does not take the union of the valid Controls.
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 // Shortcut reports should be propogated to the UI as quickly as possible, // bypassing the usual spy interval, publish interval and app ws interval. Shortcut bool }
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 Sets ¶ added in v0.10.0
Sets is a string->set-of-strings map.
type StringSet ¶ added in v0.10.0
type StringSet []string
StringSet is a sorted set of unique strings. Clients must use the Add method to add strings.
func MakeStringSet ¶ added in v0.10.0
MakeStringSet makes a new StringSet with the given strings.
func (StringSet) Add ¶ added in v0.10.0
Add adds the strings to the StringSet. Add is the only valid way to grow a StringSet. Add returns the StringSet to enable chaining.
type Topology ¶
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.
type WireMetrics ¶ added in v0.10.0
type WireMetrics struct { Samples []Sample `json:"samples"` // On the wire, samples are sorted oldest to newest, Min float64 `json:"min"` // the opposite order to how we store them internally. Max float64 `json:"max"` First string `json:"first,omitempty"` Last string `json:"last,omitempty"` }
WireMetrics is the on-the-wire representation of Metrics.