Documentation ¶
Index ¶
- Constants
- func RegisterCollector(id string, c collectorFactory)
- type Collector
- type CollectorEvent
- type Container
- type ContainerImage
- type ContainerPort
- type ContainerRuntime
- type ContainerState
- type ECSLaunchType
- type ECSTask
- type Entity
- type EntityID
- type EntityMeta
- type Event
- type EventBundle
- type EventType
- type Filter
- type Kind
- type KubernetesPod
- type KubernetesPodOwner
- type OrchestratorContainer
- type Source
- type Store
- type WorkloadDumpResponse
- type WorkloadEntity
Constants ¶
const ( KindContainer Kind = "container" KindKubernetesPod Kind = "kubernetes_pod" KindECSTask Kind = "ecs_task" SourceDocker Source = "docker" SourceContainerd Source = "containerd" SourceECS Source = "ecs" SourceECSFargate Source = "ecs_fargate" SourceKubelet Source = "kubelet" SourceKubeMetadata Source = "kube_metadata" ContainerRuntimeDocker ContainerRuntime = "docker" ContainerRuntimeContainerd ContainerRuntime = "containerd" ECSLaunchTypeEC2 ECSLaunchType = "ec2" ECSLaunchTypeFargate ECSLaunchType = "fargate" EventTypeSet EventType = iota EventTypeUnset )
List of enumerable constants for the types above.
Variables ¶
This section is empty.
Functions ¶
func RegisterCollector ¶
func RegisterCollector(id string, c collectorFactory)
RegisterCollector registers a new collector, identified by an id for logging and telemetry purposes, to be used by the store.
Types ¶
type Collector ¶
type Collector interface { // Start starts a collector. The collector should run until the context // is done. It also gets a reference to the store that started it so it // can use Notify, or get access to other entities in the store. Start(context.Context, Store) error // Pull triggers an entity collection. To be used by collectors that // don't have streaming functionality, and called periodically by the // store. Pull(context.Context) error }
Collector is responsible for collecting metadata about workloads.
type CollectorEvent ¶
CollectorEvent is an event generated by a metadata collector, to be handled by the metadata store.
type Container ¶
type Container struct { EntityID EntityMeta EnvVars map[string]string Hostname string Image ContainerImage NetworkIPs map[string]string PID int Ports []ContainerPort Runtime ContainerRuntime State ContainerState }
Container is a containerized workload.
type ContainerImage ¶
ContainerImage is the an image used by a container.
func NewContainerImage ¶
func NewContainerImage(imageName string) (ContainerImage, error)
NewContainerImage builds a ContainerImage from an image name
func (ContainerImage) String ¶
func (c ContainerImage) String(verbose bool) string
String returns a string representation of ContainerImage.
type ContainerPort ¶
ContainerPort is a port open in the container.
func (ContainerPort) String ¶
func (c ContainerPort) String(verbose bool) string
String returns a string representation of ContainerPort.
type ContainerRuntime ¶
type ContainerRuntime string
ContainerRuntime is the container runtime used by a container.
type ContainerState ¶
ContainerState is the state of a container.
func (ContainerState) String ¶
func (c ContainerState) String(verbose bool) string
String returns a string representation of ContainerState.
type ECSTask ¶
type ECSTask struct { EntityID EntityMeta Tags map[string]string ContainerInstanceTags map[string]string ClusterName string Region string AvailabilityZone string Family string Version string LaunchType ECSLaunchType Containers []OrchestratorContainer }
ECSTask is an ECS Task.
type Entity ¶
type Entity interface { GetID() EntityID Merge(Entity) error DeepCopy() Entity String(verbose bool) string }
Entity is an item in the metadata store. It exists as an interface to avoid usage of interface{}.
type EntityID ¶
EntityID represents the ID of an Entity.
func (EntityID) GetID ¶
GetID satisfies the Entity interface for EntityID to allow a standalone EntityID to be passed in events of type EventTypeUnset without the need to build a full, concrete entity.
type EntityMeta ¶
type EntityMeta struct { Name string Namespace string Annotations map[string]string Labels map[string]string }
EntityMeta represents generic metadata about an Entity.
func (EntityMeta) String ¶
func (e EntityMeta) String(verbose bool) string
String returns a string representation of EntityMeta.
type EventBundle ¶
type EventBundle struct { Events []Event Ch chan struct{} }
EventBundle is a collection of events, and a channel that needs to be closed when the receiving subscriber wants to unblock the notifier.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter allows a subscriber to filter events by entity kind or event source.
func (*Filter) Match ¶
func (f *Filter) Match(ev CollectorEvent) bool
Match returns true if the filter matches an event.
func (*Filter) MatchKind ¶
MatchKind returns true if the filter matches the passed Kind. If the filter is nil, or has no kinds, it always matches.
func (*Filter) MatchSource ¶
MatchSource returns true if the filter matches the passed sources. If the filter is nil, or has no sources, it always matches.
type KubernetesPod ¶
type KubernetesPod struct { EntityID EntityMeta Owners []KubernetesPodOwner PersistentVolumeClaimNames []string Containers []OrchestratorContainer Ready bool Phase string IP string PriorityClass string KubeServices []string NamespaceLabels map[string]string }
KubernetesPod is a Kubernetes Pod.
func (KubernetesPod) DeepCopy ¶
func (p KubernetesPod) DeepCopy() Entity
DeepCopy returns a deep copy of the pod.
func (KubernetesPod) GetID ¶
func (p KubernetesPod) GetID() EntityID
GetID returns the KubernetesPod's EntityID.
func (*KubernetesPod) Merge ¶
func (p *KubernetesPod) Merge(e Entity) error
Merge merges a KubernetesPod with another. Returns an error if trying to merge with another kind.
func (KubernetesPod) String ¶
func (p KubernetesPod) String(verbose bool) string
String returns a string representation of KubernetesPod.
type KubernetesPodOwner ¶
KubernetesPodOwner is extracted from a pod's owner references.
func (KubernetesPodOwner) String ¶
func (o KubernetesPodOwner) String(verbose bool) string
String returns a string representation of KubernetesPodOwner.
type OrchestratorContainer ¶
type OrchestratorContainer struct { ID string Name string Image ContainerImage }
OrchestratorContainer is a reference to a Container with orchestrator-specific data attached to it.
func (OrchestratorContainer) String ¶
func (o OrchestratorContainer) String(_ bool) string
String returns a string representation of OrchestratorContainer.
type Store ¶
type Store interface { Start(ctx context.Context) Subscribe(name string, filter *Filter) chan EventBundle Unsubscribe(ch chan EventBundle) GetContainer(id string) (*Container, error) ListContainers() ([]*Container, error) GetKubernetesPod(id string) (*KubernetesPod, error) GetKubernetesPodForContainer(containerID string) (*KubernetesPod, error) GetECSTask(id string) (*ECSTask, error) Notify(events []CollectorEvent) Dump(verbose bool) WorkloadDumpResponse }
Store is a central storage of metadata about workloads. A workload is any unit of work being done by a piece of software, like a process, a container, a kubernetes pod, or a task in any cloud provider.
func GetGlobalStore ¶
func GetGlobalStore() Store
GetGlobalStore returns a global instance of the workloadmeta store, creating one if it doesn't exist. Start() needs to be called before any data collection happens.
type WorkloadDumpResponse ¶
type WorkloadDumpResponse struct {
Entities map[string]WorkloadEntity `json:"entities"`
}
WorkloadDumpResponse is used to dump the store content.
func (WorkloadDumpResponse) Write ¶
func (wdr WorkloadDumpResponse) Write(writer io.Writer)
Write writes the stores content in a given writer. Useful for agent's CLI and Flare.
type WorkloadEntity ¶
WorkloadEntity contains entity data.
Directories ¶
Path | Synopsis |
---|---|
Package collectors is a wrapper that loads the available workloadmeta collectors.
|
Package collectors is a wrapper that loads the available workloadmeta collectors. |