Documentation ¶
Index ¶
- Constants
- type AlarmConfiguration
- type AlarmEventDetail
- type AlarmMetric
- type AlarmMetricDetail
- type AlarmMetricStat
- type AlarmState
- type AlarmTags
- type Client
- type EventDetails
- func (d *EventDetails) AlarmARN() (string, error)
- func (d *EventDetails) AlarmConsoleLink() string
- func (d *EventDetails) GetMetricDataRequestForHrs(hrs ...int) (*cloudwatch.MetricDataResult, error)
- func (d *EventDetails) InjectTags() error
- func (d *EventDetails) MetricList() map[string][]string
- func (d *EventDetails) SetCWClient(c *Client)
Constants ¶
const ( //MetricNamesKey is the map[string]string key used for the metric names in MetricList() MetricNamesKey = "names" //MetricDimensionsKey is the map[string]string key used for the metric dimensions in MetricList() MetricDimensionsKey = "dimensions" //MetricNamespacesKey is the map[string]string key used for the metric namespaces in MetricList() MetricNamespacesKey = "namespaces" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlarmConfiguration ¶
type AlarmConfiguration struct {
Metrics []AlarmMetric `json:"metrics"`
}
AlarmConfiguration wraps cloudwatch alarm config from the event payload
type AlarmEventDetail ¶
type AlarmEventDetail struct { State AlarmState `json:"state"` PreviousState AlarmState `json:"previousState"` Configuration AlarmConfiguration `json:"configuration"` AlarmName string `json:"alarmName"` // Tags is not actually present in the event payload. We need to inject this ourselves Tags AlarmTags `json:"tags"` }
AlarmEventDetail wraps the cloudwatch alarm detail as sent via Eventbridge -> SQS -> Lambda
type AlarmMetric ¶
type AlarmMetric struct { ReturnData bool `json:"returnData"` ID string `json:"id"` MetricStat AlarmMetricStat `json:"metricStat"` }
AlarmMetric wraps the cloudwatch alarm metric config
type AlarmMetricDetail ¶
type AlarmMetricDetail struct { Namespace string `json:"namespace"` Name string `json:"name"` Dimensions map[string]string `json:"dimensions"` }
AlarmMetricDetail wraps the individual alarm metric
func (AlarmMetricDetail) AWSDimensions ¶
func (d AlarmMetricDetail) AWSDimensions() []*cloudwatch.Dimension
AWSDimensions returns our map[string]string dimensions in aws formatted cloudwatch.Dimension
type AlarmMetricStat ¶
type AlarmMetricStat struct { Stat string `json:"stat"` Period int64 `json:"period"` Metric AlarmMetricDetail `json:"metric"` }
AlarmMetricStat wraps the cloudwatch alarm metric stat config
type AlarmState ¶
type AlarmState struct { Value string `json:"value"` Timestamp string `json:"timestamp"` ReasonData string `json:"reasonData"` Reason string `json:"reason"` }
AlarmState contains the cloudwatch alarm state details
type Client ¶
type Client struct {
CWClient cloudwatchiface.CloudWatchAPI
}
Client provides methods to get information on a specific cloudwatch alarm.
type EventDetails ¶
type EventDetails struct { Account string `json:"account"` Version string `json:"version"` Time string `json:"time"` Source string `json:"source"` Resources []string `json:"resources"` Region string `json:"region"` ID string `json:"id"` DetailType string `json:"detail-type"` Detail AlarmEventDetail `json:"detail"` // contains filtered or unexported fields }
EventDetails contains the actual event details as received by SQS
func (*EventDetails) AlarmARN ¶
func (d *EventDetails) AlarmARN() (string, error)
AlarmARN returns the arn for the alarm that sent this event
func (*EventDetails) AlarmConsoleLink ¶
func (d *EventDetails) AlarmConsoleLink() string
AlarmConsoleLink provides a URL straight to the AWS console so users can view the alarm details
func (*EventDetails) GetMetricDataRequestForHrs ¶
func (d *EventDetails) GetMetricDataRequestForHrs(hrs ...int) (*cloudwatch.MetricDataResult, error)
GetMetricDataForHrs returns metric data for the given event over the last N hours (default is 1 hour)
func (*EventDetails) InjectTags ¶
func (d *EventDetails) InjectTags() error
InjectTags adds the AWS tags on the related cloudwatch alarm
func (*EventDetails) MetricList ¶
func (d *EventDetails) MetricList() map[string][]string
MetricList returns a map[string]string with all metric names & namespaces for this alarm (it will stick all namespaces, dimensions and names under the respective keys... if there are more than 1 of each)
func (*EventDetails) SetCWClient ¶
func (d *EventDetails) SetCWClient(c *Client)
SetCWClient sets the cloudwatch client to use for internal operations