report

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2016 License: Apache-2.0 Imports: 21 Imported by: 218

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 (
	FromLatest   = "latest"
	FromSets     = "sets"
	FromCounters = "counters"
)

FromLatest and friends denote the different fields where metadata can be gathered from.

View Source
const (
	DefaultFormat  = ""
	FilesizeFormat = "filesize"
	IntegerFormat  = "integer"
	PercentFormat  = "percent"
)

DefaultFormat and friends tell the UI how to render the "Value" of this metric.

View Source
const (
	Endpoint       = "endpoint"
	Process        = "process"
	Container      = "container"
	Pod            = "pod"
	Service        = "service"
	ContainerImage = "container_image"
	Host           = "host"
	Overlay        = "overlay"

	// Used when counting the number of containers
	ContainersKey = "containers"
)

Names of the various topologies.

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"
	// ControlProbeID is the random ID of the probe which controls the specific node.
	ControlProbeID = "control_probe_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.

View Source
var EmptyCounters = Counters{ps.NewMap()}

EmptyCounters is the set of empty counters.

View Source
var EmptyEdgeMetadatas = EdgeMetadatas{ps.NewMap()}

EmptyEdgeMetadatas is the set of empty EdgeMetadatas.

View Source
var EmptyIDList = IDList(EmptyStringSet)

EmptyIDList is an Empty ID List.

View Source
var EmptyLatestMap = LatestMap{ps.NewMap()}

EmptyLatestMap is an empty LatestMap. Start with this.

View Source
var EmptyNodeSet = NodeSet{ps.NewMap()}

EmptyNodeSet is the empty set of nodes.

View Source
var EmptySets = Sets{ps.NewMap()}

EmptySets is an empty Sets. Starts with this.

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

func MakeContainerImageNodeID(containerImageID string) string

MakeContainerImageNodeID produces a container image node ID from its composite parts.

func MakeContainerNodeID added in v0.3.0

func MakeContainerNodeID(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(namespaceID, 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) (containerID string, ok bool)

ParseContainerNodeID produces the 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 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

type Controls map[string]Control

Controls describe the control tags within the Nodes

func (Controls) AddControl added in v0.10.0

func (cs Controls) AddControl(c Control)

AddControl returns a fresh Controls, c added to cs.

func (Controls) Copy added in v0.10.0

func (cs Controls) Copy() Controls

Copy produces a copy of cs.

func (Controls) Merge added in v0.10.0

func (cs Controls) Merge(other Controls) Controls

Merge merges other with cs, returning a fresh Controls.

type Counters added in v0.7.0

type Counters struct {
	// contains filtered or unexported fields
}

Counters is a string->int map.

func MakeCounters added in v0.12.0

func MakeCounters() Counters

MakeCounters returns EmptyCounters

func (Counters) Add added in v0.12.0

func (c Counters) Add(key string, value int) Counters

Add value to the counter 'key'

func (*Counters) CodecDecodeSelf added in v0.13.0

func (c *Counters) CodecDecodeSelf(decoder *codec.Decoder)

CodecDecodeSelf implements codec.Selfer

func (*Counters) CodecEncodeSelf added in v0.13.0

func (c *Counters) CodecEncodeSelf(encoder *codec.Encoder)

CodecEncodeSelf implements codec.Selfer

func (Counters) Copy added in v0.7.0

func (c Counters) Copy() Counters

Copy is a noop

func (Counters) DeepEqual added in v0.12.0

func (c Counters) DeepEqual(d Counters) bool

DeepEqual tests equality with other Counters

func (Counters) ForEach added in v0.14.0

func (c Counters) ForEach(f func(key string, val int))

ForEach calls f for each k/v pair of counters. Keys are iterated in lexicographical order.

func (*Counters) GobDecode added in v0.12.0

func (c *Counters) GobDecode(input []byte) error

GobDecode implements gob.Unmarshaller

func (Counters) GobEncode added in v0.12.0

func (c Counters) GobEncode() ([]byte, error)

GobEncode implements gob.Marshaller

func (Counters) Lookup added in v0.12.0

func (c Counters) Lookup(key string) (int, bool)

Lookup the counter 'key'

func (Counters) MarshalJSON added in v0.12.0

func (Counters) MarshalJSON() ([]byte, error)

MarshalJSON shouldn't be used, use CodecEncodeSelf instead

func (Counters) Merge added in v0.7.0

func (c Counters) Merge(other Counters) Counters

Merge produces a fresh Counters, container the keys from both inputs. When both inputs container the same key, the latter value is used.

func (Counters) Size added in v0.12.0

func (c Counters) Size() int

Size returns the number of counters

func (Counters) String added in v0.12.0

func (c Counters) String() string

String serializes Counters into a string.

func (*Counters) UnmarshalJSON added in v0.12.0

func (*Counters) UnmarshalJSON(b []byte) error

UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead

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
}

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.

