forked from amazon-archives/k8s-cloudwatch-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
externalmetric.go
135 lines (110 loc) · 4.57 KB
/
externalmetric.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package v1alpha1
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +genclient:noStatus
// +genclient:skipVerbs=patch
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ExternalMetric describes a ExternalMetric resource
type ExternalMetric struct {
// TypeMeta is the metadata for the resource, like kind and apiversion
meta_v1.TypeMeta `json:",inline"`
// ObjectMeta contains the metadata for the particular object (name, namespace, self link,
// labels, etc)
meta_v1.ObjectMeta `json:"metadata,omitempty"`
// Spec is the custom resource spec
Spec MetricSeriesSpec `json:"spec"`
}
// MetricSeriesSpec contains the specification for a metric series.
type MetricSeriesSpec struct {
// Name specifies the series name.
Name string `json:"name"`
// Queries specify the CloudWatch metrics query to retrieve data for this series.
Queries []MetricDataQuery `json:"queries"`
}
// MetricDataQuery represents the query structure used in GetMetricData operation to CloudWatch API.
type MetricDataQuery struct {
// Resources specifies how associated Kubernetes resources should be discovered for
// the given metrics.
Resources string `json:"resources"`
// The math expression to be performed on the returned data, if this structure
// is performing a math expression. For more information about metric math expressions,
// see Metric Math Syntax and Functions (http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/using-metric-math.html#metric-math-syntax)
// in the Amazon CloudWatch User Guide.
//
// Within one MetricDataQuery structure, you must specify either Expression
// or MetricStat but not both.
Expression string `json:"expression"`
// A short name used to tie this structure to the results in the response. This
// name must be unique within a single call to GetMetricData. If you are performing
// math expressions on this set of data, this name represents that data and
// can serve as a variable in the mathematical expression. The valid characters
// are letters, numbers, and underscore. The first character must be a lowercase
// letter.
//
// Id is a required field
ID string `json:"id"`
// A human-readable label for this metric or expression. This is especially
// useful if this is an expression, so that you know what the value represents.
// If the metric or expression is shown in a CloudWatch dashboard widget, the
// label is shown. If Label is omitted, CloudWatch generates a default.
Label string `json:"label"`
// The metric to be returned, along with statistics, period, and units. Use
// this parameter only if this structure is performing a data retrieval and
// not performing a math expression on the returned data.
//
// Within one MetricDataQuery structure, you must specify either Expression
// or MetricStat but not both.
MetricStat MetricStat `json:"metricStat"`
// Indicates whether to return the time stamps and raw data values of this metric.
// If you are performing this call just to do math expressions and do not also
// need the raw data returned, you can specify False. If you omit this, the
// default of True is used.
ReturnData bool `json:"returnData"`
}
// MetricStat defines the metric to be returned, along with the statistics, period, and units.
type MetricStat struct {
// The metric to return, including the metric name, namespace, and dimensions.
//
// Metric is a required field
Metric Metric `json:"metric"`
// The period to use when retrieving the metric.
//
// Period is a required field
Period int64 `json:"period"`
// The statistic to return. It can include any CloudWatch statistic or extended
// statistic.
//
// Stat is a required field
Stat string `json:"stat"`
// The unit to use for the returned data points.
Unit string `json:"unit"`
}
// Metric represents a specific metric.
type Metric struct {
// The dimensions for the metric.
Dimensions []Dimension `json:"dimensions"`
// The name of the metric.
MetricName string `json:"metricName"`
// The namespace of the metric.
Namespace string `json:"namespace"`
}
// Dimension expands the identity of a metric.
type Dimension struct {
// The name of the dimension.
//
// Name is a required field
Name string `json:"name"`
// The value representing the dimension measurement.
//
// Value is a required field
Value string `json:"value"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ExternalMetricList is a list of ExternalMetric resources
type ExternalMetricList struct {
meta_v1.TypeMeta `json:",inline"`
meta_v1.ListMeta `json:"metadata"`
Items []ExternalMetric `json:"items"`
}