| 1 |
/* |
| 2 |
Copyright 2018 The Kubernetes Authors. |
| 3 |
|
| 4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
you may not use this file except in compliance with the License. |
| 6 |
You may obtain a copy of the License at |
| 7 |
|
| 8 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| 10 |
Unless required by applicable law or agreed to in writing, software |
| 11 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
See the License for the specific language governing permissions and |
| 14 |
limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package external_metrics |
| 18 |
|
| 19 |
import ( |
| 20 |
"k8s.io/apimachinery/pkg/api/resource" |
| 21 |
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 22 |
) |
| 23 |
|
| 24 |
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 25 |
|
| 26 |
// a list of values for a given metric for some set labels |
| 27 |
type ExternalMetricValueList struct { |
| 28 |
metav1.TypeMeta `json:",inline"` |
| 29 |
metav1.ListMeta `json:"metadata,omitempty"` |
| 30 |
|
| 31 |
// value of the metric matching a given set of labels |
| 32 |
Items []ExternalMetricValue `json:"items"` |
| 33 |
} |
| 34 |
|
| 35 |
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 36 |
|
| 37 |
// a metric value for external metric |
| 38 |
// A single metric value is identified by metric name and a set of string labels. |
| 39 |
// For one metric there can be multiple values with different sets of labels. |
| 40 |
type ExternalMetricValue struct { |
| 41 |
metav1.TypeMeta `json:",inline"` |
| 42 |
|
| 43 |
// the name of the metric |
| 44 |
MetricName string `json:"metricName"` |
| 45 |
|
| 46 |
// a set of labels that identify a single time series for the metric |
| 47 |
MetricLabels map[string]string `json:"metricLabels"` |
| 48 |
|
| 49 |
// indicates the time at which the metrics were produced |
| 50 |
Timestamp metav1.Time `json:"timestamp"` |
| 51 |
|
| 52 |
// indicates the window ([Timestamp-Window, Timestamp]) from |
| 53 |
// which these metrics were calculated, when returning rate |
| 54 |
// metrics calculated from cumulative metrics (or zero for |
| 55 |
// non-calculated instantaneous metrics). |
| 56 |
WindowSeconds *int64 `json:"window,omitempty"` |
| 57 |
|
| 58 |
// the value of the metric |
| 59 |
Value resource.Quantity `json:"value"` |
| 60 |
} |