| 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 v1beta2 |
| 18 |
|
| 19 |
import ( |
| 20 |
"k8s.io/api/core/v1" |
| 21 |
"k8s.io/apimachinery/pkg/api/resource" |
| 22 |
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 23 |
) |
| 24 |
|
| 25 |
// MetricIdentifier identifies a metric by name and, optionally, selector |
| 26 |
type MetricIdentifier struct { |
| 27 |
// name is the name of the given metric |
| 28 |
Name string `json:"name" protobuf:"bytes,1,opt,name=name"` |
| 29 |
// selector represents the label selector that could be used to select |
| 30 |
// this metric, and will generally just be the selector passed in to |
| 31 |
// the query used to fetch this metric. |
| 32 |
// When left blank, only the metric's Name will be used to gather metrics. |
| 33 |
// +optional |
| 34 |
Selector *metav1.LabelSelector `json:"selector" protobuf:"bytes,2,opt,name=selector"` |
| 35 |
} |
| 36 |
|
| 37 |
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 38 |
|
| 39 |
// MetricValueList is a list of values for a given metric for some set of objects |
| 40 |
type MetricValueList struct { |
| 41 |
metav1.TypeMeta `json:",inline"` |
| 42 |
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 43 |
|
| 44 |
// the value of the metric across the described objects |
| 45 |
Items []MetricValue `json:"items" protobuf:"bytes,2,rep,name=items"` |
| 46 |
} |
| 47 |
|
| 48 |
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 49 |
|
| 50 |
// MetricValue is the metric value for some object |
| 51 |
type MetricValue struct { |
| 52 |
metav1.TypeMeta `json:",inline"` |
| 53 |
|
| 54 |
// a reference to the described object |
| 55 |
DescribedObject v1.ObjectReference `json:"describedObject" protobuf:"bytes,1,name=describedObject"` |
| 56 |
|
| 57 |
Metric MetricIdentifier `json:"metric" protobuf:"bytes,2,name=metric"` |
| 58 |
|
| 59 |
// indicates the time at which the metrics were produced |
| 60 |
Timestamp metav1.Time `json:"timestamp" protobuf:"bytes,3,name=timestamp"` |
| 61 |
|
| 62 |
// indicates the window ([Timestamp-Window, Timestamp]) from |
| 63 |
// which these metrics were calculated, when returning rate |
| 64 |
// metrics calculated from cumulative metrics (or zero for |
| 65 |
// non-calculated instantaneous metrics). |
| 66 |
WindowSeconds *int64 `json:"windowSeconds,omitempty" protobuf:"bytes,4,opt,name=windowSeconds"` |
| 67 |
|
| 68 |
// the value of the metric for this |
| 69 |
Value resource.Quantity `json:"value" protobuf:"bytes,5,name=value"` |
| 70 |
} |
| 71 |
|
| 72 |
// AllObjects is a wildcard used to select metrics |
| 73 |
// for all objects matching the given label selector |
| 74 |
const AllObjects = "*" |
| 75 |
|
| 76 |
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 77 |
|
| 78 |
// MetricListOptions is used to select metrics by their label selectors |
| 79 |
type MetricListOptions struct { |
| 80 |
metav1.TypeMeta `json:",inline"` |
| 81 |
|
| 82 |
// A selector to restrict the list of returned objects by their labels. |
| 83 |
// Defaults to everything. |
| 84 |
// +optional |
| 85 |
LabelSelector string `json:"labelSelector,omitempty" protobuf:"bytes,1,opt,name=labelSelector"` |
| 86 |
|
| 87 |
// A selector to restrict the list of returned metrics by their labels |
| 88 |
// +optional |
| 89 |
MetricLabelSelector string `json:"metricLabelSelector,omitempty" protobuf:"bytes,2,opt,name=metricLabelSelector"` |
| 90 |
} |