func (EdgeMetadata) String added in v0.14.0

func (e EdgeMetadata) String() string

String returns a string representation of this EdgeMetadata Helps with our use of Spew and diff.

type EdgeMetadatas

type EdgeMetadatas struct {
	// contains filtered or unexported fields
}

EdgeMetadatas collect metadata about each edge in a topology. Keys are the remote node IDs, as in Adjacency.

func MakeEdgeMetadatas added in v0.12.0

func MakeEdgeMetadatas() EdgeMetadatas

MakeEdgeMetadatas returns EmptyEdgeMetadatas

func (EdgeMetadatas) Add added in v0.12.0

func (c EdgeMetadatas) Add(key string, value EdgeMetadata) EdgeMetadatas

Add value to the counter 'key'

func (*EdgeMetadatas) CodecDecodeSelf added in v0.13.0

func (c *EdgeMetadatas) CodecDecodeSelf(decoder *codec.Decoder)

CodecDecodeSelf implements codec.Selfer

func (*EdgeMetadatas) CodecEncodeSelf added in v0.13.0

func (c *EdgeMetadatas) CodecEncodeSelf(encoder *codec.Encoder)

CodecEncodeSelf implements codec.Selfer

func (EdgeMetadatas) Copy added in v0.7.0

func (c EdgeMetadatas) Copy() EdgeMetadatas

Copy is a noop

func (EdgeMetadatas) DeepEqual added in v0.12.0

func (c EdgeMetadatas) DeepEqual(d EdgeMetadatas) bool

DeepEqual tests equality with other Counters

func (EdgeMetadatas) Flatten added in v0.7.0

func (c EdgeMetadatas) Flatten() EdgeMetadata

Flatten flattens all the EdgeMetadatas in this set and returns the result. The original is not modified.

func (EdgeMetadatas) ForEach added in v0.12.0

func (c EdgeMetadatas) ForEach(fn func(k string, v EdgeMetadata))

ForEach executes f on each key value pair in the map

func (*EdgeMetadatas) GobDecode added in v0.12.0

func (c *EdgeMetadatas) GobDecode(input []byte) error

GobDecode implements gob.Unmarshaller

func (EdgeMetadatas) GobEncode added in v0.12.0

func (c EdgeMetadatas) GobEncode() ([]byte, error)

GobEncode implements gob.Marshaller

func (EdgeMetadatas) Lookup added in v0.12.0

func (c EdgeMetadatas) Lookup(key string) (EdgeMetadata, bool)

Lookup the counter 'key'

func (EdgeMetadatas) MarshalJSON added in v0.12.0

func (EdgeMetadatas) MarshalJSON() ([]byte, error)

MarshalJSON shouldn't be used, use CodecEncodeSelf instead

func (EdgeMetadatas) Merge

func (c EdgeMetadatas) Merge(other EdgeMetadatas) EdgeMetadatas

Merge produces a fresh Counters, container the keys from both inputs. When both inputs container the same key, the latter value is used.

func (EdgeMetadatas) Size added in v0.12.0

func (c EdgeMetadatas) Size() int

Size is the number of elements

func (EdgeMetadatas) String added in v0.12.0

func (c EdgeMetadatas) String() string

func (*EdgeMetadatas) UnmarshalJSON added in v0.12.0

func (*EdgeMetadatas) UnmarshalJSON(b []byte) error

UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead

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

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) Intersection added in v0.14.0

func (a IDList) Intersection(b IDList) IDList

Intersection returns the intersection of a and b

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

func (IDList) Remove added in v0.12.0

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

Remove is the only correct way to remove IDs from an IDList.

