Help us shape the future of Go! Take the 2026 Go Developer Survey

cloudwatch

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cloudwatch emulates Amazon CloudWatch metrics, alarms and dashboards over every protocol its SDKs speak: RPCv2-CBOR (Go, Java), JSON 1.0 (Python, JS, CLI) and the legacy Query protocol. Metric alarms are evaluated in the background and fire their actions through the hub.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alarm

type Alarm struct {
	AlarmName                          string
	AlarmArn                           string
	AlarmDescription                   string `json:",omitempty"`
	AlarmConfigurationUpdatedTimestamp core.Time
	ActionsEnabled                     bool
	OKActions                          []string `json:",omitempty"`
	AlarmActions                       []string `json:",omitempty"`
	InsufficientDataActions            []string `json:",omitempty"`
	StateValue                         string
	StateReason                        string `json:",omitempty"`
	StateReasonData                    string `json:",omitempty"`
	StateUpdatedTimestamp              core.Time
	StateTransitionedTimestamp         core.Time
	MetricName                         string      `json:",omitempty"`
	Namespace                          string      `json:",omitempty"`
	Statistic                          string      `json:",omitempty"`
	ExtendedStatistic                  string      `json:",omitempty"`
	Dimensions                         []Dimension `json:",omitempty"`
	Period                             int         `json:",omitempty"`
	Unit                               string      `json:",omitempty"`
	EvaluationPeriods                  int         `json:",omitempty"`
	DatapointsToAlarm                  int         `json:",omitempty"`
	Threshold                          *float64    `json:",omitempty"`
	ComparisonOperator                 string      `json:",omitempty"`
	TreatMissingData                   string      `json:",omitempty"`
	EvaluateLowSampleCountPercentile   string      `json:",omitempty"`
	Metrics                            []query     `json:",omitempty"`
	ThresholdMetricId                  string      `json:",omitempty"`
	AlarmRule                          string      `json:",omitempty"`
}

Alarm is a metric or composite alarm in its MetricAlarm/CompositeAlarm wire shape; composite alarms set AlarmRule.

type Dashboard

type Dashboard struct {
	Name     string    `json:"name"`
	Account  string    `json:"account"`
	Body     string    `json:"body"`
	Modified time.Time `json:"modified"`
}

Dashboard is a stored dashboard.

type Dimension

type Dimension struct {
	Name  string
	Value string
}

Dimension is a metric dimension.

type HistoryItem

type HistoryItem struct {
	AlarmName       string
	AlarmType       string
	Timestamp       core.Time
	HistoryItemType string
	HistorySummary  string
	HistoryData     string
}

HistoryItem is one DescribeAlarmHistory entry.

type Metric

type Metric struct {
	Account    string      `json:"account"`
	Region     string      `json:"region"`
	Namespace  string      `json:"namespace"`
	Name       string      `json:"name"`
	Dimensions []Dimension `json:"dimensions,omitempty"`
	Points     []Point     `json:"points"`
}

Metric is one time series.

type Point

type Point struct {
	T      time.Time `json:"t"`
	N      float64   `json:"n"`
	Sum    float64   `json:"sum"`
	Min    float64   `json:"min"`
	Max    float64   `json:"max"`
	Values []float64 `json:"values,omitempty"` // samples of a Values/Counts datum, for percentiles
	Counts []float64 `json:"counts,omitempty"`
	Unit   string    `json:"unit,omitempty"`
}

Point is one datum: a value, values with counts, or a statistic set.

type Service

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

Service is the CloudWatch emulator.

func New

func New(hub *core.Hub) *Service

New creates the CloudWatch service and starts alarm evaluation.

func (*Service) Close

func (s *Service) Close() error

Close stops alarm evaluation; the hub may call it more than once.

func (*Service) Evaluate

func (s *Service) Evaluate(now time.Time)

Evaluate evaluates every metric alarm at now and runs the actions of the alarms that change state. The background loop calls it every 10 seconds.

func (*Service) Info

func (s *Service) Info() core.Info

func (*Service) Inspect

func (s *Service) Inspect(table, id string) any

Inspect returns an alarm (by name) or the metrics of a namespace with their recent points.

func (*Service) Load

func (s *Service) Load(b []byte) error

func (*Service) Reset

func (s *Service) Reset()

func (*Service) Resources

func (s *Service) Resources() []core.Table

Resources lists metrics and alarms.

func (*Service) Save

func (s *Service) Save() ([]byte, error)

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Service) TaggedResources

func (s *Service) TaggedResources(account, region string) map[string]map[string]string

TaggedResources lists alarms (ARN → tags) for the tagging API and Resource Explorer.

type Tag

type Tag struct {
	Key   string
	Value string
}

Tag is a CloudWatch resource tag.

Jump to

Keyboard shortcuts

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