Documentation
¶
Overview ¶
Package exportcloudwatch exports AWS CloudWatch metrics as prometheus metrics.
To use this package
- create one or more ExportConfigs
- call Validate() on each of them
- store the result of MetricsToRead
- call ReadMetrics
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MetricsToRead ¶
func MetricsToRead(ec []ExportConfig, cw *cloudwatch.CloudWatch) (map[string]MetricStat, error)
MetricsToRead returns a map of MetricStats that match the criteria expressed in the ExportConfigs.
func ReadMetrics ¶
func ReadMetrics(cw MetricDataGetter, start time.Time, period time.Duration, metricstats map[string]MetricStat) error
ReadMetrics pulls metrics for the passed time over the period of duration into the metricstats map.
Types ¶
type ExportConfig ¶
type ExportConfig struct {
// Namespace and Name map directly to metrics in AWS Cloudwatch
Namespace, Name string
// Dimensions are the names of dimensions to pull the data of, and Statistics
// are the Statistics to pull
Dimensions, Statistics []string
// Both of these filter the metrics based on the values of the dimension
DimensionsMatch, DimensionsNoMatch map[string]*regexp.Regexp
// StatDefault determines the default value for a stat if no value is read
StatDefault StatDefaultType
// NameDerivationVersion specifies the algorithm used to convert CloudWatch metric names
// to Prometheus metric names. 0 (the default) is the "legacy"/"classic" naming scheme;
// 1 is the new naming scheme, which should result in fewer overlaps in derived metric names
NameDerivationVersion uint
// contains filtered or unexported fields
}
ExportConfig describes which cloudwatch metrics we want to export. Make sure you call Validate.
func (*ExportConfig) String ¶
func (e *ExportConfig) String(i int) string
func (*ExportConfig) Validate ¶
func (e *ExportConfig) Validate() error
Validate returns an error if the configuration is incorrect and registers each metric with the default prometheus registry.
type MetricDataGetter ¶
type MetricDataGetter interface {
GetMetricData(*cloudwatch.GetMetricDataInput) (*cloudwatch.GetMetricDataOutput, error)
}
type MetricStat ¶
type MetricStat struct {
// contains filtered or unexported fields
}
MetricStat is a specific statistic for a *cloudwatch.Metric with a related, registered *prometheus.Gauge
type StatDefaultType ¶
type StatDefaultType int
StatDefaultType describes how to deal with a stat that has no value
const ( // Prior leaves the stat set to its prior value; this is the default Prior StatDefaultType = iota // Zero will set the stat to 0 Zero // NaN will set the stat to not-a-number NaN )