report

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2015 License: Apache-2.0 Imports: 9 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 (
	// 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

View Source
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

func AddLocalBridge(name string) error

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

func ExtractHostID(m Node) string

ExtractHostID extracts the host id from Node

func LocalAddresses added in v0.9.0

func LocalAddresses() ([]net.IP, error)

LocalAddresses returns a list of the local IP addresses.

func MakeAddressNodeID added in v0.3.0

func MakeAddressNodeID(hostID, address string) string

MakeAddressNodeID produces an address node ID from its composite parts.

func MakeContainerNodeID added in v0.3.0

func MakeContainerNodeID(hostID, containerID string) string

MakeContainerNodeID produces a container node ID from its 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 MakeOverlayNodeID added in v0.4.0

func MakeOverlayNodeID(peerName string) string

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

func MakePodNodeID(hostID, podID string) string

MakePodNodeID produces a pod 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 MakeScopedAddressNodeID added in v0.9.0

func MakeScopedAddressNodeID(hostID, address string) string

MakeScopedAddressNodeID is like MakeAddressNodeID, but it always prefixes the ID witha scope.

func MakeScopedEndpointNodeID added in v0.9.0

func MakeScopedEndpointNodeID(hostID, address, port string) string

MakeScopedEndpointNodeID is like MakeEndpointNodeID, but it always prefixes the ID witha scope.

func MakeServiceNodeID added in v0.9.0

func MakeServiceNodeID(namespaceID, serviceID string) string

MakeServiceNodeID produces a service node ID from its composite parts.

func ParseAddressNodeID added in v0.7.0

func ParseAddressNodeID(addressNodeID string) (hostID, address string, ok bool)

ParseAddressNodeID produces the host ID, address from an address node ID.

func ParseContainerNodeID added in v0.7.0

func ParseContainerNodeID(containerNodeID string) (hostID, containerID string, ok bool)

ParseContainerNodeID produces the host and container id from an container node ID.

func ParseEndpointNodeID added in v0.5.0

func ParseEndpointNodeID(endpointNodeID string) (hostID, address, port string, ok bool)

ParseEndpointNodeID produces the host ID, address, and port and remainder (typically an address) from an endpoint node ID. Note that hostID may be blank.

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

type Counters map[string]int

Counters is a string->int map.

func (Counters) Copy added in v0.7.0

func (c Counters) Copy() Counters

Copy creates a deep copy of the Counters.

func (Counters) Merge added in v0.7.0

func (c Counters) Merge(other Counters) Counters

Merge merges two sets of counters into a fresh set of counters, summing values where appropriate.

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

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.

func (IDList) Copy added in v0.7.0

func (a IDList) Copy() IDList

Copy returns a copy of the IDList.

func (IDList) Merge added in v0.5.0

func (a IDList) Merge(b IDList) IDList

Merge all elements from a and b into a new list

type Interface added in v0.4.0

type Interface interface {
	Addrs() ([]net.Addr, error)
}

Interface is exported for testing.

type Metadata added in v0.7.0

type Metadata map[string]string

Metadata is a string->string map.

func (Metadata) Copy added in v0.7.0

func (m Metadata) Copy() Metadata

Copy creates a deep copy of the Metadata.

func (Metadata) Merge added in v0.7.0

func (m Metadata) Merge(other Metadata) Metadata

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 does not modify the receiver.

type Networks added in v0.4.0

type Networks []*net.IPNet

Networks represent a set of subnets

func (Networks) Contains added in v0.4.0

func (n Networks) Contains(ip net.IP) bool

Contains returns true if IP is in Networks.

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

func MakeNodeWith(m map[string]string) Node

MakeNodeWith creates a new Node with the supplied map.

func (Node) Copy added in v0.7.0

func (n Node) Copy() Node

Copy returns a value copy of the Node.

func (Node) Merge added in v0.7.0

func (n Node) Merge(other Node) Node

Merge mergses the individual components of a node and returns a fresh node.

func (Node) WithAdjacent added in v0.7.0

func (n Node) WithAdjacent(a string) Node

WithAdjacent returns a fresh copy of n, with 'a' added to Adjacency

func (Node) WithCounters added in v0.7.0

func (n Node) WithCounters(c map[string]int) Node

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) WithMetadata added in v0.7.0

func (n Node) WithMetadata(m map[string]string) Node

WithMetadata returns a fresh copy of n, with Metadata m merged in.

type Nodes added in v0.7.0

type Nodes map[string]Node

Nodes is a collection of nodes in a topology. Keys are node IDs. TODO(pb): type Topology map[string]Node

func (Nodes) Copy added in v0.7.0

func (n Nodes) Copy() Nodes

Copy returns a value copy of the Nodes.

func (Nodes) Merge added in v0.7.0

func (n Nodes) Merge(other Nodes) Nodes

Merge merges the other object into this one, and returns the result object. The original is not modified.

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) Copy added in v0.7.0

func (r Report) Copy() Report

Copy returns a value copy of the report.

func (Report) Merge

func (r Report) Merge(other Report) Report

Merge merges another Report into the receiver and returns the result. The original is not modified.

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

type Sampling struct {
	Count uint64 // observed and processed
	Total uint64 // observed overall
}

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.

func (Sampling) Merge added in v0.6.0

func (s Sampling) Merge(other Sampling) Sampling

Merge combines two sampling structures via simple addition and returns the result. The original is not modified.

func (Sampling) Rate added in v0.6.0

func (s Sampling) Rate() float64

Rate returns the effective sampling 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 MakeTopology added in v0.7.0

func MakeTopology() Topology

MakeTopology gives you a Topology.

func (Topology) AddNode added in v0.7.0

func (t Topology) AddNode(nodeID string, nmd Node) Topology

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.

func (Topology) Copy added in v0.7.0

func (t Topology) Copy() Topology

Copy returns a value copy of the Topology.

func (Topology) Merge

func (t Topology) Merge(other Topology) Topology

Merge merges the other object into this one, and returns the result object. The original is not modified.

func (Topology) Validate added in v0.3.0

func (t Topology) Validate() error

Validate checks the topology for various inconsistencies.

Jump to

Keyboard shortcuts

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