Skip to content

Commit

Permalink
Merge pull request #89413 from zhouya0/remove_prometheus_references_f…
Browse files Browse the repository at this point in the history
…rom_etcd_version_monitor

Remove prometheus references from etcd version monitor
  • Loading branch information
k8s-ci-robot committed Mar 27, 2020
2 parents c1fc466 + 04d06d2 commit 3842a92
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cluster/images/etcd-version-monitor/BUILD
Expand Up @@ -17,9 +17,9 @@ go_library(
importpath = "k8s.io/kubernetes/cluster/images/etcd-version-monitor",
deps = [
"//staging/src/k8s.io/component-base/metrics:go_default_library",
"//staging/src/k8s.io/component-base/metrics/testutil:go_default_library",
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
"//vendor/github.com/prometheus/client_model/go:go_default_library",
"//vendor/github.com/prometheus/common/expfmt:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
Expand Down
6 changes: 2 additions & 4 deletions cluster/images/etcd-version-monitor/etcd-version-monitor.go
Expand Up @@ -27,10 +27,10 @@ import (

"github.com/gogo/protobuf/proto"
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"
"github.com/spf13/pflag"

"k8s.io/component-base/metrics"
"k8s.io/component-base/metrics/testutil"
"k8s.io/klog"
)

Expand Down Expand Up @@ -271,9 +271,7 @@ func scrapeMetrics() (map[string]*dto.MetricFamily, error) {
}
defer resp.Body.Close()

// Parse the metrics in text format to a MetricFamily struct.
var textParser expfmt.TextParser
return textParser.TextToMetricFamilies(resp.Body)
return testutil.TextToMetricFamilies(resp.Body)
}

func renameMetric(mf *dto.MetricFamily, name string) {
Expand Down
9 changes: 9 additions & 0 deletions staging/src/k8s.io/component-base/metrics/testutil/metrics.go
Expand Up @@ -92,6 +92,15 @@ func ParseMetrics(data string, output *Metrics) error {
}
}

// TextToMetricFamilies reads 'in' as the simple and flat text-based exchange
// format and creates MetricFamily proto messages. It returns the MetricFamily
// proto messages in a map where the metric names are the keys, along with any
// error encountered.
func TextToMetricFamilies(in io.Reader) (map[string]*dto.MetricFamily, error) {
var textParser expfmt.TextParser
return textParser.TextToMetricFamilies(in)
}

// ExtractMetricSamples parses the prometheus metric samples from the input string.
func ExtractMetricSamples(metricsBlob string) ([]*model.Sample, error) {
dec := expfmt.NewDecoder(strings.NewReader(metricsBlob), expfmt.FmtText)
Expand Down

0 comments on commit 3842a92

Please sign in to comment.