Documentation
¶
Overview ¶
Package cloud collects from public clouds: an AWS CloudWatch GetMetricData poller, the AWS Resource Groups Tagging API as inventory, and an Azure Event Hubs consumer (Kafka endpoint).
Credentials never travel through remote config. AWS uses the SDK's standard chain (environment, shared credentials file, instance role); Azure's connection string is in the local file or an environment variable. Neither is logged, exported or put into a label or an error.
shortcut: GCP and Azure API pollers are known gap G-21; GCP arrives by Pub/Sub push, Azure by Event Hubs.
Index ¶
- Variables
- func EmitEntities(out sink.Sink, es []Entity, at time.Time)
- func EmitInventory(out sink.Sink, rs []Tagged, at time.Time)
- func MergeCredential(cfg, sec map[string]any)
- func ParseARN(arn string) (service, region, account string, ok bool)
- func Process(out sink.Sink, msg []byte, now time.Time)
- func ProcessWith(out sink.Sink, ship func(map[string]string, []*tracepb.Span), msg []byte, ...)
- func ResourceID(arn string) string
- func RunAWS(ctx context.Context, raw json.RawMessage, out sink.Sink) error
- func RunDBDiscovery(ctx context.Context, raw json.RawMessage, out sink.Sink) error
- func RunEventHub(ctx context.Context, raw json.RawMessage, out sink.Sink) error
- func RunPulls(ctx context.Context, raw json.RawMessage, out sink.Sink) error
- func RunPullsIn(ctx context.Context, raw json.RawMessage, stateDir string, out sink.Sink) error
- func RunStepFunctions(ctx context.Context, raw json.RawMessage, out sink.Sink, ...) error
- type AWSConfig
- type DBConfig
- type DBDiscovery
- type Entity
- type EventHubConfig
- type LivePoint
- type LiveQuery
- type LiveSeries
- type PullSpec
- type SFNConfig
- type Tagged
Constants ¶
This section is empty.
Variables ¶
var EndpointKeys = []string{"endpoint", "login_endpoint"}
EndpointKeys are the config keys that say where a credential is sent.
var ErrBadLiveQuery = errors.New("bad query")
ErrBadLiveQuery marks a request the caller can fix, as opposed to a provider failure.
Functions ¶
func EmitEntities ¶
EmitEntities writes one `cloud.resource.info` gauge per entity.
func EmitInventory ¶
EmitInventory writes one `cloud.resource.info` gauge (value 1) per resource, carrying the entity resource the worker turns into an infra_entities row (kind cloud, keyed by cloud.resource_id). The agent host's own host.* is blanked: a cloud resource does not run on it. Tags become cloud.tag.<key> properties; keys are prefixed, so no tag can name a resource attribute.
func MergeCredential ¶
MergeCredential adds an opened credential to a tenant row's config. An endpoint counts only from inside the credential, where the API seals it: it can only change along with the credential, so editing a row cannot send a stored credential to another host.
func ParseARN ¶
ParseARN splits arn:partition:service:region:account:resource (resource keeps its colons).
func Process ¶
Process turns one Event Hubs message ({"records": [...]} of diagnostic logs or metrics) into samples and log records. Each Azure resource id becomes a cloud entity through the resource.
func ProcessWith ¶
func ProcessWith(out sink.Sink, ship func(map[string]string, []*tracepb.Span), msg []byte, now time.Time)
ProcessWith is Process; with ship set, Application Insights request and dependency rows are shipped as spans instead of logs.
func ResourceID ¶
ResourceID is the part of an ARN a CloudWatch dimension carries: what follows the last ':' or '/' of the resource part (function:orders -> orders, instance/i-0abc -> i-0abc).
func RunDBDiscovery ¶
RunDBDiscovery refreshes every 10 minutes until ctx ends.
func RunEventHub ¶
RunEventHub consumes until ctx ends.
func RunPulls ¶
RunPulls starts every configured pull and blocks until ctx ends. A bad entry is reported and skipped so one typo does not stop the others.
func RunPullsIn ¶
RunPullsIn is RunPulls for a BYOC agent: when out keeps no positions itself, App Insights positions are kept in stateDir (empty: in memory only).
Types ¶
type AWSConfig ¶
type AWSConfig struct {
Enabled *bool `json:"enabled"`
Interval string `json:"interval"` // poll interval, default = period_s, floor 60s
Region string `json:"region"`
Profile string `json:"profile"` // shared-config profile; empty = default chain
Endpoint string `json:"endpoint"` // override (VPC endpoint, test double)
// Namespaces to poll, e.g. ["AWS/Lambda", "AWS/EC2"], or ["auto"] for every AWS/* namespace with
// recent metrics. Empty = no metric polling.
Namespaces []string `json:"namespaces"`
// Presets add named namespace sets: "data_streams" = AWS/Kinesis, AWS/SQS and AWS/SNS (queue
// depth and age, iterator age, throughput and failures, for the data streams view).
Presets []string `json:"presets"`
MaxMetrics int `json:"max_metrics"` // per namespace, default 100
// Stats to request per metric (default ["Average"]). Each stat doubles the metrics billed.
Stats []string `json:"stats"`
// PeriodS is the GetMetricData period: 300 (default, standard resolution) or 60.
PeriodS int `json:"period_s"`
// Inventory turns on the Resource Groups Tagging API walk (entities of kind cloud).
Inventory *bool `json:"inventory"`
InventoryInterval string `json:"inventory_interval"` // default 5m, floor 1m
// TagFilters polls only metrics of resources carrying every listed tag (key -> allowed values;
// an empty list means the key must exist). CloudWatch metrics have no tags, so the tagged
// resource ids come from the Resource Groups Tagging API and are matched against dimension values.
TagFilters map[string][]string `json:"tag_filters"`
// RoleARN is assumed on top of the default chain (cross-account access); ExternalID guards it.
RoleARN string `json:"role_arn"`
ExternalID string `json:"external_id"`
}
AWSConfig is the module's local configuration.
type DBConfig ¶
type DBConfig struct {
AWS *rdsConfig `json:"aws"`
Azure *azureDBConfig `json:"azure"`
GCP *cloudSQLConfig `json:"gcp"`
Interval string `json:"interval"` // default 10m, floor 1m
}
DBConfig lists the providers to discover. Credentials live in the sealed local agent config.
type DBDiscovery ¶
type DBDiscovery struct {
// contains filtered or unexported fields
}
DBDiscovery remembers the last good answer per provider: a failed refresh keeps it.
func NewDBDiscovery ¶
func NewDBDiscovery(cfg DBConfig) *DBDiscovery
NewDBDiscovery returns a discoverer for cfg.
type EventHubConfig ¶
type EventHubConfig struct {
Enabled *bool `json:"enabled"`
// ConnectionString or ConnectionStringEnv holds the namespace connection string. It is a
// secret: it is never logged, exported or placed in an error.
ConnectionString string `json:"connection_string"`
ConnectionStringEnv string `json:"connection_string_env"`
Brokers []string `json:"brokers"` // default <namespace>.servicebus.windows.net:9093
Topics []string `json:"topics"` // event hub names
Group string `json:"group"` // consumer group, default wt-agent
// Plaintext disables TLS and SASL; for a local Kafka stand-in only.
Plaintext bool `json:"plaintext"`
// StartAtEarliest makes a group with no committed offset read from the start of retention
// instead of from now. Off by default: days of history would flood the export buffer.
StartAtEarliest bool `json:"start_at_earliest"`
}
EventHubConfig reads Azure diagnostic logs and metrics from an Event Hubs namespace through its Kafka-compatible endpoint (port 9093, SASL PLAIN, user "$ConnectionString").
type LiveQuery ¶
type LiveQuery struct {
Metrics []string `json:"metrics"` // azure, gcp
Resources []string `json:"resources"` // azure
ZoneIDs []string `json:"zone_ids"` // cloudflare
Namespaces []string `json:"namespaces"` // aws
Metric string `json:"metric"` // aws: one metric name
Stat string `json:"stat"` // aws: Average (default), Sum, Minimum, Maximum, SampleCount
}
LiveQuery narrows a row. An empty list means the row's whole list.
type LiveSeries ¶
type LiveSeries struct {
Name string `json:"name"`
Attrs map[string]string `json:"attrs"`
Points []LivePoint `json:"points"`
}
LiveSeries is one provider time series.
type PullSpec ¶
type PullSpec struct {
Provider string `json:"provider"` // aws, gcp, azure, cloudflare
IntervalS int `json:"interval_s"`
Config json.RawMessage `json:"config"`
// PublicOnly marks a tenant's row: every call goes through tenantClient. An agent's own config
// may reach private endpoints, a tenant's may not.
PublicOnly bool `json:"public_only,omitempty"`
}
PullSpec is one entry of the module's "pulls" list.
type SFNConfig ¶
type SFNConfig struct {
Enabled *bool `json:"enabled"`
Interval string `json:"interval"` // default 60s, at least 30s
Region string `json:"region"`
StateMachines []string `json:"state_machines"` // ARNs; empty: every STANDARD machine
MaxExecutions int `json:"max_executions"` // per machine and round, default 50
}
SFNConfig is the aws_stepfunctions module's config (agent file only).
Source Files
¶
- appinsights.go
- appinsights_pull.go
- azure_graph.go
- azuredb.go
- azuremonitor.go
- bigquery.go
- cloudflare.go
- cloudsql.go
- cloudwatch.go
- cloudwatch_discover.go
- cloudwatch_tags.go
- cursor_file.go
- eventhub.go
- gcp_assets.go
- gcp_cloudrun.go
- gcpmonitoring.go
- live.go
- pull.go
- rds.go
- stepfunctions.go
- stepfunctions_spans.go
- tagging.go
- vercel.go