updating cadvisor deps
Signed-off-by: Vishnu kannan <vishnuk@google.com>
This commit is contained in:
42
vendor/github.com/google/cadvisor/collector/config.go
generated
vendored
42
vendor/github.com/google/cadvisor/collector/config.go
generated
vendored
@@ -17,12 +17,13 @@ package collector
|
||||
import (
|
||||
"time"
|
||||
|
||||
"encoding/json"
|
||||
"github.com/google/cadvisor/info/v1"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
//the endpoint to hit to scrape metrics
|
||||
Endpoint string `json:"endpoint"`
|
||||
Endpoint EndpointConfig `json:"endpoint"`
|
||||
|
||||
//holds information about different metrics that can be collected
|
||||
MetricsConfig []MetricConfig `json:"metrics_config"`
|
||||
@@ -52,7 +53,7 @@ type MetricConfig struct {
|
||||
|
||||
type Prometheus struct {
|
||||
//the endpoint to hit to scrape metrics
|
||||
Endpoint string `json:"endpoint"`
|
||||
Endpoint EndpointConfig `json:"endpoint"`
|
||||
|
||||
//the frequency at which metrics should be collected
|
||||
PollingFrequency time.Duration `json:"polling_frequency"`
|
||||
@@ -60,3 +61,40 @@ type Prometheus struct {
|
||||
//holds names of different metrics that can be collected
|
||||
MetricsConfig []string `json:"metrics_config"`
|
||||
}
|
||||
|
||||
type EndpointConfig struct {
|
||||
// The full URL of the endpoint to reach
|
||||
URL string
|
||||
// A configuration in which an actual URL is constructed from, using the container's ip address
|
||||
URLConfig URLConfig
|
||||
}
|
||||
|
||||
type URLConfig struct {
|
||||
// the protocol to use for connecting to the endpoint. Eg 'http' or 'https'
|
||||
Protocol string `json:"protocol"`
|
||||
|
||||
// the port to use for connecting to the endpoint. Eg '8778'
|
||||
Port json.Number `json:"port"`
|
||||
|
||||
// the path to use for the endpoint. Eg '/metrics'
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
func (ec *EndpointConfig) UnmarshalJSON(b []byte) error {
|
||||
url := ""
|
||||
config := URLConfig{
|
||||
Protocol: "http",
|
||||
Port: "8000",
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(b, &url); err == nil {
|
||||
ec.URL = url
|
||||
return nil
|
||||
}
|
||||
err := json.Unmarshal(b, &config)
|
||||
if err == nil {
|
||||
ec.URLConfig = config
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
7
vendor/github.com/google/cadvisor/collector/generic_collector.go
generated
vendored
7
vendor/github.com/google/cadvisor/collector/generic_collector.go
generated
vendored
@@ -24,6 +24,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/cadvisor/container"
|
||||
"github.com/google/cadvisor/info/v1"
|
||||
)
|
||||
|
||||
@@ -51,13 +52,15 @@ type collectorInfo struct {
|
||||
}
|
||||
|
||||
//Returns a new collector using the information extracted from the configfile
|
||||
func NewCollector(collectorName string, configFile []byte, metricCountLimit int) (*GenericCollector, error) {
|
||||
func NewCollector(collectorName string, configFile []byte, metricCountLimit int, containerHandler container.ContainerHandler) (*GenericCollector, error) {
|
||||
var configInJSON Config
|
||||
err := json.Unmarshal(configFile, &configInJSON)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
configInJSON.Endpoint.configure(containerHandler)
|
||||
|
||||
//TODO : Add checks for validity of config file (eg : Accurate JSON fields)
|
||||
|
||||
if len(configInJSON.MetricsConfig) == 0 {
|
||||
@@ -130,7 +133,7 @@ func (collector *GenericCollector) Collect(metrics map[string][]v1.MetricVal) (t
|
||||
currentTime := time.Now()
|
||||
nextCollectionTime := currentTime.Add(time.Duration(collector.info.minPollingFrequency))
|
||||
|
||||
uri := collector.configFile.Endpoint
|
||||
uri := collector.configFile.Endpoint.URL
|
||||
response, err := http.Get(uri)
|
||||
if err != nil {
|
||||
return nextCollectionTime, nil, err
|
||||
|
9
vendor/github.com/google/cadvisor/collector/prometheus_collector.go
generated
vendored
9
vendor/github.com/google/cadvisor/collector/prometheus_collector.go
generated
vendored
@@ -24,6 +24,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/cadvisor/container"
|
||||
"github.com/google/cadvisor/info/v1"
|
||||
)
|
||||
|
||||
@@ -46,13 +47,15 @@ type PrometheusCollector struct {
|
||||
}
|
||||
|
||||
//Returns a new collector using the information extracted from the configfile
|
||||
func NewPrometheusCollector(collectorName string, configFile []byte, metricCountLimit int) (*PrometheusCollector, error) {
|
||||
func NewPrometheusCollector(collectorName string, configFile []byte, metricCountLimit int, containerHandler container.ContainerHandler) (*PrometheusCollector, error) {
|
||||
var configInJSON Prometheus
|
||||
err := json.Unmarshal(configFile, &configInJSON)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
configInJSON.Endpoint.configure(containerHandler)
|
||||
|
||||
minPollingFrequency := configInJSON.PollingFrequency
|
||||
|
||||
// Minimum supported frequency is 1s
|
||||
@@ -108,7 +111,7 @@ func getMetricData(line string) string {
|
||||
|
||||
func (collector *PrometheusCollector) GetSpec() []v1.MetricSpec {
|
||||
specs := []v1.MetricSpec{}
|
||||
response, err := http.Get(collector.configFile.Endpoint)
|
||||
response, err := http.Get(collector.configFile.Endpoint.URL)
|
||||
if err != nil {
|
||||
return specs
|
||||
}
|
||||
@@ -153,7 +156,7 @@ func (collector *PrometheusCollector) Collect(metrics map[string][]v1.MetricVal)
|
||||
currentTime := time.Now()
|
||||
nextCollectionTime := currentTime.Add(time.Duration(collector.pollingFrequency))
|
||||
|
||||
uri := collector.configFile.Endpoint
|
||||
uri := collector.configFile.Endpoint.URL
|
||||
response, err := http.Get(uri)
|
||||
if err != nil {
|
||||
return nextCollectionTime, nil, err
|
||||
|
26
vendor/github.com/google/cadvisor/collector/util.go
generated
vendored
Normal file
26
vendor/github.com/google/cadvisor/collector/util.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package collector
|
||||
|
||||
import "github.com/google/cadvisor/container"
|
||||
|
||||
func (endpointConfig *EndpointConfig) configure(containerHandler container.ContainerHandler) {
|
||||
//If the exact URL was not specified, generate it based on the ip address of the container.
|
||||
endpoint := endpointConfig
|
||||
if endpoint.URL == "" {
|
||||
ipAddress := containerHandler.GetContainerIPAddress()
|
||||
endpointConfig.URL = endpoint.URLConfig.Protocol + "://" + ipAddress + ":" + endpoint.URLConfig.Port.String() + endpoint.URLConfig.Path
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user