type Interface added in v0.4.0

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

Interface is exported for testing.

type LatestEntry added in v0.10.0

type LatestEntry struct {
	Timestamp time.Time `json:"timestamp"`
	Value     string    `json:"value"`
}

LatestEntry represents a timestamped value inside the LatestMap.

func (LatestEntry) Equal added in v0.12.0

func (e LatestEntry) Equal(e2 LatestEntry) bool

Equal returns true if the supplied LatestEntry is equal to this one.

func (LatestEntry) String added in v0.10.0

func (e LatestEntry) String() string

type LatestMap added in v0.10.0

type LatestMap struct {
	ps.Map
}

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) CodecDecodeSelf added in v0.13.0

func (m *LatestMap) CodecDecodeSelf(decoder *codec.Decoder)

CodecDecodeSelf implements codec.Selfer

func (*LatestMap) CodecEncodeSelf added in v0.13.0

func (m *LatestMap) CodecEncodeSelf(encoder *codec.Encoder)

CodecEncodeSelf implements codec.Selfer

func (LatestMap) Copy added in v0.10.0

func (m LatestMap) Copy() LatestMap

Copy is a noop, as LatestMaps are immutable.

func (LatestMap) DeepEqual added in v0.12.0

func (m LatestMap) DeepEqual(n LatestMap) bool

DeepEqual tests equality with other LatestMap

func (LatestMap) Delete added in v0.12.0

func (m LatestMap) Delete(key string) LatestMap

Delete the value for the given key.

func (LatestMap) ForEach added in v0.12.0

func (m LatestMap) ForEach(fn func(k, v string))

ForEach executes f on each key value pair in the map

func (*LatestMap) GobDecode added in v0.10.0

func (m *LatestMap) GobDecode(input []byte) error

GobDecode implements gob.Unmarshaller

func (LatestMap) GobEncode added in v0.10.0

func (m LatestMap) GobEncode() ([]byte, error)

GobEncode implements gob.Marshaller

func (LatestMap) Lookup added in v0.10.0

func (m LatestMap) Lookup(key string) (string, bool)

Lookup the value for the given key.

func (LatestMap) LookupEntry added in v0.14.0

func (m LatestMap) LookupEntry(key string) (string, time.Time, bool)

LookupEntry returns the raw entry for the given key.

func (LatestMap) MarshalJSON added in v0.10.0

func (LatestMap) MarshalJSON() ([]byte, error)

MarshalJSON shouldn't be used, use CodecEncodeSelf instead

func (LatestMap) Merge added in v0.10.0

func (m LatestMap) Merge(other LatestMap) LatestMap

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) Set added in v0.10.0

func (m LatestMap) Set(key string, timestamp time.Time, value string) LatestMap

Set the value for the given key.

func (LatestMap) Size added in v0.12.0

func (m LatestMap) Size() int

Size returns the number of elements

func (LatestMap) String added in v0.12.0

func (m LatestMap) String() string

func (*LatestMap) UnmarshalJSON added in v0.10.0

func (*LatestMap) UnmarshalJSON(b []byte) error

UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead

type MetadataRow added in v0.14.0

type MetadataRow struct {
	ID       string  `json:"id"`
	Label    string  `json:"label"`
	Value    string  `json:"value"`
	Priority float64 `json:"priority,omitempty"`
	Datatype string  `json:"dataType,omitempty"`
}

MetadataRow is a row for the metadata table.

func (MetadataRow) Copy added in v0.14.0

func (m MetadataRow) Copy() MetadataRow

Copy returns a value copy of a metadata row.

type MetadataRowsByPriority added in v0.14.0

type MetadataRowsByPriority []MetadataRow

MetadataRowsByPriority implements sort.Interface, so we can sort the rows by priority before rendering them to the UI.

func (MetadataRowsByPriority) Len added in v0.14.0

func (m MetadataRowsByPriority) Len() int

Len is part of sort.Interface.

func (MetadataRowsByPriority) Less added in v0.14.0

func (m MetadataRowsByPriority) Less(i, j int) bool

Less is part of sort.Interface.

func (MetadataRowsByPriority) Swap added in v0.14.0

func (m MetadataRowsByPriority) Swap(i, j int)

Swap is part of sort.Interface.

