Documentation
¶
Overview ¶
Package cloudwatch provides a basic emulation of Amazon CloudWatch (metrics + alarms).
Implemented operations: PutMetricAlarm, DescribeAlarms, DeleteAlarms, PutMetricData, GetMetricStatistics, GetMetricData, ListMetrics, ListTagsForResource, TagResource, UntagResource.
Enough for CDK stacks that reference AWS::CloudWatch::Alarm resources.
Index ¶
- type AlarmHistoryItem
- type Dimension
- type Metric
- type MetricAlarm
- type MetricDataPoint
- type Service
- func (s *Service) Dispatch(w http.ResponseWriter, r *http.Request)
- func (s *Service) DispatchQuery(w http.ResponseWriter, r *http.Request)
- func (s *Service) InitAlarmActions(d *alarmaction.Dispatcher)
- func (s *Service) Name() string
- func (s *Service) OwnsVersion(version string) bool
- func (s *Service) RegisterRoutes(_ chi.Router)
- func (s *Service) Stop(ctx context.Context)
- func (s *Service) TargetPrefix() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlarmHistoryItem ¶
type AlarmHistoryItem struct {
AlarmName string `json:"AlarmName"`
AlarmType string `json:"AlarmType"`
Timestamp time.Time `json:"Timestamp"`
HistoryItemType string `json:"HistoryItemType"`
HistorySummary string `json:"HistorySummary"`
HistoryData string `json:"HistoryData"`
}
AlarmHistoryItem is one row of DescribeAlarmHistory.
type Metric ¶
type Metric struct {
Namespace string `json:"Namespace"`
MetricName string `json:"MetricName"`
Dimensions []Dimension `json:"Dimensions,omitempty"`
}
Metric represents a CloudWatch metric entry.
type MetricAlarm ¶
type MetricAlarm struct {
AlarmName string `json:"AlarmName"`
AlarmArn string `json:"AlarmArn"`
MetricName string `json:"MetricName,omitempty"`
Namespace string `json:"Namespace,omitempty"`
Statistic string `json:"Statistic,omitempty"`
ExtendedStatistic string `json:"ExtendedStatistic,omitempty"`
Dimensions []Dimension `json:"Dimensions,omitempty"`
Unit string `json:"Unit,omitempty"`
Period int `json:"Period,omitempty"`
EvaluationPeriods int `json:"EvaluationPeriods,omitempty"`
DatapointsToAlarm int `json:"DatapointsToAlarm,omitempty"`
Threshold float64 `json:"Threshold,omitempty"`
ComparisonOperator string `json:"ComparisonOperator,omitempty"`
ActionsEnabled bool `json:"ActionsEnabled"`
AlarmActions []string `json:"AlarmActions,omitempty"`
OKActions []string `json:"OKActions,omitempty"`
InsufficientDataActions []string `json:"InsufficientDataActions,omitempty"`
StateValue string `json:"StateValue"`
StateReason string `json:"StateReason"`
StateReasonData string `json:"StateReasonData,omitempty"`
AlarmDescription string `json:"AlarmDescription,omitempty"`
TreatMissingData string `json:"TreatMissingData,omitempty"`
StateUpdatedTimestamp string `json:"StateUpdatedTimestamp,omitempty"`
StateTransitionedTimestamp string `json:"StateTransitionedTimestamp,omitempty"`
AlarmConfigurationUpdatedTimestamp string `json:"AlarmConfigurationUpdatedTimestamp,omitempty"`
// ManualStateHoldUntil is when a SetAlarmState override stops being
// protected from the evaluator. Internal — see setAlarmStateHold.
ManualStateHoldUntil string `json:"ManualStateHoldUntil,omitempty"`
}
MetricAlarm represents a CloudWatch alarm.
This is the persisted shape, not a wire shape — the Query and JSON responses are rendered from it separately. ManualStateHoldUntil in particular is Overcast's own bookkeeping and is never emitted.
type MetricDataPoint ¶
type MetricDataPoint struct {
Namespace string `json:"Namespace"`
MetricName string `json:"MetricName"`
Dimensions []Dimension `json:"Dimensions,omitempty"`
Timestamp time.Time `json:"Timestamp"`
Unit string `json:"Unit,omitempty"`
SampleCount float64 `json:"SampleCount"`
Sum float64 `json:"Sum"`
Minimum float64 `json:"Minimum"`
Maximum float64 `json:"Maximum"`
}
MetricDataPoint stores a single published datapoint.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements router.Service and router.QueryDispatcher for CloudWatch.
func New ¶
New returns a configured CloudWatch Service.
It performs no store I/O: the alarm evaluator and the metric-data sweeper only register their tickers here, and neither touches the store until its first tick (AGENTS.md § startup budget).
func (*Service) Dispatch ¶
func (s *Service) Dispatch(w http.ResponseWriter, r *http.Request)
Dispatch satisfies router.TargetDispatcher.
Like every other JSON-tier service, the operation name comes from codec.FromContext — populated by middleware.Protocol identifying the X-Amz-Target header before Dispatch ever runs. Dispatch no longer parses X-Amz-Target itself; the header-trimming fallback below only covers callers that invoke Dispatch without going through the router's middleware chain (e.g. a unit test constructing a bare request).
func (*Service) DispatchQuery ¶
func (s *Service) DispatchQuery(w http.ResponseWriter, r *http.Request)
DispatchQuery satisfies router.QueryDispatcher.
func (*Service) InitAlarmActions ¶
func (s *Service) InitAlarmActions(d *alarmaction.Dispatcher)
InitAlarmActions wires the dispatcher that delivers alarm state transitions to their action ARNs. Called once from router.New; a Service without it still evaluates alarms, it just has nowhere to send the transitions.
func (*Service) OwnsVersion ¶
OwnsVersion satisfies router.QueryVersionOwner.
func (*Service) RegisterRoutes ¶
func (*Service) TargetPrefix ¶
TargetPrefix satisfies router.TargetDispatcher for AWS SDK JSON protocol.