Bump prometheus dependency to v2.21.0 (#8795)

* Bump prometheus dependency to v2.21.0

* Make golangci-lint happy
This commit is contained in:
Patryk Małek 2021-03-25 17:18:50 +01:00 committed by GitHub
parent e4bbcc447d
commit e96955d1bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 645 additions and 131 deletions

View File

@ -27,6 +27,7 @@ following works:
- github.com/apache/thrift [Apache License 2.0](https://github.com/apache/thrift/blob/master/LICENSE) - github.com/apache/thrift [Apache License 2.0](https://github.com/apache/thrift/blob/master/LICENSE)
- github.com/aristanetworks/glog [Apache License 2.0](https://github.com/aristanetworks/glog/blob/master/LICENSE) - github.com/aristanetworks/glog [Apache License 2.0](https://github.com/aristanetworks/glog/blob/master/LICENSE)
- github.com/aristanetworks/goarista [Apache License 2.0](https://github.com/aristanetworks/goarista/blob/master/COPYING) - github.com/aristanetworks/goarista [Apache License 2.0](https://github.com/aristanetworks/goarista/blob/master/COPYING)
- github.com/armon/go-metrics [MIT License](https://github.com/armon/go-metrics/blob/master/LICENSE)
- github.com/aws/aws-sdk-go [Apache License 2.0](https://github.com/aws/aws-sdk-go/blob/master/LICENSE.txt) - github.com/aws/aws-sdk-go [Apache License 2.0](https://github.com/aws/aws-sdk-go/blob/master/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2 [Apache License 2.0](https://github.com/aws/aws-sdk-go-v2/blob/main/LICENSE.txt) - github.com/aws/aws-sdk-go-v2 [Apache License 2.0](https://github.com/aws/aws-sdk-go-v2/blob/main/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/config [Apache License 2.0](https://github.com/aws/aws-sdk-go-v2/blob/main/config/LICENSE.txt) - github.com/aws/aws-sdk-go-v2/config [Apache License 2.0](https://github.com/aws/aws-sdk-go-v2/blob/main/config/LICENSE.txt)
@ -62,6 +63,7 @@ following works:
- github.com/eapache/go-xerial-snappy [MIT License](https://github.com/eapache/go-xerial-snappy/blob/master/LICENSE) - github.com/eapache/go-xerial-snappy [MIT License](https://github.com/eapache/go-xerial-snappy/blob/master/LICENSE)
- github.com/eapache/queue [MIT License](https://github.com/eapache/queue/blob/master/LICENSE) - github.com/eapache/queue [MIT License](https://github.com/eapache/queue/blob/master/LICENSE)
- github.com/eclipse/paho.mqtt.golang [Eclipse Public License - v 1.0](https://github.com/eclipse/paho.mqtt.golang/blob/master/LICENSE) - github.com/eclipse/paho.mqtt.golang [Eclipse Public License - v 1.0](https://github.com/eclipse/paho.mqtt.golang/blob/master/LICENSE)
- github.com/fatih/color [MIT License](https://github.com/fatih/color/blob/master/LICENSE.md)
- github.com/form3tech-oss/jwt-go [MIT License](https://github.com/form3tech-oss/jwt-go/blob/master/LICENSE) - github.com/form3tech-oss/jwt-go [MIT License](https://github.com/form3tech-oss/jwt-go/blob/master/LICENSE)
- github.com/ghodss/yaml [MIT License](https://github.com/ghodss/yaml/blob/master/LICENSE) - github.com/ghodss/yaml [MIT License](https://github.com/ghodss/yaml/blob/master/LICENSE)
- github.com/go-logfmt/logfmt [MIT License](https://github.com/go-logfmt/logfmt/blob/master/LICENSE) - github.com/go-logfmt/logfmt [MIT License](https://github.com/go-logfmt/logfmt/blob/master/LICENSE)
@ -94,10 +96,13 @@ following works:
- github.com/grpc-ecosystem/grpc-gateway [BSD 3-Clause "New" or "Revised" License](https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt) - github.com/grpc-ecosystem/grpc-gateway [BSD 3-Clause "New" or "Revised" License](https://github.com/grpc-ecosystem/grpc-gateway/blob/master/LICENSE.txt)
- github.com/hailocab/go-hostpool [MIT License](https://github.com/hailocab/go-hostpool/blob/master/LICENSE) - github.com/hailocab/go-hostpool [MIT License](https://github.com/hailocab/go-hostpool/blob/master/LICENSE)
- github.com/harlow/kinesis-consumer [MIT License](https://github.com/harlow/kinesis-consumer/blob/master/MIT-LICENSE) - github.com/harlow/kinesis-consumer [MIT License](https://github.com/harlow/kinesis-consumer/blob/master/MIT-LICENSE)
- github.com/hashicorp/consul [Mozilla Public License 2.0](https://github.com/hashicorp/consul/blob/master/LICENSE) - github.com/hashicorp/consul/api [Mozilla Public License 2.0](https://github.com/hashicorp/consul/blob/master/LICENSE)
- github.com/hashicorp/go-cleanhttp [Mozilla Public License 2.0](https://github.com/hashicorp/go-cleanhttp/blob/master/LICENSE) - github.com/hashicorp/go-cleanhttp [Mozilla Public License 2.0](https://github.com/hashicorp/go-cleanhttp/blob/master/LICENSE)
- github.com/hashicorp/go-hclog [Mozilla Public License 2.0](https://github.com/hashicorp/go-hclog/LICENSE)
- github.com/hashicorp/go-immutable-radix [Mozilla Public License 2.0](https://github.com/hashicorp/go-immutable-radix/LICENSE)
- github.com/hashicorp/go-rootcerts [Mozilla Public License 2.0](https://github.com/hashicorp/go-rootcerts/blob/master/LICENSE) - github.com/hashicorp/go-rootcerts [Mozilla Public License 2.0](https://github.com/hashicorp/go-rootcerts/blob/master/LICENSE)
- github.com/hashicorp/go-uuid [Mozilla Public License 2.0](https://github.com/hashicorp/go-uuid/LICENSE) - github.com/hashicorp/go-uuid [Mozilla Public License 2.0](https://github.com/hashicorp/go-uuid/blob/master/LICENSE)
- github.com/hashicorp/golang-lru [Mozilla Public License 2.0](https://github.com/hashicorp/golang-lru/blob/master/LICENSE)
- github.com/hashicorp/serf [Mozilla Public License 2.0](https://github.com/hashicorp/serf/blob/master/LICENSE) - github.com/hashicorp/serf [Mozilla Public License 2.0](https://github.com/hashicorp/serf/blob/master/LICENSE)
- github.com/influxdata/go-syslog [MIT License](https://github.com/influxdata/go-syslog/blob/develop/LICENSE) - github.com/influxdata/go-syslog [MIT License](https://github.com/influxdata/go-syslog/blob/develop/LICENSE)
- github.com/influxdata/tail [MIT License](https://github.com/influxdata/tail/blob/master/LICENSE.txt) - github.com/influxdata/tail [MIT License](https://github.com/influxdata/tail/blob/master/LICENSE.txt)
@ -117,6 +122,7 @@ following works:
- github.com/konsorten/go-windows-terminal-sequences [MIT License](https://github.com/konsorten/go-windows-terminal-sequences/blob/master/LICENSE) - github.com/konsorten/go-windows-terminal-sequences [MIT License](https://github.com/konsorten/go-windows-terminal-sequences/blob/master/LICENSE)
- github.com/leodido/ragel-machinery [MIT License](https://github.com/leodido/ragel-machinery/blob/develop/LICENSE) - github.com/leodido/ragel-machinery [MIT License](https://github.com/leodido/ragel-machinery/blob/develop/LICENSE)
- github.com/mailru/easyjson [MIT License](https://github.com/mailru/easyjson/blob/master/LICENSE) - github.com/mailru/easyjson [MIT License](https://github.com/mailru/easyjson/blob/master/LICENSE)
- github.com/mattn/go-colorable [MIT License](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- github.com/mattn/go-isatty [MIT License](https://github.com/mattn/go-isatty/blob/master/LICENSE) - github.com/mattn/go-isatty [MIT License](https://github.com/mattn/go-isatty/blob/master/LICENSE)
- github.com/matttproud/golang_protobuf_extensions [Apache License 2.0](https://github.com/matttproud/golang_protobuf_extensions/blob/master/LICENSE) - github.com/matttproud/golang_protobuf_extensions [Apache License 2.0](https://github.com/matttproud/golang_protobuf_extensions/blob/master/LICENSE)
- github.com/mdlayher/apcupsd [MIT License](https://github.com/mdlayher/apcupsd/blob/master/LICENSE.md) - github.com/mdlayher/apcupsd [MIT License](https://github.com/mdlayher/apcupsd/blob/master/LICENSE.md)

52
go.mod
View File

@ -3,31 +3,29 @@ module github.com/influxdata/telegraf
go 1.16 go 1.16
require ( require (
cloud.google.com/go v0.54.0 cloud.google.com/go v0.56.0
cloud.google.com/go/bigquery v1.4.0 cloud.google.com/go/bigquery v1.4.0
cloud.google.com/go/pubsub v1.2.0 cloud.google.com/go/pubsub v1.2.0
code.cloudfoundry.org/clock v1.0.0 // indirect code.cloudfoundry.org/clock v1.0.0 // indirect
collectd.org v0.5.0 collectd.org v0.5.0
github.com/Azure/azure-event-hubs-go/v3 v3.2.0 github.com/Azure/azure-event-hubs-go/v3 v3.2.0
github.com/Azure/azure-storage-queue-go v0.0.0-20181215014128-6ed74e755687 github.com/Azure/azure-storage-queue-go v0.0.0-20181215014128-6ed74e755687
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect github.com/Azure/go-autorest/autorest v0.11.4
github.com/Azure/go-autorest/autorest v0.11.1
github.com/Azure/go-autorest/autorest/azure/auth v0.4.2 github.com/Azure/go-autorest/autorest/azure/auth v0.4.2
github.com/BurntSushi/toml v0.3.1 github.com/BurntSushi/toml v0.3.1
github.com/Mellanox/rdmamap v0.0.0-20191106181932-7c3c4763a6ee github.com/Mellanox/rdmamap v0.0.0-20191106181932-7c3c4763a6ee
github.com/Microsoft/ApplicationInsights-Go v0.4.2 github.com/Microsoft/ApplicationInsights-Go v0.4.2
github.com/Microsoft/go-winio v0.4.9 // indirect
github.com/Shopify/sarama v1.27.2 github.com/Shopify/sarama v1.27.2
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect
github.com/aerospike/aerospike-client-go v1.27.0 github.com/aerospike/aerospike-client-go v1.27.0
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d
github.com/aliyun/alibaba-cloud-sdk-go v1.61.785 github.com/aliyun/alibaba-cloud-sdk-go v1.61.1004
github.com/amir/raidman v0.0.0-20170415203553-1ccc43bfb9c9 github.com/amir/raidman v0.0.0-20170415203553-1ccc43bfb9c9
github.com/antchfx/xmlquery v1.3.3 github.com/antchfx/xmlquery v1.3.5
github.com/antchfx/xpath v1.1.11 github.com/antchfx/xpath v1.1.11
github.com/apache/thrift v0.12.0 github.com/apache/thrift v0.13.0
github.com/aristanetworks/glog v0.0.0-20191112221043-67e8567f59f3 // indirect github.com/aristanetworks/glog v0.0.0-20191112221043-67e8567f59f3 // indirect
github.com/aristanetworks/goarista v0.0.0-20190325233358-a123909ec740 github.com/aristanetworks/goarista v0.0.0-20190325233358-a123909ec740
github.com/armon/go-metrics v0.3.0 // indirect
github.com/aws/aws-sdk-go v1.34.34 github.com/aws/aws-sdk-go v1.34.34
github.com/aws/aws-sdk-go-v2 v1.1.0 github.com/aws/aws-sdk-go-v2 v1.1.0
github.com/aws/aws-sdk-go-v2/config v1.1.0 github.com/aws/aws-sdk-go-v2/config v1.1.0
@ -39,7 +37,6 @@ require (
github.com/bmatcuk/doublestar/v3 v3.0.0 github.com/bmatcuk/doublestar/v3 v3.0.0
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
github.com/caio/go-tdigest v3.1.0+incompatible github.com/caio/go-tdigest v3.1.0+incompatible
github.com/cenkalti/backoff v2.0.0+incompatible // indirect
github.com/cisco-ie/nx-telemetry-proto v0.0.0-20190531143454-82441e232cf6 github.com/cisco-ie/nx-telemetry-proto v0.0.0-20190531143454-82441e232cf6
github.com/cockroachdb/apd v1.1.0 // indirect github.com/cockroachdb/apd v1.1.0 // indirect
github.com/containerd/containerd v1.4.1 // indirect github.com/containerd/containerd v1.4.1 // indirect
@ -49,14 +46,11 @@ require (
github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4 github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4
github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1 github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1
github.com/dimchansky/utfbom v1.1.0 github.com/dimchansky/utfbom v1.1.0
github.com/docker/distribution v2.6.0-rc.1.0.20170726174610-edc3ab29cdff+incompatible // indirect
github.com/docker/docker v17.12.0-ce-rc1.0.20200916142827-bd33bbf0497b+incompatible github.com/docker/docker v17.12.0-ce-rc1.0.20200916142827-bd33bbf0497b+incompatible
github.com/docker/go-connections v0.3.0 // indirect
github.com/docker/go-units v0.3.3 // indirect
github.com/docker/libnetwork v0.8.0-dev.2.0.20181012153825-d7b61745d166 github.com/docker/libnetwork v0.8.0-dev.2.0.20181012153825-d7b61745d166
github.com/eclipse/paho.mqtt.golang v1.3.0 github.com/eclipse/paho.mqtt.golang v1.3.0
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/go-logfmt/logfmt v0.4.0 github.com/go-logfmt/logfmt v0.5.0
github.com/go-ping/ping v0.0.0-20210201095549-52eed920f98c github.com/go-ping/ping v0.0.0-20210201095549-52eed920f98c
github.com/go-redis/redis v6.15.9+incompatible github.com/go-redis/redis v6.15.9+incompatible
github.com/go-sql-driver/mysql v1.5.0 github.com/go-sql-driver/mysql v1.5.0
@ -71,16 +65,13 @@ require (
github.com/google/go-cmp v0.5.5 github.com/google/go-cmp v0.5.5
github.com/google/go-github/v32 v32.1.0 github.com/google/go-github/v32 v32.1.0
github.com/gopcua/opcua v0.1.13 github.com/gopcua/opcua v0.1.13
github.com/gorilla/mux v1.6.2 github.com/gorilla/mux v1.7.3
github.com/gosnmp/gosnmp v1.30.0 github.com/gosnmp/gosnmp v1.30.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/harlow/kinesis-consumer v0.3.1-0.20181230152818-2f58b136fee0 github.com/harlow/kinesis-consumer v0.3.1-0.20181230152818-2f58b136fee0
github.com/hashicorp/consul v1.2.1 github.com/hashicorp/consul/api v1.6.0
github.com/hashicorp/go-msgpack v0.5.5 // indirect github.com/hashicorp/go-msgpack v0.5.5 // indirect
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90 // indirect
github.com/hashicorp/memberlist v0.1.5 // indirect
github.com/hashicorp/serf v0.8.1 // indirect
github.com/influxdata/go-syslog/v2 v2.0.1 github.com/influxdata/go-syslog/v2 v2.0.1
github.com/influxdata/tail v1.0.1-0.20200707181643-03a791b270e4 github.com/influxdata/tail v1.0.1-0.20200707181643-03a791b270e4
github.com/influxdata/toml v0.0.0-20190415235208-270119a8ce65 github.com/influxdata/toml v0.0.0-20190415235208-270119a8ce65
@ -92,13 +83,10 @@ require (
github.com/kardianos/service v1.0.0 github.com/kardianos/service v1.0.0
github.com/karrick/godirwalk v1.16.1 github.com/karrick/godirwalk v1.16.1
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/lib/pq v1.3.0 // indirect github.com/lib/pq v1.3.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 github.com/matttproud/golang_protobuf_extensions v1.0.1
github.com/mdlayher/apcupsd v0.0.0-20200608131503-2bf01da7bf1b github.com/mdlayher/apcupsd v0.0.0-20200608131503-2bf01da7bf1b
github.com/miekg/dns v1.0.14 github.com/miekg/dns v1.1.31
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/multiplay/go-ts3 v1.0.0 github.com/multiplay/go-ts3 v1.0.0
github.com/naoina/go-stringutil v0.1.0 // indirect github.com/naoina/go-stringutil v0.1.0 // indirect
github.com/nats-io/nats-server/v2 v2.1.4 github.com/nats-io/nats-server/v2 v2.1.4
@ -106,26 +94,22 @@ require (
github.com/newrelic/newrelic-telemetry-sdk-go v0.5.1 github.com/newrelic/newrelic-telemetry-sdk-go v0.5.1
github.com/nsqio/go-nsq v1.0.8 github.com/nsqio/go-nsq v1.0.8
github.com/openconfig/gnmi v0.0.0-20180912164834-33a1865c3029 github.com/openconfig/gnmi v0.0.0-20180912164834-33a1865c3029
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492 // indirect
github.com/openzipkin/zipkin-go-opentracing v0.3.4 github.com/openzipkin/zipkin-go-opentracing v0.3.4
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.5.1 github.com/prometheus/client_golang v1.7.1
github.com/prometheus/client_model v0.2.0 github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.9.1 github.com/prometheus/common v0.13.0
github.com/prometheus/procfs v0.0.8 github.com/prometheus/procfs v0.1.3
github.com/prometheus/prometheus v2.5.0+incompatible github.com/prometheus/prometheus v1.8.2-0.20200911110723-e83ef207b6c2
github.com/riemann/riemann-go-client v0.5.0 github.com/riemann/riemann-go-client v0.5.0
github.com/safchain/ethtool v0.0.0-20200218184317-f459e2d13664 github.com/safchain/ethtool v0.0.0-20200218184317-f459e2d13664
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b // indirect
github.com/sensu/sensu-go/api/core/v2 v2.6.0 github.com/sensu/sensu-go/api/core/v2 v2.6.0
github.com/shirou/gopsutil v3.20.11+incompatible github.com/shirou/gopsutil v3.20.11+incompatible
github.com/shopspring/decimal v0.0.0-20200105231215-408a2507e114 // indirect github.com/shopspring/decimal v0.0.0-20200105231215-408a2507e114 // indirect
github.com/signalfx/golib/v3 v3.3.0 github.com/signalfx/golib/v3 v3.3.0
github.com/sirupsen/logrus v1.6.0 github.com/sirupsen/logrus v1.6.0
github.com/soniah/gosnmp v1.25.0 github.com/soniah/gosnmp v1.25.0
github.com/streadway/amqp v0.0.0-20180528204448-e5adc2ada8b8 github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.7.0
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62 github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62
github.com/tidwall/gjson v1.6.0 github.com/tidwall/gjson v1.6.0
@ -148,8 +132,8 @@ require (
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 golang.org/x/sys v0.0.0-20201119102817-f84b799fce68
golang.org/x/text v0.3.4 golang.org/x/text v0.3.4
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20200205215550-e35592f146e4 golang.zx2c4.com/wireguard/wgctrl v0.0.0-20200205215550-e35592f146e4
google.golang.org/api v0.20.0 google.golang.org/api v0.29.0
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 google.golang.org/genproto v0.0.0-20200815001618-f69a88009b70
google.golang.org/grpc v1.33.1 google.golang.org/grpc v1.33.1
gopkg.in/djherbis/times.v1 v1.2.0 gopkg.in/djherbis/times.v1 v1.2.0
gopkg.in/fatih/pool.v2 v2.0.0 // indirect gopkg.in/fatih/pool.v2 v2.0.0 // indirect

643
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -12,9 +12,9 @@ import (
func TestParse(t *testing.T) { func TestParse(t *testing.T) {
prompbInput := prompb.WriteRequest{ prompbInput := prompb.WriteRequest{
Timeseries: []*prompb.TimeSeries{ Timeseries: []prompb.TimeSeries{
{ {
Labels: []*prompb.Label{ Labels: []prompb.Label{
{Name: "__name__", Value: "go_gc_duration_seconds"}, {Name: "__name__", Value: "go_gc_duration_seconds"},
{Name: "quantile", Value: "0.99"}, {Name: "quantile", Value: "0.99"},
}, },
@ -23,7 +23,7 @@ func TestParse(t *testing.T) {
}, },
}, },
{ {
Labels: []*prompb.Label{ Labels: []prompb.Label{
{Name: "__name__", Value: "prometheus_target_interval_length_seconds"}, {Name: "__name__", Value: "prometheus_target_interval_length_seconds"},
{Name: "job", Value: "prometheus"}, {Name: "job", Value: "prometheus"},
}, },
@ -72,9 +72,9 @@ func TestParse(t *testing.T) {
func TestDefaultTags(t *testing.T) { func TestDefaultTags(t *testing.T) {
prompbInput := prompb.WriteRequest{ prompbInput := prompb.WriteRequest{
Timeseries: []*prompb.TimeSeries{ Timeseries: []prompb.TimeSeries{
{ {
Labels: []*prompb.Label{ Labels: []prompb.Label{
{Name: "__name__", Value: "foo"}, {Name: "__name__", Value: "foo"},
{Name: "__eg__", Value: "bar"}, {Name: "__eg__", Value: "bar"},
}, },
@ -118,9 +118,9 @@ func TestMetricsWithTimestamp(t *testing.T) {
testTime := time.Date(2020, time.October, 4, 17, 0, 0, 0, time.UTC) testTime := time.Date(2020, time.October, 4, 17, 0, 0, 0, time.UTC)
testTimeUnix := testTime.UnixNano() / int64(time.Millisecond) testTimeUnix := testTime.UnixNano() / int64(time.Millisecond)
prompbInput := prompb.WriteRequest{ prompbInput := prompb.WriteRequest{
Timeseries: []*prompb.TimeSeries{ Timeseries: []prompb.TimeSeries{
{ {
Labels: []*prompb.Label{ Labels: []prompb.Label{
{Name: "__name__", Value: "foo"}, {Name: "__name__", Value: "foo"},
{Name: "__eg__", Value: "bar"}, {Name: "__eg__", Value: "bar"},
}, },

View File

@ -3,15 +3,16 @@ package prometheusremotewrite
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/gogo/protobuf/proto"
"github.com/golang/snappy"
"github.com/influxdata/telegraf/plugins/serializers/prometheus"
"hash/fnv" "hash/fnv"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/gogo/protobuf/proto"
"github.com/golang/snappy"
"github.com/influxdata/telegraf/plugins/serializers/prometheus"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/prometheus/prometheus/prompb" "github.com/prometheus/prometheus/prompb"
) )
@ -54,11 +55,11 @@ func (s *Serializer) Serialize(metric telegraf.Metric) ([]byte, error) {
func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) { func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) {
var buf bytes.Buffer var buf bytes.Buffer
var entries = make(map[MetricKey]*prompb.TimeSeries) var entries = make(map[MetricKey]prompb.TimeSeries)
for _, metric := range metrics { for _, metric := range metrics {
commonLabels := s.createLabels(metric) commonLabels := s.createLabels(metric)
var metrickey MetricKey var metrickey MetricKey
var promts *prompb.TimeSeries var promts prompb.TimeSeries
for _, field := range metric.FieldList() { for _, field := range metric.FieldList() {
metricName := prometheus.MetricName(metric.Name(), field.Key, metric.Type()) metricName := prometheus.MetricName(metric.Name(), field.Key, metric.Type())
metricName, ok := prometheus.SanitizeMetricName(metricName) metricName, ok := prometheus.SanitizeMetricName(metricName)
@ -88,9 +89,9 @@ func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) {
if _, ok = entries[metrickeycount]; !ok { if _, ok = entries[metrickeycount]; !ok {
entries[metrickeycount] = promtscount entries[metrickeycount] = promtscount
} }
labels := make([]*prompb.Label, len(commonLabels), len(commonLabels)+1) labels := make([]prompb.Label, len(commonLabels), len(commonLabels)+1)
copy(labels, commonLabels) copy(labels, commonLabels)
labels = append(labels, &prompb.Label{ labels = append(labels, prompb.Label{
Name: "le", Name: "le",
Value: "+Inf", Value: "+Inf",
}) })
@ -112,9 +113,9 @@ func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) {
continue continue
} }
labels = make([]*prompb.Label, len(commonLabels), len(commonLabels)+1) labels = make([]prompb.Label, len(commonLabels), len(commonLabels)+1)
copy(labels, commonLabels) copy(labels, commonLabels)
labels = append(labels, &prompb.Label{ labels = append(labels, prompb.Label{
Name: "le", Name: "le",
Value: fmt.Sprint(bound), Value: fmt.Sprint(bound),
}) })
@ -133,9 +134,9 @@ func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) {
} }
// if no bucket generate +Inf entry // if no bucket generate +Inf entry
labels := make([]*prompb.Label, len(commonLabels), len(commonLabels)+1) labels := make([]prompb.Label, len(commonLabels), len(commonLabels)+1)
copy(labels, commonLabels) copy(labels, commonLabels)
labels = append(labels, &prompb.Label{ labels = append(labels, prompb.Label{
Name: "le", Name: "le",
Value: "+Inf", Value: "+Inf",
}) })
@ -178,9 +179,9 @@ func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) {
continue continue
} }
labels := make([]*prompb.Label, len(commonLabels), len(commonLabels)+1) labels := make([]prompb.Label, len(commonLabels), len(commonLabels)+1)
copy(labels, commonLabels) copy(labels, commonLabels)
labels = append(labels, &prompb.Label{ labels = append(labels, prompb.Label{
Name: "quantile", Name: "quantile",
Value: fmt.Sprint(quantile), Value: fmt.Sprint(quantile),
}) })
@ -203,8 +204,8 @@ func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) {
} }
} }
var promTS = make([]*prompb.TimeSeries, len(entries)) var promTS = make([]prompb.TimeSeries, len(entries))
var i int64 var i int
for _, promts := range entries { for _, promts := range entries {
promTS[i] = promts promTS[i] = promts
i++ i++
@ -244,7 +245,7 @@ func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error) {
return buf.Bytes(), nil return buf.Bytes(), nil
} }
func hasLabel(name string, labels []*prompb.Label) bool { func hasLabel(name string, labels []prompb.Label) bool {
for _, label := range labels { for _, label := range labels {
if name == label.Name { if name == label.Name {
return true return true
@ -253,8 +254,8 @@ func hasLabel(name string, labels []*prompb.Label) bool {
return false return false
} }
func (s *Serializer) createLabels(metric telegraf.Metric) []*prompb.Label { func (s *Serializer) createLabels(metric telegraf.Metric) []prompb.Label {
labels := make([]*prompb.Label, 0, len(metric.TagList())) labels := make([]prompb.Label, 0, len(metric.TagList()))
for _, tag := range metric.TagList() { for _, tag := range metric.TagList() {
// Ignore special tags for histogram and summary types. // Ignore special tags for histogram and summary types.
switch metric.Type() { switch metric.Type() {
@ -273,7 +274,7 @@ func (s *Serializer) createLabels(metric telegraf.Metric) []*prompb.Label {
continue continue
} }
labels = append(labels, &prompb.Label{Name: name, Value: tag.Value}) labels = append(labels, prompb.Label{Name: name, Value: tag.Value})
} }
if s.config.StringHandling != StringAsLabel { if s.config.StringHandling != StringAsLabel {
@ -298,7 +299,7 @@ func (s *Serializer) createLabels(metric telegraf.Metric) []*prompb.Label {
continue continue
} }
labels = append(labels, &prompb.Label{Name: name, Value: value}) labels = append(labels, prompb.Label{Name: name, Value: value})
addedFieldLabel = true addedFieldLabel = true
} }
@ -311,7 +312,7 @@ func (s *Serializer) createLabels(metric telegraf.Metric) []*prompb.Label {
return labels return labels
} }
func MakeMetricKey(labels []*prompb.Label) MetricKey { func MakeMetricKey(labels []prompb.Label) MetricKey {
h := fnv.New64a() h := fnv.New64a()
for _, label := range labels { for _, label := range labels {
h.Write([]byte(label.Name)) h.Write([]byte(label.Name))
@ -322,17 +323,17 @@ func MakeMetricKey(labels []*prompb.Label) MetricKey {
return MetricKey(h.Sum64()) return MetricKey(h.Sum64())
} }
func getPromTS(name string, labels []*prompb.Label, value float64, ts time.Time) (MetricKey, *prompb.TimeSeries) { func getPromTS(name string, labels []prompb.Label, value float64, ts time.Time) (MetricKey, prompb.TimeSeries) {
sample := []prompb.Sample{{ sample := []prompb.Sample{{
// Timestamp is int milliseconds for remote write. // Timestamp is int milliseconds for remote write.
Timestamp: ts.UnixNano() / int64(time.Millisecond), Timestamp: ts.UnixNano() / int64(time.Millisecond),
Value: value, Value: value,
}} }}
labelscopy := make([]*prompb.Label, len(labels), len(labels)+1) labelscopy := make([]prompb.Label, len(labels), len(labels)+1)
copy(labelscopy, labels) copy(labelscopy, labels)
labels = append(labelscopy, &prompb.Label{ labels = append(labelscopy, prompb.Label{
Name: "__name__", Name: "__name__",
Value: name, Value: name,
}) })
return MakeMetricKey(labels), &prompb.TimeSeries{Labels: labels, Samples: sample} return MakeMetricKey(labels), prompb.TimeSeries{Labels: labels, Samples: sample}
} }

View File

@ -141,6 +141,7 @@ http_request_duration_seconds_bucket{le="0.5"} 129389
}) })
require.NoError(t, err) require.NoError(t, err)
data, err := s.Serialize(tt.metric) data, err := s.Serialize(tt.metric)
require.NoError(t, err)
actual, err := prompbToText(data) actual, err := prompbToText(data)
require.NoError(t, err) require.NoError(t, err)
@ -647,7 +648,10 @@ func prompbToText(data []byte) ([]byte, error) {
} }
samples := protoToSamples(&req) samples := protoToSamples(&req)
for _, sample := range samples { for _, sample := range samples {
buf.Write([]byte(fmt.Sprintf("%s %s\n", sample.Metric.String(), sample.Value.String()))) _, err = buf.Write([]byte(fmt.Sprintf("%s %s\n", sample.Metric.String(), sample.Value.String())))
if err != nil {
return nil, err
}
} }
if err != nil { if err != nil {
return nil, err return nil, err