type MetadataTemplate added in v0.14.0

type MetadataTemplate struct {
	ID       string  `json:"id"`
	Label    string  `json:"label,omitempty"`    // Human-readable descriptor for this row
	Truncate int     `json:"truncate,omitempty"` // If > 0, truncate the value to this length.
	Datatype string  `json:"dataType,omitempty"`
	Priority float64 `json:"priority,omitempty"`
	From     string  `json:"from,omitempty"` // Defines how to get the value from a report node
}

MetadataTemplate extracts some metadata rows from a node

func (MetadataTemplate) Copy added in v0.14.0

Copy returns a value-copy of the template

func (MetadataTemplate) MetadataRows added in v0.14.0

func (t MetadataTemplate) MetadataRows(n Node) []MetadataRow

MetadataRows returns the rows for a node

type MetadataTemplates added in v0.14.0

type MetadataTemplates map[string]MetadataTemplate

MetadataTemplates is a mergeable set of metadata templates

func (MetadataTemplates) Copy added in v0.14.0

Copy returns a value copy of the metadata templates

func (MetadataTemplates) Merge added in v0.14.0

Merge merges two sets of MetadataTemplates so far just ignores based on duplicate id key

func (MetadataTemplates) MetadataRows added in v0.14.0

func (e MetadataTemplates) MetadataRows(n Node) []MetadataRow

MetadataRows returns the rows for a node

type Metric added in v0.10.0

type Metric struct {
	Samples     ps.List
	Min, Max    float64
	First, Last time.Time
}

Metric is a list of timeseries data with some metadata. Clients must use the Add method to add values. Metrics are immutable.

func MakeMetric added in v0.10.0

func MakeMetric() Metric

MakeMetric makes a new Metric.

func (Metric) Add added in v0.10.0

func (m Metric) Add(t time.Time, v float64) Metric

Add returns a new Metric with (t, v) added to its Samples. Add is the only valid way to grow a Metric.

func (*Metric) CodecDecodeSelf added in v0.13.0

func (m *Metric) CodecDecodeSelf(decoder *codec.Decoder)

CodecDecodeSelf implements codec.Selfer

func (*Metric) CodecEncodeSelf added in v0.13.0

func (m *Metric) CodecEncodeSelf(encoder *codec.Encoder)

CodecEncodeSelf implements codec.Selfer

func (Metric) Copy added in v0.10.0

func (m Metric) Copy() Metric

Copy returns a value copy of the Metric. Metric is immutable, so we can skip this.

func (Metric) Div added in v0.10.0

func (m Metric) Div(n float64) Metric

Div returns a new copy of the metric, with each value divided by n.

func (*Metric) GobDecode added in v0.10.0

func (m *Metric) GobDecode(input []byte) error

GobDecode implements gob.Unmarshaller

func (Metric) GobEncode added in v0.10.0

func (m Metric) GobEncode() ([]byte, error)

GobEncode implements gob.Marshaller

func (Metric) LastSample added in v0.10.0

func (m Metric) LastSample() *Sample

LastSample returns the last sample in the metric, or nil if there are no samples.

func (Metric) Len added in v0.10.0

func (m Metric) Len() int

Len returns the number of samples in the metric.

func (Metric) MarshalJSON added in v0.10.0

func (Metric) MarshalJSON() ([]byte, error)

MarshalJSON shouldn't be used, use CodecEncodeSelf instead

func (Metric) Merge added in v0.10.0

func (m Metric) Merge(other Metric) Metric

Merge combines the two Metrics and returns a new result.

func (Metric) ToIntermediate added in v0.12.0

func (m Metric) ToIntermediate() WireMetrics

ToIntermediate converts the metric to a representation suitable for serialization.

func (*Metric) UnmarshalJSON added in v0.10.0

func (*Metric) UnmarshalJSON(b []byte) error

UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead

func (Metric) WithFirst added in v0.10.0

func (m Metric) WithFirst(t time.Time) Metric

WithFirst returns a fresh copy of m, with First set to t.

func (Metric) WithMax added in v0.11.0

func (m Metric) WithMax(max float64) Metric

WithMax returns a fresh copy of m, with Max set to max

type MetricRow added in v0.14.0

