github.com/google/cadvisor@v0.49.1/info/v1/metric.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 v1
    16  
    17  import (
    18  	"time"
    19  )
    20  
    21  // Type of metric being exported.
    22  type MetricType string
    23  
    24  const (
    25  	// Instantaneous value. May increase or decrease.
    26  	MetricGauge MetricType = "gauge"
    27  
    28  	// A counter-like value that is only expected to increase.
    29  	MetricCumulative MetricType = "cumulative"
    30  )
    31  
    32  // DataType for metric being exported.
    33  type DataType string
    34  
    35  const (
    36  	IntType   DataType = "int"
    37  	FloatType DataType = "float"
    38  )
    39  
    40  // Spec for custom metric.
    41  type MetricSpec struct {
    42  	// The name of the metric.
    43  	Name string `json:"name"`
    44  
    45  	// Type of the metric.
    46  	Type MetricType `json:"type"`
    47  
    48  	// Data Type for the stats.
    49  	Format DataType `json:"format"`
    50  
    51  	// Display Units for the stats.
    52  	Units string `json:"units"`
    53  }
    54  
    55  // An exported metric.
    56  type MetricValBasic struct {
    57  	// Time at which the metric was queried
    58  	Timestamp time.Time `json:"timestamp"`
    59  
    60  	// The value of the metric at this point.
    61  	IntValue   int64   `json:"int_value,omitempty"`
    62  	FloatValue float64 `json:"float_value,omitempty"`
    63  }
    64  
    65  // An exported metric.
    66  type MetricVal struct {
    67  	// Label associated with a metric
    68  	Label  string            `json:"label,omitempty"`
    69  	Labels map[string]string `json:"labels,omitempty"`
    70  
    71  	// Time at which the metric was queried
    72  	Timestamp time.Time `json:"timestamp"`
    73  
    74  	// The value of the metric at this point.
    75  	IntValue   int64   `json:"int_value,omitempty"`
    76  	FloatValue float64 `json:"float_value,omitempty"`
    77  }