cloudwatch

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

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
	Namespace          string
	MetricName         string
	ComparisonOperator string
	Threshold          float64
	EvaluationPeriods  int
	Period             int
	Statistic          string
	StateValue         string
	StateReason        string
	AlarmActions       []string
	Dimensions         []Dimension
	Tags               map[string]string
}

Alarm represents a CloudWatch metric alarm definition.

type CloudWatchService

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

CloudWatchService is the cloudmock implementation of the AWS CloudWatch Metrics API.

func New

func New(accountID, region string) *CloudWatchService

New returns a new CloudWatchService for the given AWS account ID and region.

func (*CloudWatchService) Actions

func (s *CloudWatchService) Actions() []service.Action

Actions returns the list of CloudWatch API actions supported by this service.

func (*CloudWatchService) GetAlarmActionsSummary

func (s *CloudWatchService) GetAlarmActionsSummary() (alarmNames, actionArns []string)

GetAlarmActionsSummary returns parallel slices of alarm names and action ARNs for topology.

func (*CloudWatchService) GetAllAlarms

func (s *CloudWatchService) GetAllAlarms() []*Alarm

GetAllAlarms returns all alarms for topology queries.

func (*CloudWatchService) HandleRequest

func (s *CloudWatchService) HandleRequest(ctx *service.RequestContext) (*service.Response, error)

HandleRequest routes an incoming CloudWatch request to the appropriate handler. CloudWatch uses form-encoded POST bodies; the Action is found in the form body. Newer AWS SDKs use Smithy RPC-v2 CBOR over the /service/.../operation/{name} path.

func (*CloudWatchService) HealthCheck

func (s *CloudWatchService) HealthCheck() error

HealthCheck always returns nil (no external dependencies).

func (*CloudWatchService) Name

func (s *CloudWatchService) Name() string

Name returns the AWS service name used for routing. CloudWatch Metrics uses "monitoring" in the credential scope.

func (*CloudWatchService) ResourceSchemas

func (s *CloudWatchService) ResourceSchemas() []schema.ResourceSchema

ResourceSchemas returns the schema for CloudWatch resource types.

func (*CloudWatchService) SetLocator

func (s *CloudWatchService) SetLocator(locator ServiceLocator)

SetLocator sets the service locator for cross-service delivery (alarm → SNS).

type Dimension

type Dimension struct {
	Name  string
	Value string
}

Dimension is a name/value pair that identifies a metric.

type MetricDatum

type MetricDatum struct {
	Namespace  string
	MetricName string
	Value      float64
	Unit       string
	Timestamp  time.Time
	Dimensions []Dimension
}

MetricDatum is a single data point stored for a metric.

type SNSPublisher

type SNSPublisher interface {
	PublishDirect(topicName, message, subject string) bool
}

SNSPublisher is an interface for directly publishing messages to SNS topics.

type ServiceLocator

type ServiceLocator interface {
	Lookup(name string) (service.Service, error)
}

ServiceLocator provides access to other services for cross-service communication.

type Store

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

Store holds all CloudWatch metric data points and alarms in memory.

func NewStore

func NewStore(accountID, region string) *Store

NewStore returns a new Store for the given account and region.

func (*Store) DeleteAlarms

func (s *Store) DeleteAlarms(names []string)

DeleteAlarms removes alarms by name. Silently ignores non-existent names.

func (*Store) DescribeAlarms

func (s *Store) DescribeAlarms(names []string) []*Alarm

DescribeAlarms returns alarms, optionally filtered by name.

func (*Store) DescribeAlarmsForMetric

func (s *Store) DescribeAlarmsForMetric(namespace, metricName string) []*Alarm

DescribeAlarmsForMetric returns alarms matching a namespace + metric name.

func (*Store) GetMetricData

func (s *Store) GetMetricData(namespace, metricName string, dims []Dimension, start, end time.Time) []*MetricDatum

GetMetricData returns data points matching a query within a time window.

func (*Store) ListMetrics

func (s *Store) ListMetrics(namespace, metricName string) []*MetricDatum

ListMetrics returns unique (Namespace, MetricName, Dimensions) combinations. If namespace or metricName filters are set, only matching metrics are returned.

func (*Store) ListTagsForResource

func (s *Store) ListTagsForResource(resourceArn string) (map[string]string, bool)

ListTagsForResource returns tags for an alarm identified by its ARN. The second return value is false if not found.

func (*Store) PutAlarm

func (s *Store) PutAlarm(a *Alarm) *Alarm

PutAlarm creates or replaces an alarm. Returns the alarm.

func (*Store) PutMetricData

func (s *Store) PutMetricData(namespace string, data []*MetricDatum)

PutMetricData stores one or more metric data points.

func (*Store) SetAlarmState

func (s *Store) SetAlarmState(name, stateValue, stateReason string) bool

SetAlarmState updates the StateValue and StateReason on an alarm. Returns false if the alarm does not exist.

func (*Store) TagResource

func (s *Store) TagResource(resourceArn string, tags map[string]string) bool

TagResource sets tags on an alarm identified by its ARN. Returns false if not found.

func (*Store) UntagResource

func (s *Store) UntagResource(resourceArn string, tagKeys []string) bool

UntagResource removes tag keys from an alarm. Returns false if alarm not found.

Jump to

Keyboard shortcuts

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