type MetricRow struct {
	ID       string
	Label    string
	Format   string
	Group    string
	Value    float64
	Priority float64
	Metric   *Metric
}

MetricRow is a tuple of data used to render a metric as a sparkline and accoutrements.

func (*MetricRow) CodecDecodeSelf added in v0.14.0

func (m *MetricRow) CodecDecodeSelf(decoder *codec.Decoder)

CodecDecodeSelf implements codec.Selfer

func (*MetricRow) CodecEncodeSelf added in v0.14.0

func (m *MetricRow) CodecEncodeSelf(encoder *codec.Encoder)

CodecEncodeSelf marshals this MetricRow. It takes the basic Metric rendering, then adds some row-specific fields.

func (MetricRow) Copy added in v0.14.0

func (m MetricRow) Copy() MetricRow

Copy returns a value copy of the MetricRow

func (MetricRow) MarshalJSON added in v0.14.0

func (MetricRow) MarshalJSON() ([]byte, error)

MarshalJSON shouldn't be used, use CodecEncodeSelf instead

func (MetricRow) Summary added in v0.14.0

func (m MetricRow) Summary() MetricRow

Summary returns a copy of the MetricRow, without the samples, just the value if there is one.

func (*MetricRow) UnmarshalJSON added in v0.14.0

func (*MetricRow) UnmarshalJSON(b []byte) error

UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead

type MetricRowsByPriority added in v0.14.0

type MetricRowsByPriority []MetricRow

MetricRowsByPriority implements sort.Interface, so we can sort the rows by priority before rendering them to the UI.

func (MetricRowsByPriority) Len added in v0.14.0

func (m MetricRowsByPriority) Len() int

Len is part of sort.Interface.

func (MetricRowsByPriority) Less added in v0.14.0

func (m MetricRowsByPriority) Less(i, j int) bool

Less is part of sort.Interface.

func (MetricRowsByPriority) Swap added in v0.14.0

func (m MetricRowsByPriority) Swap(i, j int)

Swap is part of sort.Interface.

type MetricTemplate added in v0.14.0

type MetricTemplate struct {
	ID       string  `json:"id"`
	Label    string  `json:"label,omitempty"`
	Format   string  `json:"format,omitempty"`
	Group    string  `json:"group,omitempty"`
	Priority float64 `json:"priority,omitempty"`
}

MetricTemplate extracts a metric row from a node

func (MetricTemplate) Copy added in v0.14.0

func (t MetricTemplate) Copy() MetricTemplate

Copy returns a value-copy of the metric template

func (MetricTemplate) MetricRows added in v0.14.0

func (t MetricTemplate) MetricRows(n Node) []MetricRow

MetricRows returns the rows for a node

type MetricTemplates added in v0.14.0

type MetricTemplates map[string]MetricTemplate

MetricTemplates is a mergeable set of metric templates

func (MetricTemplates) Copy added in v0.14.0

Copy returns a value copy of the metadata templates

func (MetricTemplates) Merge added in v0.14.0

Merge merges two sets of MetricTemplates so far just ignores based on duplicate id key

func (MetricTemplates) MetricRows added in v0.14.0

func (e MetricTemplates) MetricRows(n Node) []MetricRow

MetricRows returns the rows for a node

type Metrics added in v0.10.0

type Metrics map[string]Metric

Metrics is a string->metric map.

func (Metrics) Copy added in v0.10.0

func (m Metrics) Copy() Metrics

Copy returns a value copy of the sets map.

func (Metrics) Lookup added in v0.14.0

func (m Metrics) Lookup(key string) (Metric, bool)

Lookup the metric for the given key

func (Metrics) Merge added in v0.10.0

func (m Metrics) Merge(other Metrics) Metrics

