github.com/timstclair/heapster@v0.20.0-alpha1/metrics/api/v1/types/types.go (about) 1 // Copyright 2015 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package types 16 17 import ( 18 "time" 19 ) 20 21 // Timeseries represents a set of metrics for the same target object 22 // (typically a container). 23 type Timeseries struct { 24 // Map of metric names to their values. 25 Metrics map[string][]Point `json:"metrics"` 26 27 // Common labels for all metrics. 28 Labels map[string]string `json:"labels,omitempty"` 29 } 30 31 // Point represent a metric value. 32 type Point struct { 33 // The start and end time for which this data is representative. 34 Start time.Time `json:"start"` 35 End time.Time `json:"end"` 36 37 // Labels specific to this data point. 38 Labels map[string]string `json:"labels,omitempty"` 39 40 // The value of the metric. 41 Value interface{} `json:"value"` 42 } 43 44 // TimeseriesSchema represents all the metrics and labels. 45 type TimeseriesSchema struct { 46 // All the metrics handled by heapster. 47 Metrics []MetricDescriptor `json:"metrics,omitempty"` 48 // Labels that are common to all metrics. 49 CommonLabels []LabelDescriptor `json:"common_labels,omitempty"` 50 // Labels that are present only for containers in pods. 51 // A container metric belongs to a pod is "pod_name" label is set. 52 PodLabels []LabelDescriptor `json:"pod_labels,omitempty"` 53 } 54 55 // To maintain stable api for GKE. 56 57 type MetricDescriptor struct { 58 // The unique name of the metric. 59 Name string `json:"name,omitempty"` 60 61 // Description of the metric. 62 Description string `json:"description,omitempty"` 63 64 // Descriptor of the labels specific to this metric. 65 Labels []LabelDescriptor `json:"labels,omitempty"` 66 67 // Type and value of metric data. 68 Type string `json:"type,omitempty"` 69 70 // The type of value returned as part of this metric. 71 ValueType string `json:"value_type,omitempty"` 72 73 // The units of the value returned as part of this metric. 74 Units string `json:"units,omitempty"` 75 } 76 77 type LabelDescriptor struct { 78 // Key to use for the label. 79 Key string `json:"key,omitempty"` 80 81 // Description of the label. 82 Description string `json:"description,omitempty"` 83 }