Merge merges two sets maps into a fresh set, performing set-union merges as appropriate.

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 {
	ID        string        `json:"id,omitempty"`
	Topology  string        `json:"topology,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"`
	Parents   Sets          `json:"parents,omitempty"`
	Children  NodeSet       `json:"children,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) After added in v0.12.0

func (n Node) After(other Node) bool

After is used for sorting nodes by topology and id

func (Node) Before added in v0.12.0

func (n Node) Before(other Node) bool

Before is used for sorting nodes by topology and id

func (Node) Copy added in v0.7.0

func (n Node) Copy() Node

Copy returns a value copy of the Node.

func (Node) Equal added in v0.12.0

func (n Node) Equal(other Node) bool

Equal is used for comparing nodes by topology and id

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) Prune added in v0.14.0

func (n Node) Prune() Node

Prune returns a copy of the Node with all information not strictly necessary for rendering nodes and edges stripped away. Specifically, that means cutting out parts of the Node.

func (Node) PruneParents added in v0.14.0

func (n Node) PruneParents() Node

PruneParents returns a fresh copy of n, without any parents.

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) WithChild added in v0.14.0

func (n Node) WithChild(child Node) Node

WithChild returns a fresh copy of n, with one child merged in.

func (Node) WithChildren added in v0.14.0

func (n Node) WithChildren(children NodeSet) Node

WithChildren returns a fresh copy of n, with children merged in.

func (Node) WithControls added in v0.10.0

func (n Node) WithControls(cs ...string) Node

WithControls returns a fresh copy of n, with cs added to Controls.

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) WithID added in v0.12.0

func (n Node) WithID(id string) Node

WithID returns a fresh copy of n, with ID changed.

func (Node) WithLatest added in v0.10.0

func (n Node) WithLatest(k string, ts time.Time, v string) Node

WithLatest produces a new Node with k mapped to v in the Latest metadata.

func (Node) WithLatests added in v0.12.0

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

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

func (Node) WithMetric added in v0.10.0

func (n Node) WithMetric(key string, metric Metric) Node

WithMetric returns a fresh copy of n, with metric merged in at key.

func (Node) WithMetrics added in v0.10.0

func (n Node) WithMetrics(metrics Metrics) Node

WithMetrics returns a fresh copy of n, with metrics merged in.

func (Node) WithParents added in v0.12.0

func (n Node) WithParents(parents Sets) Node

WithParents returns a fresh copy of n, with sets merged in.

func (Node) WithSet added in v0.10.0

func (n Node) WithSet(key string, set StringSet) Node

WithSet returns a fresh copy of n, with set merged in at key.

func (Node) WithSets added in v0.10.0

func (n Node) WithSets(sets Sets) Node

WithSets returns a fresh copy of n, with sets merged in.

func (Node) WithTopology added in v0.12.0

func (n Node) WithTopology(topology string) Node

WithTopology returns a fresh copy of n, with ID changed.

type NodeControls added in v0.10.0

type NodeControls struct {
	Timestamp time.Time
	Controls  StringSet
}

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) CodecDecodeSelf added in v0.13.0

func (nc *NodeControls) CodecDecodeSelf(decoder *codec.Decoder)

CodecDecodeSelf implements codec.Selfer

func (*NodeControls) CodecEncodeSelf added in v0.13.0

func (nc *NodeControls) CodecEncodeSelf(encoder *codec.Encoder)

CodecEncodeSelf implements codec.Selfer

func (NodeControls) Copy added in v0.10.0

func (nc NodeControls) Copy() NodeControls

Copy is a noop, as NodeControls is immutable

func (NodeControls) MarshalJSON added in v0.11.0

func (NodeControls) MarshalJSON() ([]byte, error)

MarshalJSON shouldn't be used, use CodecEncodeSelf instead

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.

func (*NodeControls) UnmarshalJSON added in v0.11.0

func (*NodeControls) UnmarshalJSON(b []byte) error

UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead

type NodeSet added in v0.12.0

type NodeSet struct {
	// contains filtered or unexported fields
}

NodeSet is a set of nodes keyed on ID. Clients must use the Add method to add nodes

func MakeNodeSet added in v0.12.0

func MakeNodeSet(nodes ...Node) NodeSet

MakeNodeSet makes a new NodeSet with the given nodes.

func (NodeSet) Add added in v0.12.0

func (n NodeSet) Add(nodes ...Node) NodeSet

Add adds the nodes to the NodeSet. Add is the only valid way to grow a NodeSet. Add returns the NodeSet to enable chaining.

func (*NodeSet) CodecDecodeSelf added in v0.13.0

func (n *NodeSet) CodecDecodeSelf(decoder *codec.Decoder)

CodecDecodeSelf implements codec.Selfer

func (*NodeSet) CodecEncodeSelf added in v0.13.0

func (n *NodeSet) CodecEncodeSelf(encoder *codec.Encoder)

CodecEncodeSelf implements codec.Selfer

func (NodeSet) Copy added in v0.12.0

func (n NodeSet) Copy() NodeSet

Copy is a noop

func (NodeSet) DeepEqual added in v0.12.0

func (n NodeSet) DeepEqual(i interface{}) bool

DeepEqual tests equality with other NodeSets

func (NodeSet) ForEach added in v0.12.0

func (n NodeSet) ForEach(f func(Node))

ForEach executes f for each node in the set. Nodes are traversed in sorted order.

func (*NodeSet) GobDecode added in v0.12.0

func (n *NodeSet) GobDecode(input []byte) error

GobDecode implements gob.Unmarshaller

func (NodeSet) GobEncode added in v0.12.0

func (n NodeSet) GobEncode() ([]byte, error)

GobEncode implements gob.Marshaller

func (NodeSet) Keys added in v0.12.0

func (n NodeSet) Keys() []string

Keys is a list of all the keys in this set.

func (NodeSet) Lookup added in v0.12.0

func (n NodeSet) Lookup(key string) (Node, bool)

Lookup the node 'key'

func (NodeSet) MarshalJSON added in v0.12.0

func (NodeSet) MarshalJSON() ([]byte, error)

MarshalJSON shouldn't be used, use CodecEncodeSelf instead

func (NodeSet) Merge added in v0.12.0

func (n NodeSet) Merge(other NodeSet) NodeSet

Merge combines the two NodeSets and returns a new result.

func (NodeSet) Size added in v0.12.0

func (n NodeSet) Size() int

Size is the number of nodes in the set

func (NodeSet) String added in v0.12.0

func (n NodeSet) String() string

func (*NodeSet) UnmarshalJSON added in v0.12.0

func (*NodeSet) UnmarshalJSON(b []byte) error

UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead

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.

func (Nodes) Prune added in v0.14.0

func (n Nodes) Prune() Nodes

Prune returns a copy of the Nodes with all information not strictly necessary for rendering nodes and edges in the UI cut away.

type Probe added in v0.14.0

type Probe struct {
	ID       string    `json:"id"`
	LastSeen time.Time `json:"lastSeen"`
}

Probe is the details for a single probe that generated a report.

func (Probe) Copy added in v0.14.0

func (p Probe) Copy() Probe

Copy produces a copy of the Probe

type Probes added in v0.14.0

type Probes map[string]Probe

Probes contains details of the probe(s) which generated a report.

func (Probes) Copy added in v0.14.0

func (ps Probes) Copy() Probes

Copy produces a copy of the Probes

func (Probes) Merge added in v0.14.0

func (ps Probes) Merge(other Probes) Probes

Merge two sets of Probes, keeping the records with the latest LastSeen

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

	// 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 propagated to the UI as quickly as possible,
	// bypassing the usual spy interval, publish interval and app ws interval.
	Shortcut bool

	Plugins xfer.PluginSpecs

	// ID a random identifier for this report, used when caching
	// rendered views of the report.  Reports with the same id
	// must be equal, but we don't require that equal reports have
	// the same id.
	ID string `deepequal:"skip"`

	// Probes is the details of the probes who reported this report
	Probes Probes
}

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) Topology added in v0.14.0

func (r Report) Topology(name string) (Topology, bool)

Topology gets a topology by name

func (Report) Validate added in v0.3.0

func (r Report) Validate() error

Validate checks the report for various inconsistencies.

type Sample added in v0.10.0

type Sample struct {
	Timestamp time.Time `json:"date"`
	Value     float64   `json:"value"`
}

Sample is a single datapoint of a metric.

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

type Sets struct {
	// contains filtered or unexported fields
}

Sets is a string->set-of-strings map. It is immutable.

func MakeSets added in v0.12.0

func MakeSets() Sets

MakeSets returns EmptySets

func (Sets) Add added in v0.12.0

func (s Sets) Add(key string, value StringSet) Sets

Add the given value to the Sets.

func (*Sets) CodecDecodeSelf added in v0.13.0

func (s *Sets) CodecDecodeSelf(decoder *codec.Decoder)

CodecDecodeSelf implements codec.Selfer

func (*Sets) CodecEncodeSelf added in v0.13.0

func (s *Sets) CodecEncodeSelf(encoder *codec.Encoder)

CodecEncodeSelf implements codec.Selfer

func (Sets) Copy added in v0.10.0

func (s Sets) Copy() Sets

Copy is a noop

func (Sets) DeepEqual added in v0.12.0

func (s Sets) DeepEqual(t Sets) bool

DeepEqual tests equality with other Sets

func (*Sets) GobDecode added in v0.12.0

func (s *Sets) GobDecode(input []byte) error

GobDecode implements gob.Unmarshaller

func (Sets) GobEncode added in v0.12.0

func (s Sets) GobEncode() ([]byte, error)

GobEncode implements gob.Marshaller

func (Sets) Keys added in v0.12.0

func (s Sets) Keys() []string

Keys returns the keys for this set

func (Sets) Lookup added in v0.12.0

func (s Sets) Lookup(key string) (StringSet, bool)

Lookup returns the sets stored under key.

func (Sets) MarshalJSON added in v0.12.0

func (Sets) MarshalJSON() ([]byte, error)

MarshalJSON shouldn't be used, use CodecEncodeSelf instead

func (Sets) Merge added in v0.10.0

func (s Sets) Merge(other Sets) Sets

Merge merges two sets maps into a fresh set, performing set-union merges as appropriate.

func (Sets) Size added in v0.12.0

func (s Sets) Size() int

Size returns the number of elements

func (Sets) String added in v0.12.0

func (s Sets) String() string

func (*Sets) UnmarshalJSON added in v0.12.0

func (*Sets) UnmarshalJSON(b []byte) error

UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead

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.

var EmptyStringSet StringSet

EmptyStringSet is an empty string set.

func MakeStringSet added in v0.10.0

func MakeStringSet(strs ...string) StringSet

MakeStringSet makes a new StringSet with the given strings.

func (StringSet) Add added in v0.10.0

func (s StringSet) Add(strs ...string) StringSet

Add adds the strings to the StringSet. Add is the only valid way to grow a StringSet. Add returns the StringSet to enable chaining.

func (StringSet) Contains added in v0.12.0

func (s StringSet) Contains(str string) bool

Contains returns true if the string set includes the given string

func (StringSet) Copy added in v0.10.0

func (s StringSet) Copy() StringSet

Copy returns a value copy of the StringSet.

func (StringSet) Intersection added in v0.14.0

func (s StringSet) Intersection(b StringSet) StringSet

Intersection returns the intersections of a and b

func (StringSet) Merge added in v0.10.0

func (s StringSet) Merge(other StringSet) StringSet

Merge combines the two StringSets and returns a new result.

func (StringSet) Remove added in v0.12.0

func (s StringSet) Remove(strs ...string) StringSet

Remove removes the strings from the StringSet. Remove is the only valid way to shrink a StringSet. Remove returns the StringSet to enable chaining.

type Topology

type Topology struct {
	Nodes             `json:"nodes"`
	Controls          `json:"controls,omitempty"`
	MetadataTemplates `json:"metadata_templates,omitempty"`
	MetricTemplates   `json:"metric_templates,omitempty"`
}

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, node 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.

func (Topology) WithMetadataTemplates added in v0.14.0

func (t Topology) WithMetadataTemplates(other MetadataTemplates) Topology

WithMetadataTemplates merges some metadata templates into this topology, returning a new topology.

func (Topology) WithMetricTemplates added in v0.14.0

func (t Topology) WithMetricTemplates(other MetricTemplates) Topology

WithMetricTemplates merges some metadata templates into this topology, returning a new topology.

type WireMetrics added in v0.10.0

type WireMetrics struct {
	Samples []Sample `json:"samples,omitempty"` // 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.

func (WireMetrics) FromIntermediate added in v0.13.0

func (m WireMetrics) FromIntermediate() Metric

FromIntermediate obtains the metric from a representation suitable for serialization.

type WireNodeControls added in v0.11.0

type WireNodeControls struct {
	Timestamp string    `json:"timestamp,omitempty"`
	Controls  StringSet `json:"controls,omitempty"`
}

WireNodeControls is the intermediate type for json encoding.

Jump to

Keyboard shortcuts

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