chore(linters): Enable `import-alias-naming` and `redundant-import-alias` rules for revive (#15836)
This commit is contained in:
parent
7d82709caf
commit
9415d8e7e9
|
|
@ -270,6 +270,9 @@ linters-settings:
|
||||||
- name: get-return
|
- name: get-return
|
||||||
- name: identical-branches
|
- name: identical-branches
|
||||||
- name: if-return
|
- name: if-return
|
||||||
|
- name: import-alias-naming
|
||||||
|
arguments:
|
||||||
|
- "^[a-z][a-z0-9_]*[a-z0-9]+$"
|
||||||
- name: import-shadowing
|
- name: import-shadowing
|
||||||
- name: increment-decrement
|
- name: increment-decrement
|
||||||
- name: indent-error-flow
|
- name: indent-error-flow
|
||||||
|
|
@ -285,6 +288,7 @@ linters-settings:
|
||||||
- name: range-val-in-closure
|
- name: range-val-in-closure
|
||||||
- name: receiver-naming
|
- name: receiver-naming
|
||||||
- name: redefines-builtin-id
|
- name: redefines-builtin-id
|
||||||
|
- name: redundant-import-alias
|
||||||
- name: string-of-int
|
- name: string-of-int
|
||||||
- name: struct-tag
|
- name: struct-tag
|
||||||
- name: superfluous-else
|
- name: superfluous-else
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import (
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/go-cmp/cmp/cmpopts"
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/json_v2"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -33,10 +32,11 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/parsers"
|
"github.com/influxdata/telegraf/plugins/parsers"
|
||||||
_ "github.com/influxdata/telegraf/plugins/parsers/all" // Blank import to have all parsers for testing
|
_ "github.com/influxdata/telegraf/plugins/parsers/all" // Blank import to have all parsers for testing
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/json"
|
"github.com/influxdata/telegraf/plugins/parsers/json"
|
||||||
|
"github.com/influxdata/telegraf/plugins/parsers/json_v2"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
"github.com/influxdata/telegraf/plugins/serializers"
|
"github.com/influxdata/telegraf/plugins/serializers"
|
||||||
_ "github.com/influxdata/telegraf/plugins/serializers/all" // Blank import to have all serializers for testing
|
_ "github.com/influxdata/telegraf/plugins/serializers/all" // Blank import to have all serializers for testing
|
||||||
promserializer "github.com/influxdata/telegraf/plugins/serializers/prometheus"
|
serializers_prometheus "github.com/influxdata/telegraf/plugins/serializers/prometheus"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -687,7 +687,7 @@ func TestConfig_SerializerInterfaceNewFormat(t *testing.T) {
|
||||||
// Ignore all unexported fields and fields not relevant for functionality
|
// Ignore all unexported fields and fields not relevant for functionality
|
||||||
options := []cmp.Option{
|
options := []cmp.Option{
|
||||||
cmpopts.IgnoreUnexported(stype),
|
cmpopts.IgnoreUnexported(stype),
|
||||||
cmpopts.IgnoreUnexported(reflect.Indirect(reflect.ValueOf(promserializer.MetricTypes{})).Interface()),
|
cmpopts.IgnoreUnexported(reflect.Indirect(reflect.ValueOf(serializers_prometheus.MetricTypes{})).Interface()),
|
||||||
cmpopts.IgnoreTypes(sync.Mutex{}, regexp.Regexp{}),
|
cmpopts.IgnoreTypes(sync.Mutex{}, regexp.Regexp{}),
|
||||||
cmpopts.IgnoreInterfaces(struct{ telegraf.Logger }{}),
|
cmpopts.IgnoreInterfaces(struct{ telegraf.Logger }{}),
|
||||||
}
|
}
|
||||||
|
|
@ -779,7 +779,7 @@ func TestConfig_SerializerInterfaceOldFormat(t *testing.T) {
|
||||||
// Ignore all unexported fields and fields not relevant for functionality
|
// Ignore all unexported fields and fields not relevant for functionality
|
||||||
options := []cmp.Option{
|
options := []cmp.Option{
|
||||||
cmpopts.IgnoreUnexported(stype),
|
cmpopts.IgnoreUnexported(stype),
|
||||||
cmpopts.IgnoreUnexported(reflect.Indirect(reflect.ValueOf(promserializer.MetricTypes{})).Interface()),
|
cmpopts.IgnoreUnexported(reflect.Indirect(reflect.ValueOf(serializers_prometheus.MetricTypes{})).Interface()),
|
||||||
cmpopts.IgnoreTypes(sync.Mutex{}, regexp.Regexp{}),
|
cmpopts.IgnoreTypes(sync.Mutex{}, regexp.Regexp{}),
|
||||||
cmpopts.IgnoreInterfaces(struct{ telegraf.Logger }{}),
|
cmpopts.IgnoreInterfaces(struct{ telegraf.Logger }{}),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"context"
|
"context"
|
||||||
cryptoRand "crypto/rand"
|
crypto_rand "crypto/rand"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
@ -94,7 +94,7 @@ func ReadLines(filename string) ([]string, error) {
|
||||||
// RandomString returns a random string of alphanumeric characters
|
// RandomString returns a random string of alphanumeric characters
|
||||||
func RandomString(n int) (string, error) {
|
func RandomString(n int) (string, error) {
|
||||||
var bytes = make([]byte, n)
|
var bytes = make([]byte, n)
|
||||||
_, err := cryptoRand.Read(bytes)
|
_, err := crypto_rand.Read(bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
telegrafConfig "github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/plugins/aggregators"
|
"github.com/influxdata/telegraf/plugins/aggregators"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -29,18 +29,18 @@ const bucketNegInf = "-Inf"
|
||||||
|
|
||||||
// HistogramAggregator is aggregator with histogram configs and particular histograms for defined metrics
|
// HistogramAggregator is aggregator with histogram configs and particular histograms for defined metrics
|
||||||
type HistogramAggregator struct {
|
type HistogramAggregator struct {
|
||||||
Configs []config `toml:"config"`
|
Configs []bucketConfig `toml:"config"`
|
||||||
ResetBuckets bool `toml:"reset"`
|
ResetBuckets bool `toml:"reset"`
|
||||||
Cumulative bool `toml:"cumulative"`
|
Cumulative bool `toml:"cumulative"`
|
||||||
ExpirationInterval telegrafConfig.Duration `toml:"expiration_interval"`
|
ExpirationInterval config.Duration `toml:"expiration_interval"`
|
||||||
PushOnlyOnUpdate bool `toml:"push_only_on_update"`
|
PushOnlyOnUpdate bool `toml:"push_only_on_update"`
|
||||||
|
|
||||||
buckets bucketsByMetrics
|
buckets bucketsByMetrics
|
||||||
cache map[uint64]metricHistogramCollection
|
cache map[uint64]metricHistogramCollection
|
||||||
}
|
}
|
||||||
|
|
||||||
// config is the config, which contains name, field of metric and histogram buckets.
|
// bucketConfig is the config, which contains name, field of metric and histogram buckets.
|
||||||
type config struct {
|
type bucketConfig struct {
|
||||||
Metric string `toml:"measurement_name"`
|
Metric string `toml:"measurement_name"`
|
||||||
Fields []string `toml:"fields"`
|
Fields []string `toml:"fields"`
|
||||||
Buckets buckets `toml:"buckets"`
|
Buckets buckets `toml:"buckets"`
|
||||||
|
|
@ -239,9 +239,9 @@ func (h *HistogramAggregator) getBuckets(metric string, field string) []float64
|
||||||
return buckets
|
return buckets
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, config := range h.Configs {
|
for _, cfg := range h.Configs {
|
||||||
if config.Metric == metric {
|
if cfg.Metric == metric {
|
||||||
if !isBucketExists(field, config) {
|
if !isBucketExists(field, cfg) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -249,7 +249,7 @@ func (h *HistogramAggregator) getBuckets(metric string, field string) []float64
|
||||||
h.buckets[metric] = make(bucketsByFields)
|
h.buckets[metric] = make(bucketsByFields)
|
||||||
}
|
}
|
||||||
|
|
||||||
h.buckets[metric][field] = sortBuckets(config.Buckets)
|
h.buckets[metric][field] = sortBuckets(cfg.Buckets)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,7 +257,7 @@ func (h *HistogramAggregator) getBuckets(metric string, field string) []float64
|
||||||
}
|
}
|
||||||
|
|
||||||
// isBucketExists checks if buckets exists for the passed field
|
// isBucketExists checks if buckets exists for the passed field
|
||||||
func isBucketExists(field string, cfg config) bool {
|
func isBucketExists(field string, cfg bucketConfig) bool {
|
||||||
if len(cfg.Fields) == 0 {
|
if len(cfg.Fields) == 0 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
telegrafConfig "github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
@ -17,16 +17,16 @@ type fields map[string]interface{}
|
||||||
type tags map[string]string
|
type tags map[string]string
|
||||||
|
|
||||||
// NewTestHistogram creates new test histogram aggregation with specified config
|
// NewTestHistogram creates new test histogram aggregation with specified config
|
||||||
func NewTestHistogram(cfg []config, reset bool, cumulative bool, pushOnlyOnUpdate bool) telegraf.Aggregator {
|
func NewTestHistogram(cfg []bucketConfig, reset bool, cumulative bool, pushOnlyOnUpdate bool) telegraf.Aggregator {
|
||||||
return NewTestHistogramWithExpirationInterval(cfg, reset, cumulative, pushOnlyOnUpdate, 0)
|
return NewTestHistogramWithExpirationInterval(cfg, reset, cumulative, pushOnlyOnUpdate, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTestHistogramWithExpirationInterval(
|
func NewTestHistogramWithExpirationInterval(
|
||||||
cfg []config,
|
cfg []bucketConfig,
|
||||||
reset bool,
|
reset bool,
|
||||||
cumulative bool,
|
cumulative bool,
|
||||||
pushOnlyOnUpdate bool,
|
pushOnlyOnUpdate bool,
|
||||||
expirationInterval telegrafConfig.Duration,
|
expirationInterval config.Duration,
|
||||||
) telegraf.Aggregator {
|
) telegraf.Aggregator {
|
||||||
htm := NewHistogramAggregator()
|
htm := NewHistogramAggregator()
|
||||||
htm.Configs = cfg
|
htm.Configs = cfg
|
||||||
|
|
@ -85,8 +85,8 @@ func BenchmarkApply(b *testing.B) {
|
||||||
|
|
||||||
// TestHistogram tests metrics for one period and for one field
|
// TestHistogram tests metrics for one period and for one field
|
||||||
func TestHistogram(t *testing.T) {
|
func TestHistogram(t *testing.T) {
|
||||||
var cfg []config
|
var cfg []bucketConfig
|
||||||
cfg = append(cfg, config{Metric: "first_metric_name", Fields: []string{"a"}, Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}})
|
cfg = append(cfg, bucketConfig{Metric: "first_metric_name", Fields: []string{"a"}, Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}})
|
||||||
histogram := NewTestHistogram(cfg, false, true, false)
|
histogram := NewTestHistogram(cfg, false, true, false)
|
||||||
|
|
||||||
acc := &testutil.Accumulator{}
|
acc := &testutil.Accumulator{}
|
||||||
|
|
@ -107,8 +107,8 @@ func TestHistogram(t *testing.T) {
|
||||||
|
|
||||||
// TestHistogram tests metrics for one period, for one field and push only on histogram update
|
// TestHistogram tests metrics for one period, for one field and push only on histogram update
|
||||||
func TestHistogramPushOnUpdate(t *testing.T) {
|
func TestHistogramPushOnUpdate(t *testing.T) {
|
||||||
var cfg []config
|
var cfg []bucketConfig
|
||||||
cfg = append(cfg, config{Metric: "first_metric_name", Fields: []string{"a"}, Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}})
|
cfg = append(cfg, bucketConfig{Metric: "first_metric_name", Fields: []string{"a"}, Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}})
|
||||||
histogram := NewTestHistogram(cfg, false, true, true)
|
histogram := NewTestHistogram(cfg, false, true, true)
|
||||||
|
|
||||||
acc := &testutil.Accumulator{}
|
acc := &testutil.Accumulator{}
|
||||||
|
|
@ -143,8 +143,8 @@ func TestHistogramPushOnUpdate(t *testing.T) {
|
||||||
|
|
||||||
// TestHistogramNonCumulative tests metrics for one period and for one field
|
// TestHistogramNonCumulative tests metrics for one period and for one field
|
||||||
func TestHistogramNonCumulative(t *testing.T) {
|
func TestHistogramNonCumulative(t *testing.T) {
|
||||||
var cfg []config
|
var cfg []bucketConfig
|
||||||
cfg = append(cfg, config{Metric: "first_metric_name", Fields: []string{"a"}, Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}})
|
cfg = append(cfg, bucketConfig{Metric: "first_metric_name", Fields: []string{"a"}, Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}})
|
||||||
histogram := NewTestHistogram(cfg, false, false, false)
|
histogram := NewTestHistogram(cfg, false, false, false)
|
||||||
|
|
||||||
acc := &testutil.Accumulator{}
|
acc := &testutil.Accumulator{}
|
||||||
|
|
@ -165,8 +165,8 @@ func TestHistogramNonCumulative(t *testing.T) {
|
||||||
|
|
||||||
// TestHistogramWithReset tests metrics for one period and for one field, with reset between metrics adding
|
// TestHistogramWithReset tests metrics for one period and for one field, with reset between metrics adding
|
||||||
func TestHistogramWithReset(t *testing.T) {
|
func TestHistogramWithReset(t *testing.T) {
|
||||||
var cfg []config
|
var cfg []bucketConfig
|
||||||
cfg = append(cfg, config{Metric: "first_metric_name", Fields: []string{"a"}, Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}})
|
cfg = append(cfg, bucketConfig{Metric: "first_metric_name", Fields: []string{"a"}, Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}})
|
||||||
histogram := NewTestHistogram(cfg, true, true, false)
|
histogram := NewTestHistogram(cfg, true, true, false)
|
||||||
|
|
||||||
acc := &testutil.Accumulator{}
|
acc := &testutil.Accumulator{}
|
||||||
|
|
@ -187,7 +187,7 @@ func TestHistogramWithReset(t *testing.T) {
|
||||||
|
|
||||||
// TestHistogramWithAllFields tests two metrics for one period and for all fields
|
// TestHistogramWithAllFields tests two metrics for one period and for all fields
|
||||||
func TestHistogramWithAllFields(t *testing.T) {
|
func TestHistogramWithAllFields(t *testing.T) {
|
||||||
cfg := []config{
|
cfg := []bucketConfig{
|
||||||
{Metric: "first_metric_name", Buckets: []float64{0.0, 15.5, 20.0, 30.0, 40.0}},
|
{Metric: "first_metric_name", Buckets: []float64{0.0, 15.5, 20.0, 30.0, 40.0}},
|
||||||
{Metric: "second_metric_name", Buckets: []float64{0.0, 4.0, 10.0, 23.0, 30.0}},
|
{Metric: "second_metric_name", Buckets: []float64{0.0, 4.0, 10.0, 23.0, 30.0}},
|
||||||
}
|
}
|
||||||
|
|
@ -266,7 +266,7 @@ func TestHistogramWithAllFields(t *testing.T) {
|
||||||
|
|
||||||
// TestHistogramWithAllFieldsNonCumulative tests two metrics for one period and for all fields
|
// TestHistogramWithAllFieldsNonCumulative tests two metrics for one period and for all fields
|
||||||
func TestHistogramWithAllFieldsNonCumulative(t *testing.T) {
|
func TestHistogramWithAllFieldsNonCumulative(t *testing.T) {
|
||||||
cfg := []config{
|
cfg := []bucketConfig{
|
||||||
{Metric: "first_metric_name", Buckets: []float64{0.0, 15.5, 20.0, 30.0, 40.0}},
|
{Metric: "first_metric_name", Buckets: []float64{0.0, 15.5, 20.0, 30.0, 40.0}},
|
||||||
{Metric: "second_metric_name", Buckets: []float64{0.0, 4.0, 10.0, 23.0, 30.0}},
|
{Metric: "second_metric_name", Buckets: []float64{0.0, 4.0, 10.0, 23.0, 30.0}},
|
||||||
}
|
}
|
||||||
|
|
@ -370,8 +370,8 @@ func TestHistogramWithAllFieldsNonCumulative(t *testing.T) {
|
||||||
// TestHistogramWithTwoPeriodsAndAllFields tests two metrics getting added with a push/reset in between (simulates
|
// TestHistogramWithTwoPeriodsAndAllFields tests two metrics getting added with a push/reset in between (simulates
|
||||||
// getting added in different periods) for all fields
|
// getting added in different periods) for all fields
|
||||||
func TestHistogramWithTwoPeriodsAndAllFields(t *testing.T) {
|
func TestHistogramWithTwoPeriodsAndAllFields(t *testing.T) {
|
||||||
var cfg []config
|
var cfg []bucketConfig
|
||||||
cfg = append(cfg, config{Metric: "first_metric_name", Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}})
|
cfg = append(cfg, bucketConfig{Metric: "first_metric_name", Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}})
|
||||||
histogram := NewTestHistogram(cfg, false, true, false)
|
histogram := NewTestHistogram(cfg, false, true, false)
|
||||||
|
|
||||||
acc := &testutil.Accumulator{}
|
acc := &testutil.Accumulator{}
|
||||||
|
|
@ -415,8 +415,8 @@ func TestWrongBucketsOrder(t *testing.T) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var cfg []config
|
var cfg []bucketConfig
|
||||||
cfg = append(cfg, config{Metric: "first_metric_name", Buckets: []float64{0.0, 90.0, 20.0, 30.0, 40.0}})
|
cfg = append(cfg, bucketConfig{Metric: "first_metric_name", Buckets: []float64{0.0, 90.0, 20.0, 30.0, 40.0}})
|
||||||
histogram := NewTestHistogram(cfg, false, true, false)
|
histogram := NewTestHistogram(cfg, false, true, false)
|
||||||
histogram.Add(firstMetric2)
|
histogram.Add(firstMetric2)
|
||||||
}
|
}
|
||||||
|
|
@ -431,11 +431,11 @@ func TestHistogramMetricExpiration(t *testing.T) {
|
||||||
timeNow = time.Now
|
timeNow = time.Now
|
||||||
}()
|
}()
|
||||||
|
|
||||||
cfg := []config{
|
cfg := []bucketConfig{
|
||||||
{Metric: "first_metric_name", Fields: []string{"a"}, Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}},
|
{Metric: "first_metric_name", Fields: []string{"a"}, Buckets: []float64{0.0, 10.0, 20.0, 30.0, 40.0}},
|
||||||
{Metric: "second_metric_name", Buckets: []float64{0.0, 4.0, 10.0, 23.0, 30.0}},
|
{Metric: "second_metric_name", Buckets: []float64{0.0, 4.0, 10.0, 23.0, 30.0}},
|
||||||
}
|
}
|
||||||
histogram := NewTestHistogramWithExpirationInterval(cfg, false, true, false, telegrafConfig.Duration(30))
|
histogram := NewTestHistogramWithExpirationInterval(cfg, false, true, false, config.Duration(30))
|
||||||
|
|
||||||
acc := &testutil.Accumulator{}
|
acc := &testutil.Accumulator{}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBasicAuth_VerifyWithCredentials(t *testing.T) {
|
func TestBasicAuth_VerifyWithCredentials(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ package aws
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
awsV2 "github.com/aws/aws-sdk-go-v2/aws"
|
"github.com/aws/aws-sdk-go-v2/aws"
|
||||||
configV2 "github.com/aws/aws-sdk-go-v2/config"
|
"github.com/aws/aws-sdk-go-v2/config"
|
||||||
credentialsV2 "github.com/aws/aws-sdk-go-v2/credentials"
|
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||||
stscredsV2 "github.com/aws/aws-sdk-go-v2/credentials/stscreds"
|
"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
|
||||||
"github.com/aws/aws-sdk-go-v2/service/sts"
|
"github.com/aws/aws-sdk-go-v2/service/sts"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -24,61 +24,61 @@ type CredentialConfig struct {
|
||||||
WebIdentityTokenFile string `toml:"web_identity_token_file"`
|
WebIdentityTokenFile string `toml:"web_identity_token_file"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CredentialConfig) Credentials() (awsV2.Config, error) {
|
func (c *CredentialConfig) Credentials() (aws.Config, error) {
|
||||||
if c.RoleARN != "" {
|
if c.RoleARN != "" {
|
||||||
return c.configWithAssumeCredentials()
|
return c.configWithAssumeCredentials()
|
||||||
}
|
}
|
||||||
return c.configWithRootCredentials()
|
return c.configWithRootCredentials()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CredentialConfig) configWithRootCredentials() (awsV2.Config, error) {
|
func (c *CredentialConfig) configWithRootCredentials() (aws.Config, error) {
|
||||||
options := []func(*configV2.LoadOptions) error{
|
options := []func(*config.LoadOptions) error{
|
||||||
configV2.WithRegion(c.Region),
|
config.WithRegion(c.Region),
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Profile != "" {
|
if c.Profile != "" {
|
||||||
options = append(options, configV2.WithSharedConfigProfile(c.Profile))
|
options = append(options, config.WithSharedConfigProfile(c.Profile))
|
||||||
}
|
}
|
||||||
if c.Filename != "" {
|
if c.Filename != "" {
|
||||||
options = append(options, configV2.WithSharedCredentialsFiles([]string{c.Filename}))
|
options = append(options, config.WithSharedCredentialsFiles([]string{c.Filename}))
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.AccessKey != "" || c.SecretKey != "" {
|
if c.AccessKey != "" || c.SecretKey != "" {
|
||||||
provider := credentialsV2.NewStaticCredentialsProvider(c.AccessKey, c.SecretKey, c.Token)
|
provider := credentials.NewStaticCredentialsProvider(c.AccessKey, c.SecretKey, c.Token)
|
||||||
options = append(options, configV2.WithCredentialsProvider(provider))
|
options = append(options, config.WithCredentialsProvider(provider))
|
||||||
}
|
}
|
||||||
|
|
||||||
return configV2.LoadDefaultConfig(context.Background(), options...)
|
return config.LoadDefaultConfig(context.Background(), options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CredentialConfig) configWithAssumeCredentials() (awsV2.Config, error) {
|
func (c *CredentialConfig) configWithAssumeCredentials() (aws.Config, error) {
|
||||||
// To generate credentials using assumeRole, we need to create AWS STS client with the default AWS endpoint,
|
// To generate credentials using assumeRole, we need to create AWS STS client with the default AWS endpoint,
|
||||||
defaultConfig, err := c.configWithRootCredentials()
|
defaultConfig, err := c.configWithRootCredentials()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return awsV2.Config{}, err
|
return aws.Config{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var provider awsV2.CredentialsProvider
|
var provider aws.CredentialsProvider
|
||||||
stsService := sts.NewFromConfig(defaultConfig)
|
stsService := sts.NewFromConfig(defaultConfig)
|
||||||
if c.WebIdentityTokenFile != "" {
|
if c.WebIdentityTokenFile != "" {
|
||||||
provider = stscredsV2.NewWebIdentityRoleProvider(
|
provider = stscreds.NewWebIdentityRoleProvider(
|
||||||
stsService,
|
stsService,
|
||||||
c.RoleARN,
|
c.RoleARN,
|
||||||
stscredsV2.IdentityTokenFile(c.WebIdentityTokenFile),
|
stscreds.IdentityTokenFile(c.WebIdentityTokenFile),
|
||||||
func(opts *stscredsV2.WebIdentityRoleOptions) {
|
func(opts *stscreds.WebIdentityRoleOptions) {
|
||||||
if c.RoleSessionName != "" {
|
if c.RoleSessionName != "" {
|
||||||
opts.RoleSessionName = c.RoleSessionName
|
opts.RoleSessionName = c.RoleSessionName
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
provider = stscredsV2.NewAssumeRoleProvider(stsService, c.RoleARN, func(opts *stscredsV2.AssumeRoleOptions) {
|
provider = stscreds.NewAssumeRoleProvider(stsService, c.RoleARN, func(opts *stscreds.AssumeRoleOptions) {
|
||||||
if c.RoleSessionName != "" {
|
if c.RoleSessionName != "" {
|
||||||
opts.RoleSessionName = c.RoleSessionName
|
opts.RoleSessionName = c.RoleSessionName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig.Credentials = awsV2.NewCredentialsCache(provider)
|
defaultConfig.Credentials = aws.NewCredentialsCache(provider)
|
||||||
return defaultConfig, nil
|
return defaultConfig, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/plugins/common/cookie"
|
"github.com/influxdata/telegraf/plugins/common/cookie"
|
||||||
oauthConfig "github.com/influxdata/telegraf/plugins/common/oauth"
|
"github.com/influxdata/telegraf/plugins/common/oauth"
|
||||||
"github.com/influxdata/telegraf/plugins/common/proxy"
|
"github.com/influxdata/telegraf/plugins/common/proxy"
|
||||||
"github.com/influxdata/telegraf/plugins/common/tls"
|
"github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
)
|
)
|
||||||
|
|
@ -27,7 +27,7 @@ type HTTPClientConfig struct {
|
||||||
|
|
||||||
proxy.HTTPProxy
|
proxy.HTTPProxy
|
||||||
tls.ClientConfig
|
tls.ClientConfig
|
||||||
oauthConfig.OAuth2Config
|
oauth.OAuth2Config
|
||||||
cookie.CookieAuthConfig
|
cookie.CookieAuthConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/IBM/sarama"
|
"github.com/IBM/sarama"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
tgConf "github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/plugins/common/tls"
|
"github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -19,10 +19,9 @@ type ReadConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetConfig on the sarama.Config object from the ReadConfig struct.
|
// SetConfig on the sarama.Config object from the ReadConfig struct.
|
||||||
func (k *ReadConfig) SetConfig(config *sarama.Config, log telegraf.Logger) error {
|
func (k *ReadConfig) SetConfig(cfg *sarama.Config, log telegraf.Logger) error {
|
||||||
config.Consumer.Return.Errors = true
|
cfg.Consumer.Return.Errors = true
|
||||||
|
return k.Config.SetConfig(cfg, log)
|
||||||
return k.Config.SetConfig(config, log)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteConfig for kafka clients meaning to write to kafka
|
// WriteConfig for kafka clients meaning to write to kafka
|
||||||
|
|
@ -36,18 +35,18 @@ type WriteConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetConfig on the sarama.Config object from the WriteConfig struct.
|
// SetConfig on the sarama.Config object from the WriteConfig struct.
|
||||||
func (k *WriteConfig) SetConfig(config *sarama.Config, log telegraf.Logger) error {
|
func (k *WriteConfig) SetConfig(cfg *sarama.Config, log telegraf.Logger) error {
|
||||||
config.Producer.Return.Successes = true
|
cfg.Producer.Return.Successes = true
|
||||||
config.Producer.Idempotent = k.IdempotentWrites
|
cfg.Producer.Idempotent = k.IdempotentWrites
|
||||||
config.Producer.Retry.Max = k.MaxRetry
|
cfg.Producer.Retry.Max = k.MaxRetry
|
||||||
if k.MaxMessageBytes > 0 {
|
if k.MaxMessageBytes > 0 {
|
||||||
config.Producer.MaxMessageBytes = k.MaxMessageBytes
|
cfg.Producer.MaxMessageBytes = k.MaxMessageBytes
|
||||||
}
|
}
|
||||||
config.Producer.RequiredAcks = sarama.RequiredAcks(k.RequiredAcks)
|
cfg.Producer.RequiredAcks = sarama.RequiredAcks(k.RequiredAcks)
|
||||||
if config.Producer.Idempotent {
|
if cfg.Producer.Idempotent {
|
||||||
config.Net.MaxOpenRequests = 1
|
cfg.Net.MaxOpenRequests = 1
|
||||||
}
|
}
|
||||||
return k.Config.SetConfig(config, log)
|
return k.Config.SetConfig(cfg, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config common to all Kafka clients.
|
// Config common to all Kafka clients.
|
||||||
|
|
@ -59,12 +58,12 @@ type Config struct {
|
||||||
ClientID string `toml:"client_id"`
|
ClientID string `toml:"client_id"`
|
||||||
CompressionCodec int `toml:"compression_codec"`
|
CompressionCodec int `toml:"compression_codec"`
|
||||||
EnableTLS *bool `toml:"enable_tls"`
|
EnableTLS *bool `toml:"enable_tls"`
|
||||||
KeepAlivePeriod *tgConf.Duration `toml:"keep_alive_period"`
|
KeepAlivePeriod *config.Duration `toml:"keep_alive_period"`
|
||||||
|
|
||||||
MetadataRetryMax int `toml:"metadata_retry_max"`
|
MetadataRetryMax int `toml:"metadata_retry_max"`
|
||||||
MetadataRetryType string `toml:"metadata_retry_type"`
|
MetadataRetryType string `toml:"metadata_retry_type"`
|
||||||
MetadataRetryBackoff tgConf.Duration `toml:"metadata_retry_backoff"`
|
MetadataRetryBackoff config.Duration `toml:"metadata_retry_backoff"`
|
||||||
MetadataRetryMaxDuration tgConf.Duration `toml:"metadata_retry_max_duration"`
|
MetadataRetryMaxDuration config.Duration `toml:"metadata_retry_max_duration"`
|
||||||
|
|
||||||
// Disable full metadata fetching
|
// Disable full metadata fetching
|
||||||
MetadataFull *bool `toml:"metadata_full"`
|
MetadataFull *bool `toml:"metadata_full"`
|
||||||
|
|
@ -83,26 +82,26 @@ func makeBackoffFunc(backoff, maxDuration time.Duration) BackoffFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetConfig on the sarama.Config object from the Config struct.
|
// SetConfig on the sarama.Config object from the Config struct.
|
||||||
func (k *Config) SetConfig(config *sarama.Config, log telegraf.Logger) error {
|
func (k *Config) SetConfig(cfg *sarama.Config, log telegraf.Logger) error {
|
||||||
if k.Version != "" {
|
if k.Version != "" {
|
||||||
version, err := sarama.ParseKafkaVersion(k.Version)
|
version, err := sarama.ParseKafkaVersion(k.Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Version = version
|
cfg.Version = version
|
||||||
}
|
}
|
||||||
|
|
||||||
if k.ClientID != "" {
|
if k.ClientID != "" {
|
||||||
config.ClientID = k.ClientID
|
cfg.ClientID = k.ClientID
|
||||||
} else {
|
} else {
|
||||||
config.ClientID = "Telegraf"
|
cfg.ClientID = "Telegraf"
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Producer.Compression = sarama.CompressionCodec(k.CompressionCodec)
|
cfg.Producer.Compression = sarama.CompressionCodec(k.CompressionCodec)
|
||||||
|
|
||||||
if k.EnableTLS != nil && *k.EnableTLS {
|
if k.EnableTLS != nil && *k.EnableTLS {
|
||||||
config.Net.TLS.Enable = true
|
cfg.Net.TLS.Enable = true
|
||||||
}
|
}
|
||||||
|
|
||||||
tlsConfig, err := k.ClientConfig.TLSConfig()
|
tlsConfig, err := k.ClientConfig.TLSConfig()
|
||||||
|
|
@ -111,33 +110,33 @@ func (k *Config) SetConfig(config *sarama.Config, log telegraf.Logger) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if tlsConfig != nil {
|
if tlsConfig != nil {
|
||||||
config.Net.TLS.Config = tlsConfig
|
cfg.Net.TLS.Config = tlsConfig
|
||||||
|
|
||||||
// To maintain backwards compatibility, if the enable_tls option is not
|
// To maintain backwards compatibility, if the enable_tls option is not
|
||||||
// set TLS is enabled if a non-default TLS config is used.
|
// set TLS is enabled if a non-default TLS config is used.
|
||||||
if k.EnableTLS == nil {
|
if k.EnableTLS == nil {
|
||||||
config.Net.TLS.Enable = true
|
cfg.Net.TLS.Enable = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if k.KeepAlivePeriod != nil {
|
if k.KeepAlivePeriod != nil {
|
||||||
// Defaults to OS setting (15s currently)
|
// Defaults to OS setting (15s currently)
|
||||||
config.Net.KeepAlive = time.Duration(*k.KeepAlivePeriod)
|
cfg.Net.KeepAlive = time.Duration(*k.KeepAlivePeriod)
|
||||||
}
|
}
|
||||||
|
|
||||||
if k.MetadataFull != nil {
|
if k.MetadataFull != nil {
|
||||||
// Defaults to true in Sarama
|
// Defaults to true in Sarama
|
||||||
config.Metadata.Full = *k.MetadataFull
|
cfg.Metadata.Full = *k.MetadataFull
|
||||||
}
|
}
|
||||||
|
|
||||||
if k.MetadataRetryMax != 0 {
|
if k.MetadataRetryMax != 0 {
|
||||||
config.Metadata.Retry.Max = k.MetadataRetryMax
|
cfg.Metadata.Retry.Max = k.MetadataRetryMax
|
||||||
}
|
}
|
||||||
|
|
||||||
if k.MetadataRetryBackoff != 0 {
|
if k.MetadataRetryBackoff != 0 {
|
||||||
// If config.Metadata.Retry.BackoffFunc is set, sarama ignores
|
// If cfg.Metadata.Retry.BackoffFunc is set, sarama ignores
|
||||||
// config.Metadata.Retry.Backoff
|
// cfg.Metadata.Retry.Backoff
|
||||||
config.Metadata.Retry.Backoff = time.Duration(k.MetadataRetryBackoff)
|
cfg.Metadata.Retry.Backoff = time.Duration(k.MetadataRetryBackoff)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch strings.ToLower(k.MetadataRetryType) {
|
switch strings.ToLower(k.MetadataRetryType) {
|
||||||
|
|
@ -145,15 +144,15 @@ func (k *Config) SetConfig(config *sarama.Config, log telegraf.Logger) error {
|
||||||
return errors.New("invalid metadata retry type")
|
return errors.New("invalid metadata retry type")
|
||||||
case "exponential":
|
case "exponential":
|
||||||
if k.MetadataRetryBackoff == 0 {
|
if k.MetadataRetryBackoff == 0 {
|
||||||
k.MetadataRetryBackoff = tgConf.Duration(250 * time.Millisecond)
|
k.MetadataRetryBackoff = config.Duration(250 * time.Millisecond)
|
||||||
log.Warnf("metadata_retry_backoff is 0, using %s", time.Duration(k.MetadataRetryBackoff))
|
log.Warnf("metadata_retry_backoff is 0, using %s", time.Duration(k.MetadataRetryBackoff))
|
||||||
}
|
}
|
||||||
config.Metadata.Retry.BackoffFunc = makeBackoffFunc(
|
cfg.Metadata.Retry.BackoffFunc = makeBackoffFunc(
|
||||||
time.Duration(k.MetadataRetryBackoff),
|
time.Duration(k.MetadataRetryBackoff),
|
||||||
time.Duration(k.MetadataRetryMaxDuration),
|
time.Duration(k.MetadataRetryMaxDuration),
|
||||||
)
|
)
|
||||||
case "constant", "":
|
case "constant", "":
|
||||||
}
|
}
|
||||||
|
|
||||||
return k.SetSASLConfig(config)
|
return k.SetSASLConfig(cfg)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,12 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
netProxy "golang.org/x/net/proxy"
|
"golang.org/x/net/proxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
// httpConnectProxy proxies (only?) TCP over a HTTP tunnel using the CONNECT method
|
// httpConnectProxy proxies (only?) TCP over a HTTP tunnel using the CONNECT method
|
||||||
type httpConnectProxy struct {
|
type httpConnectProxy struct {
|
||||||
forward netProxy.Dialer
|
forward proxy.Dialer
|
||||||
url *url.URL
|
url *url.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,7 +25,7 @@ func (c *httpConnectProxy) DialContext(ctx context.Context, network, addr string
|
||||||
|
|
||||||
var proxyConn net.Conn
|
var proxyConn net.Conn
|
||||||
var err error
|
var err error
|
||||||
if dialer, ok := c.forward.(netProxy.ContextDialer); ok {
|
if dialer, ok := c.forward.(proxy.ContextDialer); ok {
|
||||||
proxyConn, err = dialer.DialContext(ctx, "tcp", c.url.Host)
|
proxyConn, err = dialer.DialContext(ctx, "tcp", c.url.Host)
|
||||||
} else {
|
} else {
|
||||||
shim := contextDialerShim{c.forward}
|
shim := contextDialerShim{c.forward}
|
||||||
|
|
@ -93,14 +93,14 @@ func (c *httpConnectProxy) Dial(network, addr string) (net.Conn, error) {
|
||||||
return c.DialContext(context.Background(), network, addr)
|
return c.DialContext(context.Background(), network, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newHTTPConnectProxy(proxyURL *url.URL, forward netProxy.Dialer) (netProxy.Dialer, error) {
|
func newHTTPConnectProxy(proxyURL *url.URL, forward proxy.Dialer) (proxy.Dialer, error) {
|
||||||
return &httpConnectProxy{forward, proxyURL}, nil
|
return &httpConnectProxy{forward, proxyURL}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Register new proxy types
|
// Register new proxy types
|
||||||
netProxy.RegisterDialerType("http", newHTTPConnectProxy)
|
proxy.RegisterDialerType("http", newHTTPConnectProxy)
|
||||||
netProxy.RegisterDialerType("https", newHTTPConnectProxy)
|
proxy.RegisterDialerType("https", newHTTPConnectProxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// contextDialerShim allows cancellation of the dial from a context even if the underlying
|
// contextDialerShim allows cancellation of the dial from a context even if the underlying
|
||||||
|
|
@ -108,7 +108,7 @@ func init() {
|
||||||
// unless a new proxy type is added that doesn't implement `proxy.ContextDialer`, as all the
|
// unless a new proxy type is added that doesn't implement `proxy.ContextDialer`, as all the
|
||||||
// standard library dialers implement `proxy.ContextDialer`.
|
// standard library dialers implement `proxy.ContextDialer`.
|
||||||
type contextDialerShim struct {
|
type contextDialerShim struct {
|
||||||
dialer netProxy.Dialer
|
dialer proxy.Dialer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cd *contextDialerShim) Dial(network, addr string) (net.Conn, error) {
|
func (cd *contextDialerShim) Dial(network, addr string) (net.Conn, error) {
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
netProxy "golang.org/x/net/proxy"
|
"golang.org/x/net/proxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProxiedDialer struct {
|
type ProxiedDialer struct {
|
||||||
dialer netProxy.Dialer
|
dialer proxy.Dialer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pd *ProxiedDialer) Dial(network, addr string) (net.Conn, error) {
|
func (pd *ProxiedDialer) Dial(network, addr string) (net.Conn, error) {
|
||||||
|
|
@ -17,7 +17,7 @@ func (pd *ProxiedDialer) Dial(network, addr string) (net.Conn, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pd *ProxiedDialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
|
func (pd *ProxiedDialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
if contextDialer, ok := pd.dialer.(netProxy.ContextDialer); ok {
|
if contextDialer, ok := pd.dialer.(proxy.ContextDialer); ok {
|
||||||
return contextDialer.DialContext(ctx, network, addr)
|
return contextDialer.DialContext(ctx, network, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
tgConfig "github.com/influxdata/telegraf/config"
|
cfg "github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
)
|
)
|
||||||
|
|
@ -61,8 +61,8 @@ func TestLoadingProcessorWithConfig(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type testDurationInput struct {
|
type testDurationInput struct {
|
||||||
Duration tgConfig.Duration `toml:"duration"`
|
Duration cfg.Duration `toml:"duration"`
|
||||||
Size tgConfig.Size `toml:"size"`
|
Size cfg.Size `toml:"size"`
|
||||||
Hex int64 `toml:"hex"`
|
Hex int64 `toml:"hex"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
||||||
influxSerializer "github.com/influxdata/telegraf/plugins/serializers/influx"
|
serializers_influx "github.com/influxdata/telegraf/plugins/serializers/influx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProcessorShim(t *testing.T) {
|
func TestProcessorShim(t *testing.T) {
|
||||||
|
|
@ -52,7 +52,7 @@ func testSendAndReceive(t *testing.T, fieldKey string, fieldValue string) {
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
serializer := &influxSerializer.Serializer{}
|
serializer := &serializers_influx.Serializer{}
|
||||||
require.NoError(t, serializer.Init())
|
require.NoError(t, serializer.Init())
|
||||||
|
|
||||||
parser := influx.Parser{}
|
parser := influx.Parser{}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CallbackData func(net.Addr, []byte)
|
type CallbackData func(net.Addr, []byte)
|
||||||
|
|
@ -34,7 +34,7 @@ type Config struct {
|
||||||
SocketMode string `toml:"socket_mode"`
|
SocketMode string `toml:"socket_mode"`
|
||||||
ContentEncoding string `toml:"content_encoding"`
|
ContentEncoding string `toml:"content_encoding"`
|
||||||
MaxDecompressionSize config.Size `toml:"max_decompression_size"`
|
MaxDecompressionSize config.Size `toml:"max_decompression_size"`
|
||||||
tlsint.ServerConfig
|
common_tls.ServerConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type Socket struct {
|
type Socket struct {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import (
|
||||||
as "github.com/aerospike/aerospike-client-go/v5"
|
as "github.com/aerospike/aerospike-client-go/v5"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ type Aerospike struct {
|
||||||
EnableTLS bool `toml:"enable_tls"`
|
EnableTLS bool `toml:"enable_tls"`
|
||||||
EnableSSL bool `toml:"enable_ssl" deprecated:"1.7.0;1.35.0;use 'enable_tls' instead"`
|
EnableSSL bool `toml:"enable_ssl" deprecated:"1.7.0;1.35.0;use 'enable_tls' instead"`
|
||||||
TLSName string `toml:"tls_name"`
|
TLSName string `toml:"tls_name"`
|
||||||
tlsint.ClientConfig
|
common_tls.ClientConfig
|
||||||
|
|
||||||
initialized bool
|
initialized bool
|
||||||
tlsConfig *tls.Config
|
tlsConfig *tls.Config
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
apcupsdClient "github.com/mdlayher/apcupsd"
|
"github.com/mdlayher/apcupsd"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
|
|
@ -97,8 +97,8 @@ func (h *ApcUpsd) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchStatus(ctx context.Context, addr *url.URL) (*apcupsdClient.Status, error) {
|
func fetchStatus(ctx context.Context, addr *url.URL) (*apcupsd.Status, error) {
|
||||||
client, err := apcupsdClient.DialContext(ctx, addr.Scheme, addr.Host)
|
client, err := apcupsd.DialContext(ctx, addr.Scheme, addr.Host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ package azure_monitor
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
|
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
|
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
|
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
|
||||||
"github.com/influxdata/toml"
|
"github.com/influxdata/toml"
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/influxdata/telegraf/internal/choice"
|
"github.com/influxdata/telegraf/internal/choice"
|
||||||
"github.com/influxdata/telegraf/plugins/common/tls"
|
"github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
jsonparser "github.com/influxdata/telegraf/plugins/parsers/json"
|
parsers_json "github.com/influxdata/telegraf/plugins/parsers/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed sample.conf
|
//go:embed sample.conf
|
||||||
|
|
@ -180,7 +180,7 @@ func (beat *Beat) Gather(accumulator telegraf.Accumulator) error {
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unknown stats-type %q", name)
|
return fmt.Errorf("unknown stats-type %q", name)
|
||||||
}
|
}
|
||||||
flattener := jsonparser.JSONFlattener{}
|
flattener := parsers_json.JSONFlattener{}
|
||||||
err := flattener.FullFlattenJSON("", stats, true, true)
|
err := flattener.FullFlattenJSON("", stats, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
dialout "github.com/cisco-ie/nx-telemetry-proto/mdt_dialout"
|
mdtdialout "github.com/cisco-ie/nx-telemetry-proto/mdt_dialout"
|
||||||
telemetry "github.com/cisco-ie/nx-telemetry-proto/telemetry_bis"
|
telemetry "github.com/cisco-ie/nx-telemetry-proto/telemetry_bis"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
|
|
@ -28,7 +28,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
internaltls "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ type CiscoTelemetryMDT struct {
|
||||||
Log telegraf.Logger
|
Log telegraf.Logger
|
||||||
|
|
||||||
// GRPC TLS settings
|
// GRPC TLS settings
|
||||||
internaltls.ServerConfig
|
common_tls.ServerConfig
|
||||||
|
|
||||||
// Internal listener / client handle
|
// Internal listener / client handle
|
||||||
grpcServer *grpc.Server
|
grpcServer *grpc.Server
|
||||||
|
|
@ -83,7 +83,7 @@ type CiscoTelemetryMDT struct {
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
// Though unused in the code, required by protoc-gen-go-grpc to maintain compatibility
|
// Though unused in the code, required by protoc-gen-go-grpc to maintain compatibility
|
||||||
dialout.UnimplementedGRPCMdtDialoutServer
|
mdtdialout.UnimplementedGRPCMdtDialoutServer
|
||||||
}
|
}
|
||||||
|
|
||||||
type NxPayloadXfromStructure struct {
|
type NxPayloadXfromStructure struct {
|
||||||
|
|
@ -200,7 +200,7 @@ func (c *CiscoTelemetryMDT) Start(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
c.grpcServer = grpc.NewServer(opts...)
|
c.grpcServer = grpc.NewServer(opts...)
|
||||||
dialout.RegisterGRPCMdtDialoutServer(c.grpcServer, c)
|
mdtdialout.RegisterGRPCMdtDialoutServer(c.grpcServer, c)
|
||||||
|
|
||||||
c.wg.Add(1)
|
c.wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
|
@ -312,7 +312,7 @@ func (c *CiscoTelemetryMDT) handleTCPClient(conn net.Conn) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MdtDialout RPC server method for grpc-dialout transport
|
// MdtDialout RPC server method for grpc-dialout transport
|
||||||
func (c *CiscoTelemetryMDT) MdtDialout(stream dialout.GRPCMdtDialout_MdtDialoutServer) error {
|
func (c *CiscoTelemetryMDT) MdtDialout(stream mdtdialout.GRPCMdtDialout_MdtDialoutServer) error {
|
||||||
peerInCtx, peerOK := peer.FromContext(stream.Context())
|
peerInCtx, peerOK := peer.FromContext(stream.Context())
|
||||||
if peerOK {
|
if peerOK {
|
||||||
c.Log.Debugf("Accepted Cisco MDT GRPC dialout connection from %s", peerInCtx.Addr)
|
c.Log.Debugf("Accepted Cisco MDT GRPC dialout connection from %s", peerInCtx.Addr)
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
dialout "github.com/cisco-ie/nx-telemetry-proto/mdt_dialout"
|
mdtdialout "github.com/cisco-ie/nx-telemetry-proto/mdt_dialout"
|
||||||
telemetryBis "github.com/cisco-ie/nx-telemetry-proto/telemetry_bis"
|
telemetry "github.com/cisco-ie/nx-telemetry-proto/telemetry_bis"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/connectivity"
|
"google.golang.org/grpc/connectivity"
|
||||||
|
|
@ -36,55 +36,55 @@ func TestHandleTelemetryTwoSimple(t *testing.T) {
|
||||||
// error is expected since we are passing in dummy transport
|
// error is expected since we are passing in dummy transport
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
telemetry := &telemetryBis.Telemetry{
|
tel := &telemetry.Telemetry{
|
||||||
MsgTimestamp: 1543236572000,
|
MsgTimestamp: 1543236572000,
|
||||||
EncodingPath: "type:model/some/path",
|
EncodingPath: "type:model/some/path",
|
||||||
NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
NodeId: &telemetry.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
||||||
Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
Subscription: &telemetry.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
||||||
DataGpbkv: []*telemetryBis.TelemetryField{
|
DataGpbkv: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "keys",
|
Name: "keys",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "str"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "str"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "uint64",
|
Name: "uint64",
|
||||||
ValueByType: &telemetryBis.TelemetryField_Uint64Value{Uint64Value: 1234},
|
ValueByType: &telemetry.TelemetryField_Uint64Value{Uint64Value: 1234},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "content",
|
Name: "content",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "bool",
|
Name: "bool",
|
||||||
ValueByType: &telemetryBis.TelemetryField_BoolValue{BoolValue: true},
|
ValueByType: &telemetry.TelemetryField_BoolValue{BoolValue: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "keys",
|
Name: "keys",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "str2"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "str2"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "content",
|
Name: "content",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "bool",
|
Name: "bool",
|
||||||
ValueByType: &telemetryBis.TelemetryField_BoolValue{BoolValue: false},
|
ValueByType: &telemetry.TelemetryField_BoolValue{BoolValue: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -92,7 +92,7 @@ func TestHandleTelemetryTwoSimple(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
data, err := proto.Marshal(telemetry)
|
data, err := proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
c.handleTelemetry(data)
|
c.handleTelemetry(data)
|
||||||
|
|
@ -142,55 +142,55 @@ func TestIncludeDeleteField(t *testing.T) {
|
||||||
stateKey := "state"
|
stateKey := "state"
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
telemetry *telemetryBis.Telemetry
|
telemetry *telemetry.Telemetry
|
||||||
expected []telegraf.Metric
|
expected []telegraf.Metric
|
||||||
}{{
|
}{{
|
||||||
telemetry: &telemetryBis.Telemetry{
|
telemetry: &telemetry.Telemetry{
|
||||||
MsgTimestamp: 1543236572000,
|
MsgTimestamp: 1543236572000,
|
||||||
EncodingPath: encodingPath.stringValue,
|
EncodingPath: encodingPath.stringValue,
|
||||||
NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: source.stringValue},
|
NodeId: &telemetry.Telemetry_NodeIdStr{NodeIdStr: source.stringValue},
|
||||||
Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: subscription.stringValue},
|
Subscription: &telemetry.Telemetry_SubscriptionIdStr{SubscriptionIdStr: subscription.stringValue},
|
||||||
DataGpbkv: []*telemetryBis.TelemetryField{
|
DataGpbkv: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "keys",
|
Name: "keys",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: name.name,
|
Name: name.name,
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: name.stringValue},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: name.stringValue},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: index.name,
|
Name: index.name,
|
||||||
ValueByType: &telemetryBis.TelemetryField_Uint32Value{Uint32Value: index.uint32Value},
|
ValueByType: &telemetry.TelemetryField_Uint32Value{Uint32Value: index.uint32Value},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: ip.name,
|
Name: ip.name,
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: ip.stringValue},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: ip.stringValue},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "content",
|
Name: "content",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: stateKey,
|
Name: stateKey,
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: ip.name,
|
Name: ip.name,
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: ip.stringValue},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: ip.stringValue},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: prefixLength.name,
|
Name: prefixLength.name,
|
||||||
ValueByType: &telemetryBis.TelemetryField_Uint32Value{Uint32Value: prefixLength.uint32Value},
|
ValueByType: &telemetry.TelemetryField_Uint32Value{Uint32Value: prefixLength.uint32Value},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: origin.name,
|
Name: origin.name,
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: origin.stringValue},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: origin.stringValue},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: status.name,
|
Name: status.name,
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: status.stringValue},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: status.stringValue},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -222,29 +222,29 @@ func TestIncludeDeleteField(t *testing.T) {
|
||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
telemetry: &telemetryBis.Telemetry{
|
telemetry: &telemetry.Telemetry{
|
||||||
MsgTimestamp: 1543236572000,
|
MsgTimestamp: 1543236572000,
|
||||||
EncodingPath: encodingPath.stringValue,
|
EncodingPath: encodingPath.stringValue,
|
||||||
NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: source.stringValue},
|
NodeId: &telemetry.Telemetry_NodeIdStr{NodeIdStr: source.stringValue},
|
||||||
Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: subscription.stringValue},
|
Subscription: &telemetry.Telemetry_SubscriptionIdStr{SubscriptionIdStr: subscription.stringValue},
|
||||||
DataGpbkv: []*telemetryBis.TelemetryField{
|
DataGpbkv: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Delete: true,
|
Delete: true,
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "keys",
|
Name: "keys",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: name.name,
|
Name: name.name,
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: name.stringValue},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: name.stringValue},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: index.name,
|
Name: index.name,
|
||||||
ValueByType: &telemetryBis.TelemetryField_Uint32Value{Uint32Value: index.uint32Value},
|
ValueByType: &telemetry.TelemetryField_Uint32Value{Uint32Value: index.uint32Value},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: ip.name,
|
Name: ip.name,
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: ip.stringValue},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: ip.stringValue},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -299,26 +299,26 @@ func TestHandleTelemetrySingleNested(t *testing.T) {
|
||||||
// error is expected since we are passing in dummy transport
|
// error is expected since we are passing in dummy transport
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
telemetry := &telemetryBis.Telemetry{
|
tel := &telemetry.Telemetry{
|
||||||
MsgTimestamp: 1543236572000,
|
MsgTimestamp: 1543236572000,
|
||||||
EncodingPath: "type:model/nested/path",
|
EncodingPath: "type:model/nested/path",
|
||||||
NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
NodeId: &telemetry.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
||||||
Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
Subscription: &telemetry.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
||||||
DataGpbkv: []*telemetryBis.TelemetryField{
|
DataGpbkv: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "keys",
|
Name: "keys",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "nested",
|
Name: "nested",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "key",
|
Name: "key",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "level",
|
Name: "level",
|
||||||
ValueByType: &telemetryBis.TelemetryField_DoubleValue{DoubleValue: 3},
|
ValueByType: &telemetry.TelemetryField_DoubleValue{DoubleValue: 3},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -328,16 +328,16 @@ func TestHandleTelemetrySingleNested(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "content",
|
Name: "content",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "nested",
|
Name: "nested",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "value",
|
Name: "value",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -349,7 +349,7 @@ func TestHandleTelemetrySingleNested(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
data, err := proto.Marshal(telemetry)
|
data, err := proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
c.handleTelemetry(data)
|
c.handleTelemetry(data)
|
||||||
|
|
@ -376,49 +376,49 @@ func TestHandleEmbeddedTags(t *testing.T) {
|
||||||
// error is expected since we are passing in dummy transport
|
// error is expected since we are passing in dummy transport
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
telemetry := &telemetryBis.Telemetry{
|
tel := &telemetry.Telemetry{
|
||||||
MsgTimestamp: 1543236572000,
|
MsgTimestamp: 1543236572000,
|
||||||
EncodingPath: "type:model/extra",
|
EncodingPath: "type:model/extra",
|
||||||
NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
NodeId: &telemetry.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
||||||
Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
Subscription: &telemetry.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
||||||
DataGpbkv: []*telemetryBis.TelemetryField{
|
DataGpbkv: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "keys",
|
Name: "keys",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "content",
|
Name: "content",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "list",
|
Name: "list",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "entry1"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "entry1"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "test",
|
Name: "test",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "foo"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "foo"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "list",
|
Name: "list",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "entry2"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "entry2"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "test",
|
Name: "test",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -428,7 +428,7 @@ func TestHandleEmbeddedTags(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
data, err := proto.Marshal(telemetry)
|
data, err := proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
c.handleTelemetry(data)
|
c.handleTelemetry(data)
|
||||||
|
|
@ -464,57 +464,57 @@ func TestHandleNXAPI(t *testing.T) {
|
||||||
// error is expected since we are passing in dummy transport
|
// error is expected since we are passing in dummy transport
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
telemetry := &telemetryBis.Telemetry{
|
tel := &telemetry.Telemetry{
|
||||||
MsgTimestamp: 1543236572000,
|
MsgTimestamp: 1543236572000,
|
||||||
EncodingPath: "show nxapi",
|
EncodingPath: "show nxapi",
|
||||||
NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
NodeId: &telemetry.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
||||||
Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
Subscription: &telemetry.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
||||||
DataGpbkv: []*telemetryBis.TelemetryField{
|
DataGpbkv: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "keys",
|
Name: "keys",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "content",
|
Name: "content",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "TABLE_nxapi",
|
Name: "TABLE_nxapi",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "ROW_nxapi",
|
Name: "ROW_nxapi",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "index",
|
Name: "index",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "i1"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "i1"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "value",
|
Name: "value",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "foo"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "foo"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "index",
|
Name: "index",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "i2"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "i2"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "value",
|
Name: "value",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -532,7 +532,7 @@ func TestHandleNXAPI(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
data, err := proto.Marshal(telemetry)
|
data, err := proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
c.handleTelemetry(data)
|
c.handleTelemetry(data)
|
||||||
|
|
@ -571,45 +571,45 @@ func TestHandleNXAPIXformNXAPI(t *testing.T) {
|
||||||
// error is expected since we are passing in dummy transport
|
// error is expected since we are passing in dummy transport
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
telemetry := &telemetryBis.Telemetry{
|
tel := &telemetry.Telemetry{
|
||||||
MsgTimestamp: 1543236572000,
|
MsgTimestamp: 1543236572000,
|
||||||
EncodingPath: "show processes cpu",
|
EncodingPath: "show processes cpu",
|
||||||
NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
NodeId: &telemetry.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
||||||
Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
Subscription: &telemetry.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
||||||
DataGpbkv: []*telemetryBis.TelemetryField{
|
DataGpbkv: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "keys",
|
Name: "keys",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "content",
|
Name: "content",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "TABLE_process_cpu",
|
Name: "TABLE_process_cpu",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "ROW_process_cpu",
|
Name: "ROW_process_cpu",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "index",
|
Name: "index",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "i1"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "i1"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "value",
|
Name: "value",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "foo"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "foo"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -627,7 +627,7 @@ func TestHandleNXAPIXformNXAPI(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
data, err := proto.Marshal(telemetry)
|
data, err := proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
c.handleTelemetry(data)
|
c.handleTelemetry(data)
|
||||||
|
|
@ -655,57 +655,57 @@ func TestHandleNXXformMulti(t *testing.T) {
|
||||||
// error is expected since we are passing in dummy transport
|
// error is expected since we are passing in dummy transport
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
telemetry := &telemetryBis.Telemetry{
|
tel := &telemetry.Telemetry{
|
||||||
MsgTimestamp: 1543236572000,
|
MsgTimestamp: 1543236572000,
|
||||||
EncodingPath: "sys/lldp",
|
EncodingPath: "sys/lldp",
|
||||||
NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
NodeId: &telemetry.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
||||||
Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
Subscription: &telemetry.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
||||||
DataGpbkv: []*telemetryBis.TelemetryField{
|
DataGpbkv: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "keys",
|
Name: "keys",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "content",
|
Name: "content",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "fooEntity",
|
Name: "fooEntity",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "attributes",
|
Name: "attributes",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "rn",
|
Name: "rn",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "some-rn"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "some-rn"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "portIdV",
|
Name: "portIdV",
|
||||||
ValueByType: &telemetryBis.TelemetryField_Uint32Value{Uint32Value: 12},
|
ValueByType: &telemetry.TelemetryField_Uint32Value{Uint32Value: 12},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "portDesc",
|
Name: "portDesc",
|
||||||
ValueByType: &telemetryBis.TelemetryField_Uint64Value{Uint64Value: 100},
|
ValueByType: &telemetry.TelemetryField_Uint64Value{Uint64Value: 100},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "test",
|
Name: "test",
|
||||||
ValueByType: &telemetryBis.TelemetryField_Uint64Value{Uint64Value: 281474976710655},
|
ValueByType: &telemetry.TelemetryField_Uint64Value{Uint64Value: 281474976710655},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "subscriptionId",
|
Name: "subscriptionId",
|
||||||
ValueByType: &telemetryBis.TelemetryField_Uint64Value{Uint64Value: 2814749767106551},
|
ValueByType: &telemetry.TelemetryField_Uint64Value{Uint64Value: 2814749767106551},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -723,7 +723,7 @@ func TestHandleNXXformMulti(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
data, err := proto.Marshal(telemetry)
|
data, err := proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
c.handleTelemetry(data)
|
c.handleTelemetry(data)
|
||||||
|
|
@ -748,45 +748,45 @@ func TestHandleNXDME(t *testing.T) {
|
||||||
// error is expected since we are passing in dummy transport
|
// error is expected since we are passing in dummy transport
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
telemetry := &telemetryBis.Telemetry{
|
tel := &telemetry.Telemetry{
|
||||||
MsgTimestamp: 1543236572000,
|
MsgTimestamp: 1543236572000,
|
||||||
EncodingPath: "sys/dme",
|
EncodingPath: "sys/dme",
|
||||||
NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
NodeId: &telemetry.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
||||||
Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
Subscription: &telemetry.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
||||||
DataGpbkv: []*telemetryBis.TelemetryField{
|
DataGpbkv: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "keys",
|
Name: "keys",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "bar"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "content",
|
Name: "content",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "fooEntity",
|
Name: "fooEntity",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "attributes",
|
Name: "attributes",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "rn",
|
Name: "rn",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "some-rn"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "some-rn"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "value",
|
Name: "value",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "foo"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "foo"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -804,7 +804,7 @@ func TestHandleNXDME(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
data, err := proto.Marshal(telemetry)
|
data, err := proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
c.handleTelemetry(data)
|
c.handleTelemetry(data)
|
||||||
|
|
@ -852,13 +852,13 @@ func TestTCPDialoutOverflow(t *testing.T) {
|
||||||
require.Contains(t, acc.Errors, errors.New("dialout packet too long: 1000000000"))
|
require.Contains(t, acc.Errors, errors.New("dialout packet too long: 1000000000"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func mockTelemetryMicroburstMessage() *telemetryBis.Telemetry {
|
func mockTelemetryMicroburstMessage() *telemetry.Telemetry {
|
||||||
data, err := os.ReadFile("./testdata/microburst")
|
data, err := os.ReadFile("./testdata/microburst")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
newMessage := &telemetryBis.Telemetry{}
|
newMessage := &telemetry.Telemetry{}
|
||||||
err = proto.Unmarshal(data, newMessage)
|
err = proto.Unmarshal(data, newMessage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
@ -866,30 +866,30 @@ func mockTelemetryMicroburstMessage() *telemetryBis.Telemetry {
|
||||||
return newMessage
|
return newMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
func mockTelemetryMessage() *telemetryBis.Telemetry {
|
func mockTelemetryMessage() *telemetry.Telemetry {
|
||||||
return &telemetryBis.Telemetry{
|
return &telemetry.Telemetry{
|
||||||
MsgTimestamp: 1543236572000,
|
MsgTimestamp: 1543236572000,
|
||||||
EncodingPath: "type:model/some/path",
|
EncodingPath: "type:model/some/path",
|
||||||
NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
NodeId: &telemetry.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
||||||
Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
Subscription: &telemetry.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
||||||
DataGpbkv: []*telemetryBis.TelemetryField{
|
DataGpbkv: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "keys",
|
Name: "keys",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "str"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "str"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "content",
|
Name: "content",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "value",
|
Name: "value",
|
||||||
ValueByType: &telemetryBis.TelemetryField_Sint64Value{Sint64Value: -1},
|
ValueByType: &telemetry.TelemetryField_Sint64Value{Sint64Value: -1},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -914,8 +914,8 @@ func TestGRPCDialoutMicroburst(t *testing.T) {
|
||||||
err := c.Start(acc)
|
err := c.Start(acc)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
telemetry := mockTelemetryMicroburstMessage()
|
tel := mockTelemetryMicroburstMessage()
|
||||||
data, err := proto.Marshal(telemetry)
|
data, err := proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
c.handleTelemetry(data)
|
c.handleTelemetry(data)
|
||||||
|
|
@ -954,7 +954,7 @@ func TestTCPDialoutMultiple(t *testing.T) {
|
||||||
err := c.Start(acc)
|
err := c.Start(acc)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
telemetry := mockTelemetryMessage()
|
tel := mockTelemetryMessage()
|
||||||
|
|
||||||
hdr := struct {
|
hdr := struct {
|
||||||
MsgType uint16
|
MsgType uint16
|
||||||
|
|
@ -968,7 +968,7 @@ func TestTCPDialoutMultiple(t *testing.T) {
|
||||||
conn, err := net.Dial(addr.Network(), addr.String())
|
conn, err := net.Dial(addr.Network(), addr.String())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
data, err := proto.Marshal(telemetry)
|
data, err := proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
hdr.MsgLen = uint32(len(data))
|
hdr.MsgLen = uint32(len(data))
|
||||||
require.NoError(t, binary.Write(conn, binary.BigEndian, hdr))
|
require.NoError(t, binary.Write(conn, binary.BigEndian, hdr))
|
||||||
|
|
@ -978,8 +978,8 @@ func TestTCPDialoutMultiple(t *testing.T) {
|
||||||
conn2, err := net.Dial(addr.Network(), addr.String())
|
conn2, err := net.Dial(addr.Network(), addr.String())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
telemetry.EncodingPath = "type:model/parallel/path"
|
tel.EncodingPath = "type:model/parallel/path"
|
||||||
data, err = proto.Marshal(telemetry)
|
data, err = proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
hdr.MsgLen = uint32(len(data))
|
hdr.MsgLen = uint32(len(data))
|
||||||
require.NoError(t, binary.Write(conn2, binary.BigEndian, hdr))
|
require.NoError(t, binary.Write(conn2, binary.BigEndian, hdr))
|
||||||
|
|
@ -991,8 +991,8 @@ func TestTCPDialoutMultiple(t *testing.T) {
|
||||||
require.True(t, err == nil || errors.Is(err, io.EOF))
|
require.True(t, err == nil || errors.Is(err, io.EOF))
|
||||||
require.NoError(t, conn2.Close())
|
require.NoError(t, conn2.Close())
|
||||||
|
|
||||||
telemetry.EncodingPath = "type:model/other/path"
|
tel.EncodingPath = "type:model/other/path"
|
||||||
data, err = proto.Marshal(telemetry)
|
data, err = proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
hdr.MsgLen = uint32(len(data))
|
hdr.MsgLen = uint32(len(data))
|
||||||
require.NoError(t, binary.Write(conn, binary.BigEndian, hdr))
|
require.NoError(t, binary.Write(conn, binary.BigEndian, hdr))
|
||||||
|
|
@ -1049,11 +1049,11 @@ func TestGRPCDialoutError(t *testing.T) {
|
||||||
addr := c.Address()
|
addr := c.Address()
|
||||||
conn, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
conn, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
client := dialout.NewGRPCMdtDialoutClient(conn)
|
client := mdtdialout.NewGRPCMdtDialoutClient(conn)
|
||||||
stream, err := client.MdtDialout(context.Background())
|
stream, err := client.MdtDialout(context.Background())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
args := &dialout.MdtDialoutArgs{Errors: "foobar"}
|
args := &mdtdialout.MdtDialoutArgs{Errors: "foobar"}
|
||||||
require.NoError(t, stream.Send(args))
|
require.NoError(t, stream.Send(args))
|
||||||
|
|
||||||
// Wait for the server to close
|
// Wait for the server to close
|
||||||
|
|
@ -1078,44 +1078,44 @@ func TestGRPCDialoutMultiple(t *testing.T) {
|
||||||
acc := &testutil.Accumulator{}
|
acc := &testutil.Accumulator{}
|
||||||
err := c.Start(acc)
|
err := c.Start(acc)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
telemetry := mockTelemetryMessage()
|
tel := mockTelemetryMessage()
|
||||||
|
|
||||||
addr := c.Address()
|
addr := c.Address()
|
||||||
conn, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
conn, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, conn.WaitForStateChange(context.Background(), connectivity.Connecting))
|
require.True(t, conn.WaitForStateChange(context.Background(), connectivity.Connecting))
|
||||||
client := dialout.NewGRPCMdtDialoutClient(conn)
|
client := mdtdialout.NewGRPCMdtDialoutClient(conn)
|
||||||
stream, err := client.MdtDialout(context.TODO())
|
stream, err := client.MdtDialout(context.TODO())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
data, err := proto.Marshal(telemetry)
|
data, err := proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
args := &dialout.MdtDialoutArgs{Data: data, ReqId: 456}
|
args := &mdtdialout.MdtDialoutArgs{Data: data, ReqId: 456}
|
||||||
require.NoError(t, stream.Send(args))
|
require.NoError(t, stream.Send(args))
|
||||||
|
|
||||||
conn2, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
conn2, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, conn.WaitForStateChange(context.Background(), connectivity.Connecting))
|
require.True(t, conn.WaitForStateChange(context.Background(), connectivity.Connecting))
|
||||||
client2 := dialout.NewGRPCMdtDialoutClient(conn2)
|
client2 := mdtdialout.NewGRPCMdtDialoutClient(conn2)
|
||||||
stream2, err := client2.MdtDialout(context.TODO())
|
stream2, err := client2.MdtDialout(context.TODO())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
telemetry.EncodingPath = "type:model/parallel/path"
|
tel.EncodingPath = "type:model/parallel/path"
|
||||||
data, err = proto.Marshal(telemetry)
|
data, err = proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
args = &dialout.MdtDialoutArgs{Data: data}
|
args = &mdtdialout.MdtDialoutArgs{Data: data}
|
||||||
require.NoError(t, stream2.Send(args))
|
require.NoError(t, stream2.Send(args))
|
||||||
require.NoError(t, stream2.Send(&dialout.MdtDialoutArgs{Errors: "testclose"}))
|
require.NoError(t, stream2.Send(&mdtdialout.MdtDialoutArgs{Errors: "testclose"}))
|
||||||
_, err = stream2.Recv()
|
_, err = stream2.Recv()
|
||||||
require.True(t, err == nil || errors.Is(err, io.EOF))
|
require.True(t, err == nil || errors.Is(err, io.EOF))
|
||||||
require.NoError(t, conn2.Close())
|
require.NoError(t, conn2.Close())
|
||||||
|
|
||||||
telemetry.EncodingPath = "type:model/other/path"
|
tel.EncodingPath = "type:model/other/path"
|
||||||
data, err = proto.Marshal(telemetry)
|
data, err = proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
args = &dialout.MdtDialoutArgs{Data: data}
|
args = &mdtdialout.MdtDialoutArgs{Data: data}
|
||||||
require.NoError(t, stream.Send(args))
|
require.NoError(t, stream.Send(args))
|
||||||
require.NoError(t, stream.Send(&dialout.MdtDialoutArgs{Errors: "testclose"}))
|
require.NoError(t, stream.Send(&mdtdialout.MdtDialoutArgs{Errors: "testclose"}))
|
||||||
_, err = stream.Recv()
|
_, err = stream.Recv()
|
||||||
require.True(t, err == nil || errors.Is(err, io.EOF))
|
require.True(t, err == nil || errors.Is(err, io.EOF))
|
||||||
|
|
||||||
|
|
@ -1169,14 +1169,14 @@ func TestGRPCDialoutKeepalive(t *testing.T) {
|
||||||
addr := c.Address()
|
addr := c.Address()
|
||||||
conn, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
conn, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
client := dialout.NewGRPCMdtDialoutClient(conn)
|
client := mdtdialout.NewGRPCMdtDialoutClient(conn)
|
||||||
stream, err := client.MdtDialout(context.Background())
|
stream, err := client.MdtDialout(context.Background())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
telemetry := mockTelemetryMessage()
|
tel := mockTelemetryMessage()
|
||||||
data, err := proto.Marshal(telemetry)
|
data, err := proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
args := &dialout.MdtDialoutArgs{Data: data, ReqId: 456}
|
args := &mdtdialout.MdtDialoutArgs{Data: data, ReqId: 456}
|
||||||
require.NoError(t, stream.Send(args))
|
require.NoError(t, stream.Send(args))
|
||||||
|
|
||||||
c.Stop()
|
c.Stop()
|
||||||
|
|
@ -1195,29 +1195,29 @@ func TestSourceFieldRewrite(t *testing.T) {
|
||||||
// error is expected since we are passing in dummy transport
|
// error is expected since we are passing in dummy transport
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
telemetry := &telemetryBis.Telemetry{
|
tel := &telemetry.Telemetry{
|
||||||
MsgTimestamp: 1543236572000,
|
MsgTimestamp: 1543236572000,
|
||||||
EncodingPath: "type:model/some/path",
|
EncodingPath: "type:model/some/path",
|
||||||
NodeId: &telemetryBis.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
NodeId: &telemetry.Telemetry_NodeIdStr{NodeIdStr: "hostname"},
|
||||||
Subscription: &telemetryBis.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
Subscription: &telemetry.Telemetry_SubscriptionIdStr{SubscriptionIdStr: "subscription"},
|
||||||
DataGpbkv: []*telemetryBis.TelemetryField{
|
DataGpbkv: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "keys",
|
Name: "keys",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "source",
|
Name: "source",
|
||||||
ValueByType: &telemetryBis.TelemetryField_StringValue{StringValue: "str"},
|
ValueByType: &telemetry.TelemetryField_StringValue{StringValue: "str"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "content",
|
Name: "content",
|
||||||
Fields: []*telemetryBis.TelemetryField{
|
Fields: []*telemetry.TelemetryField{
|
||||||
{
|
{
|
||||||
Name: "bool",
|
Name: "bool",
|
||||||
ValueByType: &telemetryBis.TelemetryField_BoolValue{BoolValue: false},
|
ValueByType: &telemetry.TelemetryField_BoolValue{BoolValue: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -1225,7 +1225,7 @@ func TestSourceFieldRewrite(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
data, err := proto.Marshal(telemetry)
|
data, err := proto.Marshal(tel)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
c.handleTelemetry(data)
|
c.handleTelemetry(data)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
package cloud_pubsub
|
package cloud_pubsub
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cloud.google.com/go/pubsub"
|
|
||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"cloud.google.com/go/pubsub"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ type PubSubPush struct {
|
||||||
|
|
||||||
MaxUndeliveredMessages int `toml:"max_undelivered_messages"`
|
MaxUndeliveredMessages int `toml:"max_undelivered_messages"`
|
||||||
|
|
||||||
tlsint.ServerConfig
|
common_tls.ServerConfig
|
||||||
telegraf.Parser
|
telegraf.Parser
|
||||||
|
|
||||||
server *http.Server
|
server *http.Server
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/aws"
|
"github.com/aws/aws-sdk-go-v2/aws"
|
||||||
cwClient "github.com/aws/aws-sdk-go-v2/service/cloudwatch"
|
"github.com/aws/aws-sdk-go-v2/service/cloudwatch"
|
||||||
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
|
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -22,9 +22,9 @@ import (
|
||||||
"github.com/influxdata/telegraf/filter"
|
"github.com/influxdata/telegraf/filter"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/internal/limiter"
|
"github.com/influxdata/telegraf/internal/limiter"
|
||||||
internalMetric "github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
internalaws "github.com/influxdata/telegraf/plugins/common/aws"
|
common_aws "github.com/influxdata/telegraf/plugins/common/aws"
|
||||||
internalProxy "github.com/influxdata/telegraf/plugins/common/proxy"
|
"github.com/influxdata/telegraf/plugins/common/proxy"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ type CloudWatch struct {
|
||||||
StatisticInclude []string `toml:"statistic_include"`
|
StatisticInclude []string `toml:"statistic_include"`
|
||||||
Timeout config.Duration `toml:"timeout"`
|
Timeout config.Duration `toml:"timeout"`
|
||||||
|
|
||||||
internalProxy.HTTPProxy
|
proxy.HTTPProxy
|
||||||
|
|
||||||
Period config.Duration `toml:"period"`
|
Period config.Duration `toml:"period"`
|
||||||
Delay config.Duration `toml:"delay"`
|
Delay config.Duration `toml:"delay"`
|
||||||
|
|
@ -59,7 +59,7 @@ type CloudWatch struct {
|
||||||
windowStart time.Time
|
windowStart time.Time
|
||||||
windowEnd time.Time
|
windowEnd time.Time
|
||||||
|
|
||||||
internalaws.CredentialConfig
|
common_aws.CredentialConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metric defines a simplified Cloudwatch metric.
|
// Metric defines a simplified Cloudwatch metric.
|
||||||
|
|
@ -86,8 +86,8 @@ type metricCache struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type cloudwatchClient interface {
|
type cloudwatchClient interface {
|
||||||
ListMetrics(context.Context, *cwClient.ListMetricsInput, ...func(*cwClient.Options)) (*cwClient.ListMetricsOutput, error)
|
ListMetrics(context.Context, *cloudwatch.ListMetricsInput, ...func(*cloudwatch.Options)) (*cloudwatch.ListMetricsOutput, error)
|
||||||
GetMetricData(context.Context, *cwClient.GetMetricDataInput, ...func(*cwClient.Options)) (*cwClient.GetMetricDataOutput, error)
|
GetMetricData(context.Context, *cloudwatch.GetMetricDataInput, ...func(*cloudwatch.Options)) (*cloudwatch.GetMetricDataOutput, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*CloudWatch) SampleConfig() string {
|
func (*CloudWatch) SampleConfig() string {
|
||||||
|
|
@ -178,7 +178,7 @@ func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloudWatch) initializeCloudWatch() error {
|
func (c *CloudWatch) initializeCloudWatch() error {
|
||||||
proxy, err := c.HTTPProxy.Proxy()
|
proxyFunc, err := c.HTTPProxy.Proxy()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -188,7 +188,7 @@ func (c *CloudWatch) initializeCloudWatch() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
c.client = cwClient.NewFromConfig(awsCreds, func(options *cwClient.Options) {
|
c.client = cloudwatch.NewFromConfig(awsCreds, func(options *cloudwatch.Options) {
|
||||||
if c.CredentialConfig.EndpointURL != "" && c.CredentialConfig.Region != "" {
|
if c.CredentialConfig.EndpointURL != "" && c.CredentialConfig.Region != "" {
|
||||||
options.BaseEndpoint = &c.CredentialConfig.EndpointURL
|
options.BaseEndpoint = &c.CredentialConfig.EndpointURL
|
||||||
}
|
}
|
||||||
|
|
@ -197,7 +197,7 @@ func (c *CloudWatch) initializeCloudWatch() error {
|
||||||
options.HTTPClient = &http.Client{
|
options.HTTPClient = &http.Client{
|
||||||
// use values from DefaultTransport
|
// use values from DefaultTransport
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
Proxy: proxy,
|
Proxy: proxyFunc,
|
||||||
DialContext: (&net.Dialer{
|
DialContext: (&net.Dialer{
|
||||||
Timeout: 30 * time.Second,
|
Timeout: 30 * time.Second,
|
||||||
KeepAlive: 30 * time.Second,
|
KeepAlive: 30 * time.Second,
|
||||||
|
|
@ -271,13 +271,13 @@ func getFilteredMetrics(c *CloudWatch) ([]filteredMetric, error) {
|
||||||
allMetrics, allAccounts := c.fetchNamespaceMetrics()
|
allMetrics, allAccounts := c.fetchNamespaceMetrics()
|
||||||
|
|
||||||
for _, name := range m.MetricNames {
|
for _, name := range m.MetricNames {
|
||||||
for i, metric := range allMetrics {
|
for i, singleMetric := range allMetrics {
|
||||||
if isSelected(name, metric, m.Dimensions) {
|
if isSelected(name, singleMetric, m.Dimensions) {
|
||||||
for _, namespace := range c.Namespaces {
|
for _, namespace := range c.Namespaces {
|
||||||
metrics = append(metrics, types.Metric{
|
metrics = append(metrics, types.Metric{
|
||||||
Namespace: aws.String(namespace),
|
Namespace: aws.String(namespace),
|
||||||
MetricName: aws.String(name),
|
MetricName: aws.String(name),
|
||||||
Dimensions: metric.Dimensions,
|
Dimensions: singleMetric.Dimensions,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if c.IncludeLinkedAccounts {
|
if c.IncludeLinkedAccounts {
|
||||||
|
|
@ -327,7 +327,7 @@ func (c *CloudWatch) fetchNamespaceMetrics() ([]types.Metric, []string) {
|
||||||
metrics := []types.Metric{}
|
metrics := []types.Metric{}
|
||||||
var accounts []string
|
var accounts []string
|
||||||
for _, namespace := range c.Namespaces {
|
for _, namespace := range c.Namespaces {
|
||||||
params := &cwClient.ListMetricsInput{
|
params := &cloudwatch.ListMetricsInput{
|
||||||
Dimensions: []types.DimensionFilter{},
|
Dimensions: []types.DimensionFilter{},
|
||||||
Namespace: aws.String(namespace),
|
Namespace: aws.String(namespace),
|
||||||
IncludeLinkedAccounts: &c.IncludeLinkedAccounts,
|
IncludeLinkedAccounts: &c.IncludeLinkedAccounts,
|
||||||
|
|
@ -379,9 +379,9 @@ func (c *CloudWatch) getDataQueries(filteredMetrics []filteredMetric) map[string
|
||||||
|
|
||||||
dataQueries := map[string][]types.MetricDataQuery{}
|
dataQueries := map[string][]types.MetricDataQuery{}
|
||||||
for i, filtered := range filteredMetrics {
|
for i, filtered := range filteredMetrics {
|
||||||
for j, metric := range filtered.metrics {
|
for j, singleMetric := range filtered.metrics {
|
||||||
id := strconv.Itoa(j) + "_" + strconv.Itoa(i)
|
id := strconv.Itoa(j) + "_" + strconv.Itoa(i)
|
||||||
dimension := ctod(metric.Dimensions)
|
dimension := ctod(singleMetric.Dimensions)
|
||||||
var accountID *string
|
var accountID *string
|
||||||
if c.IncludeLinkedAccounts && len(filtered.accounts) > j {
|
if c.IncludeLinkedAccounts && len(filtered.accounts) > j {
|
||||||
accountID = aws.String(filtered.accounts[j])
|
accountID = aws.String(filtered.accounts[j])
|
||||||
|
|
@ -402,10 +402,10 @@ func (c *CloudWatch) getDataQueries(filteredMetrics []filteredMetric) map[string
|
||||||
}
|
}
|
||||||
queryID := statisticType + "_" + id
|
queryID := statisticType + "_" + id
|
||||||
c.queryDimensions[queryID] = dimension
|
c.queryDimensions[queryID] = dimension
|
||||||
dataQueries[*metric.Namespace] = append(dataQueries[*metric.Namespace], types.MetricDataQuery{
|
dataQueries[*singleMetric.Namespace] = append(dataQueries[*singleMetric.Namespace], types.MetricDataQuery{
|
||||||
Id: aws.String(queryID),
|
Id: aws.String(queryID),
|
||||||
AccountId: accountID,
|
AccountId: accountID,
|
||||||
Label: aws.String(snakeCase(*metric.MetricName + "_" + statisticType)),
|
Label: aws.String(snakeCase(*singleMetric.MetricName + "_" + statisticType)),
|
||||||
MetricStat: &types.MetricStat{
|
MetricStat: &types.MetricStat{
|
||||||
Metric: &filtered.metrics[j],
|
Metric: &filtered.metrics[j],
|
||||||
Period: aws.Int32(int32(time.Duration(c.Period).Seconds())),
|
Period: aws.Int32(int32(time.Duration(c.Period).Seconds())),
|
||||||
|
|
@ -436,7 +436,7 @@ func (c *CloudWatch) getDataQueries(filteredMetrics []filteredMetric) map[string
|
||||||
|
|
||||||
// gatherMetrics gets metric data from Cloudwatch.
|
// gatherMetrics gets metric data from Cloudwatch.
|
||||||
func (c *CloudWatch) gatherMetrics(
|
func (c *CloudWatch) gatherMetrics(
|
||||||
params *cwClient.GetMetricDataInput,
|
params *cloudwatch.GetMetricDataInput,
|
||||||
) ([]types.MetricDataResult, error) {
|
) ([]types.MetricDataResult, error) {
|
||||||
results := []types.MetricDataResult{}
|
results := []types.MetricDataResult{}
|
||||||
|
|
||||||
|
|
@ -457,7 +457,7 @@ func (c *CloudWatch) gatherMetrics(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloudWatch) aggregateMetrics(acc telegraf.Accumulator, metricDataResults map[string][]types.MetricDataResult) {
|
func (c *CloudWatch) aggregateMetrics(acc telegraf.Accumulator, metricDataResults map[string][]types.MetricDataResult) {
|
||||||
grouper := internalMetric.NewSeriesGrouper()
|
grouper := metric.NewSeriesGrouper()
|
||||||
for namespace, results := range metricDataResults {
|
for namespace, results := range metricDataResults {
|
||||||
namespace = sanitizeMeasurement(namespace)
|
namespace = sanitizeMeasurement(namespace)
|
||||||
|
|
||||||
|
|
@ -489,8 +489,8 @@ func (c *CloudWatch) aggregateMetrics(acc telegraf.Accumulator, metricDataResult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, metric := range grouper.Metrics() {
|
for _, singleMetric := range grouper.Metrics() {
|
||||||
acc.AddMetric(metric)
|
acc.AddMetric(singleMetric)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -532,8 +532,8 @@ func ctod(cDimensions []types.Dimension) *map[string]string {
|
||||||
return &dimensions
|
return &dimensions
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CloudWatch) getDataInputs(dataQueries []types.MetricDataQuery) *cwClient.GetMetricDataInput {
|
func (c *CloudWatch) getDataInputs(dataQueries []types.MetricDataQuery) *cloudwatch.GetMetricDataInput {
|
||||||
return &cwClient.GetMetricDataInput{
|
return &cloudwatch.GetMetricDataInput{
|
||||||
StartTime: aws.Time(c.windowStart),
|
StartTime: aws.Time(c.windowStart),
|
||||||
EndTime: aws.Time(c.windowEnd),
|
EndTime: aws.Time(c.windowEnd),
|
||||||
MetricDataQueries: dataQueries,
|
MetricDataQueries: dataQueries,
|
||||||
|
|
@ -554,16 +554,16 @@ func hasWildcard(dimensions []*Dimension) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func isSelected(name string, metric types.Metric, dimensions []*Dimension) bool {
|
func isSelected(name string, cloudwatchMetric types.Metric, dimensions []*Dimension) bool {
|
||||||
if name != *metric.MetricName {
|
if name != *cloudwatchMetric.MetricName {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if len(metric.Dimensions) != len(dimensions) {
|
if len(cloudwatchMetric.Dimensions) != len(dimensions) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, d := range dimensions {
|
for _, d := range dimensions {
|
||||||
selected := false
|
selected := false
|
||||||
for _, d2 := range metric.Dimensions {
|
for _, d2 := range cloudwatchMetric.Dimensions {
|
||||||
if d.Name == *d2.Name {
|
if d.Name == *d2.Name {
|
||||||
if d.Value == "" || d.valueMatcher.Match(*d2.Value) {
|
if d.Value == "" || d.valueMatcher.Match(*d2.Value) {
|
||||||
selected = true
|
selected = true
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/aws"
|
"github.com/aws/aws-sdk-go-v2/aws"
|
||||||
cwClient "github.com/aws/aws-sdk-go-v2/service/cloudwatch"
|
"github.com/aws/aws-sdk-go-v2/service/cloudwatch"
|
||||||
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
|
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/filter"
|
"github.com/influxdata/telegraf/filter"
|
||||||
internalaws "github.com/influxdata/telegraf/plugins/common/aws"
|
common_aws "github.com/influxdata/telegraf/plugins/common/aws"
|
||||||
"github.com/influxdata/telegraf/plugins/common/proxy"
|
"github.com/influxdata/telegraf/plugins/common/proxy"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
@ -23,10 +23,10 @@ type mockGatherCloudWatchClient struct{}
|
||||||
|
|
||||||
func (m *mockGatherCloudWatchClient) ListMetrics(
|
func (m *mockGatherCloudWatchClient) ListMetrics(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
params *cwClient.ListMetricsInput,
|
params *cloudwatch.ListMetricsInput,
|
||||||
_ ...func(*cwClient.Options),
|
_ ...func(*cloudwatch.Options),
|
||||||
) (*cwClient.ListMetricsOutput, error) {
|
) (*cloudwatch.ListMetricsOutput, error) {
|
||||||
response := &cwClient.ListMetricsOutput{
|
response := &cloudwatch.ListMetricsOutput{
|
||||||
Metrics: []types.Metric{
|
Metrics: []types.Metric{
|
||||||
{
|
{
|
||||||
Namespace: params.Namespace,
|
Namespace: params.Namespace,
|
||||||
|
|
@ -58,10 +58,10 @@ func (m *mockGatherCloudWatchClient) ListMetrics(
|
||||||
|
|
||||||
func (m *mockGatherCloudWatchClient) GetMetricData(
|
func (m *mockGatherCloudWatchClient) GetMetricData(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
params *cwClient.GetMetricDataInput,
|
params *cloudwatch.GetMetricDataInput,
|
||||||
_ ...func(*cwClient.Options),
|
_ ...func(*cloudwatch.Options),
|
||||||
) (*cwClient.GetMetricDataOutput, error) {
|
) (*cloudwatch.GetMetricDataOutput, error) {
|
||||||
return &cwClient.GetMetricDataOutput{
|
return &cloudwatch.GetMetricDataOutput{
|
||||||
MetricDataResults: []types.MetricDataResult{
|
MetricDataResults: []types.MetricDataResult{
|
||||||
{
|
{
|
||||||
Id: aws.String("minimum_0_0"),
|
Id: aws.String("minimum_0_0"),
|
||||||
|
|
@ -167,7 +167,7 @@ func TestGather(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
internalDuration := config.Duration(duration)
|
internalDuration := config.Duration(duration)
|
||||||
c := &CloudWatch{
|
c := &CloudWatch{
|
||||||
CredentialConfig: internalaws.CredentialConfig{
|
CredentialConfig: common_aws.CredentialConfig{
|
||||||
Region: "us-east-1",
|
Region: "us-east-1",
|
||||||
},
|
},
|
||||||
Namespace: "AWS/ELB",
|
Namespace: "AWS/ELB",
|
||||||
|
|
@ -204,7 +204,7 @@ func TestGatherDenseMetric(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
internalDuration := config.Duration(duration)
|
internalDuration := config.Duration(duration)
|
||||||
c := &CloudWatch{
|
c := &CloudWatch{
|
||||||
CredentialConfig: internalaws.CredentialConfig{
|
CredentialConfig: common_aws.CredentialConfig{
|
||||||
Region: "us-east-1",
|
Region: "us-east-1",
|
||||||
},
|
},
|
||||||
Namespace: "AWS/ELB",
|
Namespace: "AWS/ELB",
|
||||||
|
|
@ -243,7 +243,7 @@ func TestMultiAccountGather(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
internalDuration := config.Duration(duration)
|
internalDuration := config.Duration(duration)
|
||||||
c := &CloudWatch{
|
c := &CloudWatch{
|
||||||
CredentialConfig: internalaws.CredentialConfig{
|
CredentialConfig: common_aws.CredentialConfig{
|
||||||
Region: "us-east-1",
|
Region: "us-east-1",
|
||||||
},
|
},
|
||||||
Namespace: "AWS/ELB",
|
Namespace: "AWS/ELB",
|
||||||
|
|
@ -309,9 +309,9 @@ type mockSelectMetricsCloudWatchClient struct{}
|
||||||
|
|
||||||
func (m *mockSelectMetricsCloudWatchClient) ListMetrics(
|
func (m *mockSelectMetricsCloudWatchClient) ListMetrics(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
_ *cwClient.ListMetricsInput,
|
_ *cloudwatch.ListMetricsInput,
|
||||||
_ ...func(*cwClient.Options),
|
_ ...func(*cloudwatch.Options),
|
||||||
) (*cwClient.ListMetricsOutput, error) {
|
) (*cloudwatch.ListMetricsOutput, error) {
|
||||||
metrics := []types.Metric{}
|
metrics := []types.Metric{}
|
||||||
// 4 metrics are available
|
// 4 metrics are available
|
||||||
metricNames := []string{"Latency", "RequestCount", "HealthyHostCount", "UnHealthyHostCount"}
|
metricNames := []string{"Latency", "RequestCount", "HealthyHostCount", "UnHealthyHostCount"}
|
||||||
|
|
@ -352,7 +352,7 @@ func (m *mockSelectMetricsCloudWatchClient) ListMetrics(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result := &cwClient.ListMetricsOutput{
|
result := &cloudwatch.ListMetricsOutput{
|
||||||
Metrics: metrics,
|
Metrics: metrics,
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|
@ -360,9 +360,9 @@ func (m *mockSelectMetricsCloudWatchClient) ListMetrics(
|
||||||
|
|
||||||
func (m *mockSelectMetricsCloudWatchClient) GetMetricData(
|
func (m *mockSelectMetricsCloudWatchClient) GetMetricData(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
_ *cwClient.GetMetricDataInput,
|
_ *cloudwatch.GetMetricDataInput,
|
||||||
_ ...func(*cwClient.Options),
|
_ ...func(*cloudwatch.Options),
|
||||||
) (*cwClient.GetMetricDataOutput, error) {
|
) (*cloudwatch.GetMetricDataOutput, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,7 +371,7 @@ func TestSelectMetrics(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
internalDuration := config.Duration(duration)
|
internalDuration := config.Duration(duration)
|
||||||
c := &CloudWatch{
|
c := &CloudWatch{
|
||||||
CredentialConfig: internalaws.CredentialConfig{
|
CredentialConfig: common_aws.CredentialConfig{
|
||||||
Region: "us-east-1",
|
Region: "us-east-1",
|
||||||
},
|
},
|
||||||
Namespace: "AWS/ELB",
|
Namespace: "AWS/ELB",
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/internal/choice"
|
"github.com/influxdata/telegraf/internal/choice"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/selfstat"
|
"github.com/influxdata/telegraf/selfstat"
|
||||||
)
|
)
|
||||||
|
|
@ -48,7 +48,7 @@ type CloudWatchMetricStreams struct {
|
||||||
ageMin selfstat.Stat
|
ageMin selfstat.Stat
|
||||||
|
|
||||||
Log telegraf.Logger
|
Log telegraf.Logger
|
||||||
tlsint.ServerConfig
|
common_tls.ServerConfig
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
close chan struct{}
|
close chan struct{}
|
||||||
listener net.Listener
|
listener net.Listener
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
couchbaseClient "github.com/couchbase/go-couchbase"
|
"github.com/couchbase/go-couchbase"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/filter"
|
"github.com/influxdata/telegraf/filter"
|
||||||
|
|
@ -72,7 +72,7 @@ func (cb *Couchbase) Gather(acc telegraf.Accumulator) error {
|
||||||
func (cb *Couchbase) gatherServer(acc telegraf.Accumulator, addr string) error {
|
func (cb *Couchbase) gatherServer(acc telegraf.Accumulator, addr string) error {
|
||||||
escapedAddr := regexpURI.ReplaceAllString(addr, "${1}")
|
escapedAddr := regexpURI.ReplaceAllString(addr, "${1}")
|
||||||
|
|
||||||
client, err := couchbaseClient.Connect(addr)
|
client, err := couchbase.Connect(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -460,15 +460,15 @@ func (cb *Couchbase) Init() error {
|
||||||
cb.client = &http.Client{
|
cb.client = &http.Client{
|
||||||
Timeout: 10 * time.Second,
|
Timeout: 10 * time.Second,
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
MaxIdleConnsPerHost: couchbaseClient.MaxIdleConnsPerHost,
|
MaxIdleConnsPerHost: couchbase.MaxIdleConnsPerHost,
|
||||||
TLSClientConfig: tlsConfig,
|
TLSClientConfig: tlsConfig,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
couchbaseClient.SetSkipVerify(cb.ClientConfig.InsecureSkipVerify)
|
couchbase.SetSkipVerify(cb.ClientConfig.InsecureSkipVerify)
|
||||||
couchbaseClient.SetCertFile(cb.ClientConfig.TLSCert)
|
couchbase.SetCertFile(cb.ClientConfig.TLSCert)
|
||||||
couchbaseClient.SetKeyFile(cb.ClientConfig.TLSKey)
|
couchbase.SetKeyFile(cb.ClientConfig.TLSKey)
|
||||||
couchbaseClient.SetRootFile(cb.ClientConfig.TLSCA)
|
couchbase.SetRootFile(cb.ClientConfig.TLSCA)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
cpuUtil "github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v3/cpu"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
|
@ -19,8 +19,8 @@ var sampleConfig string
|
||||||
|
|
||||||
type CPUStats struct {
|
type CPUStats struct {
|
||||||
ps system.PS
|
ps system.PS
|
||||||
lastStats map[string]cpuUtil.TimesStat
|
lastStats map[string]cpu.TimesStat
|
||||||
cpuInfo map[string]cpuUtil.InfoStat
|
cpuInfo map[string]cpu.InfoStat
|
||||||
coreID bool
|
coreID bool
|
||||||
physicalID bool
|
physicalID bool
|
||||||
|
|
||||||
|
|
@ -119,7 +119,7 @@ func (c *CPUStats) Gather(acc telegraf.Accumulator) error {
|
||||||
acc.AddGauge("cpu", fieldsG, tags, now)
|
acc.AddGauge("cpu", fieldsG, tags, now)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.lastStats = make(map[string]cpuUtil.TimesStat)
|
c.lastStats = make(map[string]cpu.TimesStat)
|
||||||
for _, cts := range times {
|
for _, cts := range times {
|
||||||
c.lastStats[cts.CPU] = cts
|
c.lastStats[cts.CPU] = cts
|
||||||
}
|
}
|
||||||
|
|
@ -129,12 +129,12 @@ func (c *CPUStats) Gather(acc telegraf.Accumulator) error {
|
||||||
|
|
||||||
func (c *CPUStats) Init() error {
|
func (c *CPUStats) Init() error {
|
||||||
if c.CoreTags {
|
if c.CoreTags {
|
||||||
cpuInfo, err := cpuUtil.Info()
|
cpuInfo, err := cpu.Info()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
c.coreID = cpuInfo[0].CoreID != ""
|
c.coreID = cpuInfo[0].CoreID != ""
|
||||||
c.physicalID = cpuInfo[0].PhysicalID != ""
|
c.physicalID = cpuInfo[0].PhysicalID != ""
|
||||||
|
|
||||||
c.cpuInfo = make(map[string]cpuUtil.InfoStat)
|
c.cpuInfo = make(map[string]cpu.InfoStat)
|
||||||
for _, ci := range cpuInfo {
|
for _, ci := range cpuInfo {
|
||||||
c.cpuInfo[fmt.Sprintf("cpu%d", ci.CPU)] = ci
|
c.cpuInfo[fmt.Sprintf("cpu%d", ci.CPU)] = ci
|
||||||
}
|
}
|
||||||
|
|
@ -146,12 +146,12 @@ func (c *CPUStats) Init() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func totalCPUTime(t cpuUtil.TimesStat) float64 {
|
func totalCPUTime(t cpu.TimesStat) float64 {
|
||||||
total := t.User + t.System + t.Nice + t.Iowait + t.Irq + t.Softirq + t.Steal + t.Idle
|
total := t.User + t.System + t.Nice + t.Iowait + t.Irq + t.Softirq + t.Steal + t.Idle
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
|
||||||
func activeCPUTime(t cpuUtil.TimesStat) float64 {
|
func activeCPUTime(t cpu.TimesStat) float64 {
|
||||||
active := totalCPUTime(t) - t.Idle
|
active := totalCPUTime(t) - t.Idle
|
||||||
return active
|
return active
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
cpuUtil "github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v3/cpu"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/plugins/inputs/system"
|
"github.com/influxdata/telegraf/plugins/inputs/system"
|
||||||
|
|
@ -24,7 +24,7 @@ func TestCPUStats(t *testing.T) {
|
||||||
defer mps.AssertExpectations(t)
|
defer mps.AssertExpectations(t)
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
|
|
||||||
cts := cpuUtil.TimesStat{
|
cts := cpu.TimesStat{
|
||||||
CPU: "cpu0",
|
CPU: "cpu0",
|
||||||
User: 8.8,
|
User: 8.8,
|
||||||
System: 8.2,
|
System: 8.2,
|
||||||
|
|
@ -38,7 +38,7 @@ func TestCPUStats(t *testing.T) {
|
||||||
GuestNice: 0.324,
|
GuestNice: 0.324,
|
||||||
}
|
}
|
||||||
|
|
||||||
cts2 := cpuUtil.TimesStat{
|
cts2 := cpu.TimesStat{
|
||||||
CPU: "cpu0",
|
CPU: "cpu0",
|
||||||
User: 24.9, // increased by 16.1
|
User: 24.9, // increased by 16.1
|
||||||
System: 10.9, // increased by 2.7
|
System: 10.9, // increased by 2.7
|
||||||
|
|
@ -52,7 +52,7 @@ func TestCPUStats(t *testing.T) {
|
||||||
GuestNice: 2.524, // increased by 2.2
|
GuestNice: 2.524, // increased by 2.2
|
||||||
}
|
}
|
||||||
|
|
||||||
mps.On("CPUTimes").Return([]cpuUtil.TimesStat{cts}, nil)
|
mps.On("CPUTimes").Return([]cpu.TimesStat{cts}, nil)
|
||||||
|
|
||||||
cs := NewCPUStats(&mps)
|
cs := NewCPUStats(&mps)
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ func TestCPUStats(t *testing.T) {
|
||||||
assertContainsTaggedFloat(t, &acc, "time_guest_nice", 0.324, 0)
|
assertContainsTaggedFloat(t, &acc, "time_guest_nice", 0.324, 0)
|
||||||
|
|
||||||
mps2 := system.MockPS{}
|
mps2 := system.MockPS{}
|
||||||
mps2.On("CPUTimes").Return([]cpuUtil.TimesStat{cts2}, nil)
|
mps2.On("CPUTimes").Return([]cpu.TimesStat{cts2}, nil)
|
||||||
cs.ps = &mps2
|
cs.ps = &mps2
|
||||||
|
|
||||||
// Should have added cpu percentages too
|
// Should have added cpu percentages too
|
||||||
|
|
@ -162,7 +162,7 @@ func TestCPUCountIncrease(t *testing.T) {
|
||||||
cs := NewCPUStats(&mps)
|
cs := NewCPUStats(&mps)
|
||||||
|
|
||||||
mps.On("CPUTimes").Return(
|
mps.On("CPUTimes").Return(
|
||||||
[]cpuUtil.TimesStat{
|
[]cpu.TimesStat{
|
||||||
{
|
{
|
||||||
CPU: "cpu0",
|
CPU: "cpu0",
|
||||||
},
|
},
|
||||||
|
|
@ -172,7 +172,7 @@ func TestCPUCountIncrease(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mps2.On("CPUTimes").Return(
|
mps2.On("CPUTimes").Return(
|
||||||
[]cpuUtil.TimesStat{
|
[]cpu.TimesStat{
|
||||||
{
|
{
|
||||||
CPU: "cpu0",
|
CPU: "cpu0",
|
||||||
},
|
},
|
||||||
|
|
@ -193,28 +193,28 @@ func TestCPUTimesDecrease(t *testing.T) {
|
||||||
defer mps.AssertExpectations(t)
|
defer mps.AssertExpectations(t)
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
|
|
||||||
cts := cpuUtil.TimesStat{
|
cts := cpu.TimesStat{
|
||||||
CPU: "cpu0",
|
CPU: "cpu0",
|
||||||
User: 18,
|
User: 18,
|
||||||
Idle: 80,
|
Idle: 80,
|
||||||
Iowait: 2,
|
Iowait: 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
cts2 := cpuUtil.TimesStat{
|
cts2 := cpu.TimesStat{
|
||||||
CPU: "cpu0",
|
CPU: "cpu0",
|
||||||
User: 38, // increased by 20
|
User: 38, // increased by 20
|
||||||
Idle: 40, // decreased by 40
|
Idle: 40, // decreased by 40
|
||||||
Iowait: 1, // decreased by 1
|
Iowait: 1, // decreased by 1
|
||||||
}
|
}
|
||||||
|
|
||||||
cts3 := cpuUtil.TimesStat{
|
cts3 := cpu.TimesStat{
|
||||||
CPU: "cpu0",
|
CPU: "cpu0",
|
||||||
User: 56, // increased by 18
|
User: 56, // increased by 18
|
||||||
Idle: 120, // increased by 80
|
Idle: 120, // increased by 80
|
||||||
Iowait: 3, // increased by 2
|
Iowait: 3, // increased by 2
|
||||||
}
|
}
|
||||||
|
|
||||||
mps.On("CPUTimes").Return([]cpuUtil.TimesStat{cts}, nil)
|
mps.On("CPUTimes").Return([]cpu.TimesStat{cts}, nil)
|
||||||
|
|
||||||
cs := NewCPUStats(&mps)
|
cs := NewCPUStats(&mps)
|
||||||
|
|
||||||
|
|
@ -228,7 +228,7 @@ func TestCPUTimesDecrease(t *testing.T) {
|
||||||
assertContainsTaggedFloat(t, &acc, "time_iowait", 2, 0)
|
assertContainsTaggedFloat(t, &acc, "time_iowait", 2, 0)
|
||||||
|
|
||||||
mps2 := system.MockPS{}
|
mps2 := system.MockPS{}
|
||||||
mps2.On("CPUTimes").Return([]cpuUtil.TimesStat{cts2}, nil)
|
mps2.On("CPUTimes").Return([]cpu.TimesStat{cts2}, nil)
|
||||||
cs.ps = &mps2
|
cs.ps = &mps2
|
||||||
|
|
||||||
// CPU times decreased. An error should be raised
|
// CPU times decreased. An error should be raised
|
||||||
|
|
@ -236,7 +236,7 @@ func TestCPUTimesDecrease(t *testing.T) {
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
mps3 := system.MockPS{}
|
mps3 := system.MockPS{}
|
||||||
mps3.On("CPUTimes").Return([]cpuUtil.TimesStat{cts3}, nil)
|
mps3.On("CPUTimes").Return([]cpu.TimesStat{cts3}, nil)
|
||||||
cs.ps = &mps3
|
cs.ps = &mps3
|
||||||
|
|
||||||
err = cs.Gather(&acc)
|
err = cs.Gather(&acc)
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ import (
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/internal/choice"
|
"github.com/influxdata/telegraf/internal/choice"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
jsonParser "github.com/influxdata/telegraf/plugins/parsers/json"
|
parsers_json "github.com/influxdata/telegraf/plugins/parsers/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This plugin is based on the official ctrlX CORE API. Documentation can be found in OpenAPI format at:
|
// This plugin is based on the official ctrlX CORE API. Documentation can be found in OpenAPI format at:
|
||||||
|
|
@ -55,7 +55,7 @@ type CtrlXDataLayer struct {
|
||||||
acc telegraf.Accumulator
|
acc telegraf.Accumulator
|
||||||
connection *http.Client
|
connection *http.Client
|
||||||
tokenManager token.TokenManager
|
tokenManager token.TokenManager
|
||||||
httpconfig.HTTPClientConfig
|
common_http.HTTPClientConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// convertTimestamp2UnixTime converts the given Data Layer timestamp of the payload to UnixTime.
|
// convertTimestamp2UnixTime converts the given Data Layer timestamp of the payload to UnixTime.
|
||||||
|
|
@ -197,7 +197,7 @@ func (c *CtrlXDataLayer) createMetric(em *sseEventData, sub *subscription) (tele
|
||||||
|
|
||||||
switch em.Type {
|
switch em.Type {
|
||||||
case "object":
|
case "object":
|
||||||
flattener := jsonParser.JSONFlattener{}
|
flattener := parsers_json.JSONFlattener{}
|
||||||
err := flattener.FullFlattenJSON(fieldKey, em.Value, true, true)
|
err := flattener.FullFlattenJSON(fieldKey, em.Value, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/plugins/common/tls"
|
"github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
@ -183,7 +183,7 @@ func initRunner(t *testing.T) (*CtrlXDataLayer, *httptest.Server) {
|
||||||
url: server.URL,
|
url: server.URL,
|
||||||
Username: config.NewSecret([]byte("user")),
|
Username: config.NewSecret([]byte("user")),
|
||||||
Password: config.NewSecret([]byte("password")),
|
Password: config.NewSecret([]byte("password")),
|
||||||
HTTPClientConfig: httpconfig.HTTPClientConfig{
|
HTTPClientConfig: common_http.HTTPClientConfig{
|
||||||
ClientConfig: tls.ClientConfig{
|
ClientConfig: tls.ClientConfig{
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
diskUtil "github.com/shirou/gopsutil/v3/disk"
|
"github.com/shirou/gopsutil/v3/disk"
|
||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ func TestDiskUsage(t *testing.T) {
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
psAll := []diskUtil.PartitionStat{
|
psAll := []disk.PartitionStat{
|
||||||
{
|
{
|
||||||
Device: "/dev/sda",
|
Device: "/dev/sda",
|
||||||
Mountpoint: "/",
|
Mountpoint: "/",
|
||||||
|
|
@ -50,7 +50,7 @@ func TestDiskUsage(t *testing.T) {
|
||||||
Opts: []string{"ro", "noatime", "nodiratime", "bind"},
|
Opts: []string{"ro", "noatime", "nodiratime", "bind"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
duAll := []diskUtil.UsageStat{
|
duAll := []disk.UsageStat{
|
||||||
{
|
{
|
||||||
Path: "/",
|
Path: "/",
|
||||||
Fstype: "ext4",
|
Fstype: "ext4",
|
||||||
|
|
@ -170,15 +170,15 @@ func TestDiskUsage(t *testing.T) {
|
||||||
func TestDiskUsageHostMountPrefix(t *testing.T) {
|
func TestDiskUsageHostMountPrefix(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
partitionStats []diskUtil.PartitionStat
|
partitionStats []disk.PartitionStat
|
||||||
usageStats []*diskUtil.UsageStat
|
usageStats []*disk.UsageStat
|
||||||
hostMountPrefix string
|
hostMountPrefix string
|
||||||
expectedTags map[string]string
|
expectedTags map[string]string
|
||||||
expectedFields map[string]interface{}
|
expectedFields map[string]interface{}
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "no host mount prefix",
|
name: "no host mount prefix",
|
||||||
partitionStats: []diskUtil.PartitionStat{
|
partitionStats: []disk.PartitionStat{
|
||||||
{
|
{
|
||||||
Device: "/dev/sda",
|
Device: "/dev/sda",
|
||||||
Mountpoint: "/",
|
Mountpoint: "/",
|
||||||
|
|
@ -186,7 +186,7 @@ func TestDiskUsageHostMountPrefix(t *testing.T) {
|
||||||
Opts: []string{"ro"},
|
Opts: []string{"ro"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
usageStats: []*diskUtil.UsageStat{
|
usageStats: []*disk.UsageStat{
|
||||||
{
|
{
|
||||||
Path: "/",
|
Path: "/",
|
||||||
Total: 42,
|
Total: 42,
|
||||||
|
|
@ -211,7 +211,7 @@ func TestDiskUsageHostMountPrefix(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "host mount prefix",
|
name: "host mount prefix",
|
||||||
partitionStats: []diskUtil.PartitionStat{
|
partitionStats: []disk.PartitionStat{
|
||||||
{
|
{
|
||||||
Device: "/dev/sda",
|
Device: "/dev/sda",
|
||||||
Mountpoint: "/hostfs/var",
|
Mountpoint: "/hostfs/var",
|
||||||
|
|
@ -219,7 +219,7 @@ func TestDiskUsageHostMountPrefix(t *testing.T) {
|
||||||
Opts: []string{"ro"},
|
Opts: []string{"ro"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
usageStats: []*diskUtil.UsageStat{
|
usageStats: []*disk.UsageStat{
|
||||||
{
|
{
|
||||||
Path: "/hostfs/var",
|
Path: "/hostfs/var",
|
||||||
Total: 42,
|
Total: 42,
|
||||||
|
|
@ -245,7 +245,7 @@ func TestDiskUsageHostMountPrefix(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "host mount prefix exact match",
|
name: "host mount prefix exact match",
|
||||||
partitionStats: []diskUtil.PartitionStat{
|
partitionStats: []disk.PartitionStat{
|
||||||
{
|
{
|
||||||
Device: "/dev/sda",
|
Device: "/dev/sda",
|
||||||
Mountpoint: "/hostfs",
|
Mountpoint: "/hostfs",
|
||||||
|
|
@ -253,7 +253,7 @@ func TestDiskUsageHostMountPrefix(t *testing.T) {
|
||||||
Opts: []string{"ro"},
|
Opts: []string{"ro"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
usageStats: []*diskUtil.UsageStat{
|
usageStats: []*disk.UsageStat{
|
||||||
{
|
{
|
||||||
Path: "/hostfs",
|
Path: "/hostfs",
|
||||||
Total: 42,
|
Total: 42,
|
||||||
|
|
@ -310,7 +310,7 @@ func TestDiskStats(t *testing.T) {
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
duAll := []*diskUtil.UsageStat{
|
duAll := []*disk.UsageStat{
|
||||||
{
|
{
|
||||||
Path: "/",
|
Path: "/",
|
||||||
Fstype: "ext4",
|
Fstype: "ext4",
|
||||||
|
|
@ -342,7 +342,7 @@ func TestDiskStats(t *testing.T) {
|
||||||
InodesUsed: 1000,
|
InodesUsed: 1000,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
duMountFiltered := []*diskUtil.UsageStat{
|
duMountFiltered := []*disk.UsageStat{
|
||||||
{
|
{
|
||||||
Path: "/",
|
Path: "/",
|
||||||
Fstype: "ext4",
|
Fstype: "ext4",
|
||||||
|
|
@ -354,7 +354,7 @@ func TestDiskStats(t *testing.T) {
|
||||||
InodesUsed: 1000,
|
InodesUsed: 1000,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
duOptFiltered := []*diskUtil.UsageStat{
|
duOptFiltered := []*disk.UsageStat{
|
||||||
{
|
{
|
||||||
Path: "/",
|
Path: "/",
|
||||||
Fstype: "ext4",
|
Fstype: "ext4",
|
||||||
|
|
@ -377,7 +377,7 @@ func TestDiskStats(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
psAll := []*diskUtil.PartitionStat{
|
psAll := []*disk.PartitionStat{
|
||||||
{
|
{
|
||||||
Device: "/dev/sda",
|
Device: "/dev/sda",
|
||||||
Mountpoint: "/",
|
Mountpoint: "/",
|
||||||
|
|
@ -398,7 +398,7 @@ func TestDiskStats(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
psMountFiltered := []*diskUtil.PartitionStat{
|
psMountFiltered := []*disk.PartitionStat{
|
||||||
{
|
{
|
||||||
Device: "/dev/sda",
|
Device: "/dev/sda",
|
||||||
Mountpoint: "/",
|
Mountpoint: "/",
|
||||||
|
|
@ -406,7 +406,7 @@ func TestDiskStats(t *testing.T) {
|
||||||
Opts: []string{"ro", "noatime", "nodiratime"},
|
Opts: []string{"ro", "noatime", "nodiratime"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
psOptFiltered := []*diskUtil.PartitionStat{
|
psOptFiltered := []*disk.PartitionStat{
|
||||||
{
|
{
|
||||||
Device: "/dev/sda",
|
Device: "/dev/sda",
|
||||||
Mountpoint: "/",
|
Mountpoint: "/",
|
||||||
|
|
@ -495,13 +495,13 @@ func TestDiskUsageIssues(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
prefix string
|
prefix string
|
||||||
du diskUtil.UsageStat
|
du disk.UsageStat
|
||||||
expected []telegraf.Metric
|
expected []telegraf.Metric
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "success",
|
name: "success",
|
||||||
prefix: "",
|
prefix: "",
|
||||||
du: diskUtil.UsageStat{
|
du: disk.UsageStat{
|
||||||
Total: 256,
|
Total: 256,
|
||||||
Free: 46,
|
Free: 46,
|
||||||
Used: 200,
|
Used: 200,
|
||||||
|
|
@ -557,7 +557,7 @@ func TestDiskUsageIssues(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "issue 10297",
|
name: "issue 10297",
|
||||||
prefix: "/host",
|
prefix: "/host",
|
||||||
du: diskUtil.UsageStat{
|
du: disk.UsageStat{
|
||||||
Total: 256,
|
Total: 256,
|
||||||
Free: 46,
|
Free: 46,
|
||||||
Used: 200,
|
Used: 200,
|
||||||
|
|
@ -630,7 +630,7 @@ func TestDiskUsageIssues(t *testing.T) {
|
||||||
t.Setenv("HOST_PROC", hostProcPrefix)
|
t.Setenv("HOST_PROC", hostProcPrefix)
|
||||||
t.Setenv("HOST_SYS", hostSysPrefix)
|
t.Setenv("HOST_SYS", hostSysPrefix)
|
||||||
|
|
||||||
partitions, err := diskUtil.Partitions(true)
|
partitions, err := disk.Partitions(true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Mock the disk usage
|
// Mock the disk usage
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/system"
|
"github.com/docker/docker/api/types/system"
|
||||||
dockerClient "github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -30,11 +30,11 @@ type Client interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEnvClient() (Client, error) {
|
func NewEnvClient() (Client, error) {
|
||||||
client, err := dockerClient.NewClientWithOpts(dockerClient.FromEnv)
|
dockerClient, err := client.NewClientWithOpts(client.FromEnv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &SocketClient{client}, nil
|
return &SocketClient{dockerClient}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(host string, tlsConfig *tls.Config) (Client, error) {
|
func NewClient(host string, tlsConfig *tls.Config) (Client, error) {
|
||||||
|
|
@ -43,20 +43,20 @@ func NewClient(host string, tlsConfig *tls.Config) (Client, error) {
|
||||||
}
|
}
|
||||||
httpClient := &http.Client{Transport: transport}
|
httpClient := &http.Client{Transport: transport}
|
||||||
|
|
||||||
client, err := dockerClient.NewClientWithOpts(
|
dockerClient, err := client.NewClientWithOpts(
|
||||||
dockerClient.WithHTTPHeaders(defaultHeaders),
|
client.WithHTTPHeaders(defaultHeaders),
|
||||||
dockerClient.WithHTTPClient(httpClient),
|
client.WithHTTPClient(httpClient),
|
||||||
dockerClient.WithAPIVersionNegotiation(),
|
client.WithAPIVersionNegotiation(),
|
||||||
dockerClient.WithHost(host))
|
client.WithHost(host))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &SocketClient{client}, nil
|
return &SocketClient{dockerClient}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type SocketClient struct {
|
type SocketClient struct {
|
||||||
client *dockerClient.Client
|
client *client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *SocketClient) Info(ctx context.Context) (system.Info, error) {
|
func (c *SocketClient) Info(ctx context.Context) (system.Info, error) {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import (
|
||||||
|
|
||||||
"github.com/Masterminds/semver/v3"
|
"github.com/Masterminds/semver/v3"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
typeContainer "github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
|
|
||||||
|
|
@ -25,8 +25,8 @@ import (
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/filter"
|
"github.com/influxdata/telegraf/filter"
|
||||||
"github.com/influxdata/telegraf/internal/choice"
|
"github.com/influxdata/telegraf/internal/choice"
|
||||||
dockerint "github.com/influxdata/telegraf/internal/docker"
|
"github.com/influxdata/telegraf/internal/docker"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ type Docker struct {
|
||||||
|
|
||||||
Log telegraf.Logger
|
Log telegraf.Logger
|
||||||
|
|
||||||
tlsint.ClientConfig
|
common_tls.ClientConfig
|
||||||
|
|
||||||
newEnvClient func() (Client, error)
|
newEnvClient func() (Client, error)
|
||||||
newClient func(string, *tls.Config) (Client, error)
|
newClient func(string, *tls.Config) (Client, error)
|
||||||
|
|
@ -218,7 +218,7 @@ func (d *Docker) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// List containers
|
// List containers
|
||||||
opts := typeContainer.ListOptions{
|
opts := container.ListOptions{
|
||||||
Filters: filterArgs,
|
Filters: filterArgs,
|
||||||
}
|
}
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(d.Timeout))
|
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(d.Timeout))
|
||||||
|
|
@ -235,13 +235,13 @@ func (d *Docker) Gather(acc telegraf.Accumulator) error {
|
||||||
// Get container data
|
// Get container data
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(len(containers))
|
wg.Add(len(containers))
|
||||||
for _, container := range containers {
|
for _, cntnr := range containers {
|
||||||
go func(c types.Container) {
|
go func(c types.Container) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if err := d.gatherContainer(c, acc); err != nil {
|
if err := d.gatherContainer(c, acc); err != nil {
|
||||||
acc.AddError(err)
|
acc.AddError(err)
|
||||||
}
|
}
|
||||||
}(container)
|
}(cntnr)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
|
@ -468,12 +468,12 @@ func parseContainerName(containerNames []string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Docker) gatherContainer(
|
func (d *Docker) gatherContainer(
|
||||||
container types.Container,
|
cntnr types.Container,
|
||||||
acc telegraf.Accumulator,
|
acc telegraf.Accumulator,
|
||||||
) error {
|
) error {
|
||||||
var v *typeContainer.StatsResponse
|
var v *container.StatsResponse
|
||||||
|
|
||||||
cname := parseContainerName(container.Names)
|
cname := parseContainerName(cntnr.Names)
|
||||||
|
|
||||||
if cname == "" {
|
if cname == "" {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -483,7 +483,7 @@ func (d *Docker) gatherContainer(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
imageName, imageVersion := dockerint.ParseImage(container.Image)
|
imageName, imageVersion := docker.ParseImage(cntnr.Image)
|
||||||
|
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"engine_host": d.engineHost,
|
"engine_host": d.engineHost,
|
||||||
|
|
@ -494,13 +494,13 @@ func (d *Docker) gatherContainer(
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.IncludeSourceTag {
|
if d.IncludeSourceTag {
|
||||||
tags["source"] = hostnameFromID(container.ID)
|
tags["source"] = hostnameFromID(cntnr.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(d.Timeout))
|
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(d.Timeout))
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
r, err := d.client.ContainerStats(ctx, container.ID, false)
|
r, err := d.client.ContainerStats(ctx, cntnr.ID, false)
|
||||||
if errors.Is(err, context.DeadlineExceeded) {
|
if errors.Is(err, context.DeadlineExceeded) {
|
||||||
return errStatsTimeout
|
return errStatsTimeout
|
||||||
}
|
}
|
||||||
|
|
@ -519,26 +519,26 @@ func (d *Docker) gatherContainer(
|
||||||
daemonOSType := r.OSType
|
daemonOSType := r.OSType
|
||||||
|
|
||||||
// Add labels to tags
|
// Add labels to tags
|
||||||
for k, label := range container.Labels {
|
for k, label := range cntnr.Labels {
|
||||||
if d.labelFilter.Match(k) {
|
if d.labelFilter.Match(k) {
|
||||||
tags[k] = label
|
tags[k] = label
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return d.gatherContainerInspect(container, acc, tags, daemonOSType, v)
|
return d.gatherContainerInspect(cntnr, acc, tags, daemonOSType, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Docker) gatherContainerInspect(
|
func (d *Docker) gatherContainerInspect(
|
||||||
container types.Container,
|
cntnr types.Container,
|
||||||
acc telegraf.Accumulator,
|
acc telegraf.Accumulator,
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
daemonOSType string,
|
daemonOSType string,
|
||||||
v *typeContainer.StatsResponse,
|
v *container.StatsResponse,
|
||||||
) error {
|
) error {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(d.Timeout))
|
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(d.Timeout))
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
info, err := d.client.ContainerInspect(ctx, container.ID)
|
info, err := d.client.ContainerInspect(ctx, cntnr.ID)
|
||||||
if errors.Is(err, context.DeadlineExceeded) {
|
if errors.Is(err, context.DeadlineExceeded) {
|
||||||
return errInspectTimeout
|
return errInspectTimeout
|
||||||
}
|
}
|
||||||
|
|
@ -566,7 +566,7 @@ func (d *Docker) gatherContainerInspect(
|
||||||
"pid": info.State.Pid,
|
"pid": info.State.Pid,
|
||||||
"exitcode": info.State.ExitCode,
|
"exitcode": info.State.ExitCode,
|
||||||
"restart_count": info.RestartCount,
|
"restart_count": info.RestartCount,
|
||||||
"container_id": container.ID,
|
"container_id": cntnr.ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
finished, err := time.Parse(time.RFC3339, info.State.FinishedAt)
|
finished, err := time.Parse(time.RFC3339, info.State.FinishedAt)
|
||||||
|
|
@ -599,13 +599,13 @@ func (d *Docker) gatherContainerInspect(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d.parseContainerStats(v, acc, tags, container.ID, daemonOSType)
|
d.parseContainerStats(v, acc, tags, cntnr.ID, daemonOSType)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Docker) parseContainerStats(
|
func (d *Docker) parseContainerStats(
|
||||||
stat *typeContainer.StatsResponse,
|
stat *container.StatsResponse,
|
||||||
acc telegraf.Accumulator,
|
acc telegraf.Accumulator,
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
id, daemonOSType string,
|
id, daemonOSType string,
|
||||||
|
|
@ -781,7 +781,7 @@ func (d *Docker) parseContainerStats(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a map of devices to their block io stats
|
// Make a map of devices to their block io stats
|
||||||
func getDeviceStatMap(blkioStats typeContainer.BlkioStats) map[string]map[string]interface{} {
|
func getDeviceStatMap(blkioStats container.BlkioStats) map[string]map[string]interface{} {
|
||||||
deviceStatMap := make(map[string]map[string]interface{})
|
deviceStatMap := make(map[string]map[string]interface{})
|
||||||
|
|
||||||
for _, metric := range blkioStats.IoServiceBytesRecursive {
|
for _, metric := range blkioStats.IoServiceBytesRecursive {
|
||||||
|
|
@ -844,7 +844,7 @@ func getDeviceStatMap(blkioStats typeContainer.BlkioStats) map[string]map[string
|
||||||
|
|
||||||
func (d *Docker) gatherBlockIOMetrics(
|
func (d *Docker) gatherBlockIOMetrics(
|
||||||
acc telegraf.Accumulator,
|
acc telegraf.Accumulator,
|
||||||
stat *typeContainer.StatsResponse,
|
stat *container.StatsResponse,
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
tm time.Time,
|
tm time.Time,
|
||||||
id string,
|
id string,
|
||||||
|
|
@ -921,24 +921,24 @@ func (d *Docker) gatherDiskUsage(acc telegraf.Accumulator, opts types.DiskUsageO
|
||||||
acc.AddFields(duName, fields, tags, now)
|
acc.AddFields(duName, fields, tags, now)
|
||||||
|
|
||||||
// Containers
|
// Containers
|
||||||
for _, container := range du.Containers {
|
for _, cntnr := range du.Containers {
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"size_rw": container.SizeRw,
|
"size_rw": cntnr.SizeRw,
|
||||||
"size_root_fs": container.SizeRootFs,
|
"size_root_fs": cntnr.SizeRootFs,
|
||||||
}
|
}
|
||||||
|
|
||||||
imageName, imageVersion := dockerint.ParseImage(container.Image)
|
imageName, imageVersion := docker.ParseImage(cntnr.Image)
|
||||||
|
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"engine_host": d.engineHost,
|
"engine_host": d.engineHost,
|
||||||
"server_version": d.serverVersion,
|
"server_version": d.serverVersion,
|
||||||
"container_name": parseContainerName(container.Names),
|
"container_name": parseContainerName(cntnr.Names),
|
||||||
"container_image": imageName,
|
"container_image": imageName,
|
||||||
"container_version": imageVersion,
|
"container_version": imageVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.IncludeSourceTag {
|
if d.IncludeSourceTag {
|
||||||
tags["source"] = hostnameFromID(container.ID)
|
tags["source"] = hostnameFromID(cntnr.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
acc.AddFields(duName, fields, tags, now)
|
acc.AddFields(duName, fields, tags, now)
|
||||||
|
|
@ -958,7 +958,7 @@ func (d *Docker) gatherDiskUsage(acc telegraf.Accumulator, opts types.DiskUsageO
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(image.RepoTags) > 0 {
|
if len(image.RepoTags) > 0 {
|
||||||
imageName, imageVersion := dockerint.ParseImage(image.RepoTags[0])
|
imageName, imageVersion := docker.ParseImage(image.RepoTags[0])
|
||||||
tags["image_name"] = imageName
|
tags["image_name"] = imageName
|
||||||
tags["image_version"] = imageVersion
|
tags["image_version"] = imageVersion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
typeContainer "github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/system"
|
"github.com/docker/docker/api/types/system"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
@ -23,8 +23,8 @@ import (
|
||||||
|
|
||||||
type MockClient struct {
|
type MockClient struct {
|
||||||
InfoF func() (system.Info, error)
|
InfoF func() (system.Info, error)
|
||||||
ContainerListF func(options typeContainer.ListOptions) ([]types.Container, error)
|
ContainerListF func(options container.ListOptions) ([]types.Container, error)
|
||||||
ContainerStatsF func(containerID string) (typeContainer.StatsResponseReader, error)
|
ContainerStatsF func(containerID string) (container.StatsResponseReader, error)
|
||||||
ContainerInspectF func() (types.ContainerJSON, error)
|
ContainerInspectF func() (types.ContainerJSON, error)
|
||||||
ServiceListF func() ([]swarm.Service, error)
|
ServiceListF func() ([]swarm.Service, error)
|
||||||
TaskListF func() ([]swarm.Task, error)
|
TaskListF func() ([]swarm.Task, error)
|
||||||
|
|
@ -38,11 +38,11 @@ func (c *MockClient) Info(context.Context) (system.Info, error) {
|
||||||
return c.InfoF()
|
return c.InfoF()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *MockClient) ContainerList(_ context.Context, options typeContainer.ListOptions) ([]types.Container, error) {
|
func (c *MockClient) ContainerList(_ context.Context, options container.ListOptions) ([]types.Container, error) {
|
||||||
return c.ContainerListF(options)
|
return c.ContainerListF(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *MockClient) ContainerStats(_ context.Context, containerID string, _ bool) (typeContainer.StatsResponseReader, error) {
|
func (c *MockClient) ContainerStats(_ context.Context, containerID string, _ bool) (container.StatsResponseReader, error) {
|
||||||
return c.ContainerStatsF(containerID)
|
return c.ContainerStatsF(containerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,10 +78,10 @@ var baseClient = MockClient{
|
||||||
InfoF: func() (system.Info, error) {
|
InfoF: func() (system.Info, error) {
|
||||||
return info, nil
|
return info, nil
|
||||||
},
|
},
|
||||||
ContainerListF: func(typeContainer.ListOptions) ([]types.Container, error) {
|
ContainerListF: func(container.ListOptions) ([]types.Container, error) {
|
||||||
return containerList, nil
|
return containerList, nil
|
||||||
},
|
},
|
||||||
ContainerStatsF: func(s string) (typeContainer.StatsResponseReader, error) {
|
ContainerStatsF: func(s string) (container.StatsResponseReader, error) {
|
||||||
return containerStats(s), nil
|
return containerStats(s), nil
|
||||||
},
|
},
|
||||||
ContainerInspectF: func() (types.ContainerJSON, error) {
|
ContainerInspectF: func() (types.ContainerJSON, error) {
|
||||||
|
|
@ -426,10 +426,10 @@ func TestDocker_WindowsMemoryContainerStats(t *testing.T) {
|
||||||
InfoF: func() (system.Info, error) {
|
InfoF: func() (system.Info, error) {
|
||||||
return info, nil
|
return info, nil
|
||||||
},
|
},
|
||||||
ContainerListF: func(typeContainer.ListOptions) ([]types.Container, error) {
|
ContainerListF: func(container.ListOptions) ([]types.Container, error) {
|
||||||
return containerList, nil
|
return containerList, nil
|
||||||
},
|
},
|
||||||
ContainerStatsF: func(string) (typeContainer.StatsResponseReader, error) {
|
ContainerStatsF: func(string) (container.StatsResponseReader, error) {
|
||||||
return containerStatsWindows(), nil
|
return containerStatsWindows(), nil
|
||||||
},
|
},
|
||||||
ContainerInspectF: func() (types.ContainerJSON, error) {
|
ContainerInspectF: func() (types.ContainerJSON, error) {
|
||||||
|
|
@ -561,7 +561,7 @@ func TestContainerLabels(t *testing.T) {
|
||||||
|
|
||||||
newClientFunc := func(string, *tls.Config) (Client, error) {
|
newClientFunc := func(string, *tls.Config) (Client, error) {
|
||||||
client := baseClient
|
client := baseClient
|
||||||
client.ContainerListF = func(typeContainer.ListOptions) ([]types.Container, error) {
|
client.ContainerListF = func(container.ListOptions) ([]types.Container, error) {
|
||||||
return []types.Container{tt.container}, nil
|
return []types.Container{tt.container}, nil
|
||||||
}
|
}
|
||||||
return &client, nil
|
return &client, nil
|
||||||
|
|
@ -681,10 +681,10 @@ func TestContainerNames(t *testing.T) {
|
||||||
|
|
||||||
newClientFunc := func(string, *tls.Config) (Client, error) {
|
newClientFunc := func(string, *tls.Config) (Client, error) {
|
||||||
client := baseClient
|
client := baseClient
|
||||||
client.ContainerListF = func(typeContainer.ListOptions) ([]types.Container, error) {
|
client.ContainerListF = func(container.ListOptions) ([]types.Container, error) {
|
||||||
return containerList, nil
|
return containerList, nil
|
||||||
}
|
}
|
||||||
client.ContainerStatsF = func(s string) (typeContainer.StatsResponseReader, error) {
|
client.ContainerStatsF = func(s string) (container.StatsResponseReader, error) {
|
||||||
return containerStats(s), nil
|
return containerStats(s), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -891,7 +891,7 @@ func TestContainerStatus(t *testing.T) {
|
||||||
acc testutil.Accumulator
|
acc testutil.Accumulator
|
||||||
newClientFunc = func(string, *tls.Config) (Client, error) {
|
newClientFunc = func(string, *tls.Config) (Client, error) {
|
||||||
client := baseClient
|
client := baseClient
|
||||||
client.ContainerListF = func(typeContainer.ListOptions) ([]types.Container, error) {
|
client.ContainerListF = func(container.ListOptions) ([]types.Container, error) {
|
||||||
return containerList[:1], nil
|
return containerList[:1], nil
|
||||||
}
|
}
|
||||||
client.ContainerInspectF = func() (types.ContainerJSON, error) {
|
client.ContainerInspectF = func() (types.ContainerJSON, error) {
|
||||||
|
|
@ -1176,7 +1176,7 @@ func TestContainerStateFilter(t *testing.T) {
|
||||||
|
|
||||||
newClientFunc := func(string, *tls.Config) (Client, error) {
|
newClientFunc := func(string, *tls.Config) (Client, error) {
|
||||||
client := baseClient
|
client := baseClient
|
||||||
client.ContainerListF = func(options typeContainer.ListOptions) ([]types.Container, error) {
|
client.ContainerListF = func(options container.ListOptions) ([]types.Container, error) {
|
||||||
for k, v := range tt.expected {
|
for k, v := range tt.expected {
|
||||||
actual := options.Filters.Get(k)
|
actual := options.Filters.Get(k)
|
||||||
sort.Strings(actual)
|
sort.Strings(actual)
|
||||||
|
|
@ -1212,15 +1212,15 @@ func TestContainerName(t *testing.T) {
|
||||||
name: "container stats name is preferred",
|
name: "container stats name is preferred",
|
||||||
clientFunc: func(string, *tls.Config) (Client, error) {
|
clientFunc: func(string, *tls.Config) (Client, error) {
|
||||||
client := baseClient
|
client := baseClient
|
||||||
client.ContainerListF = func(typeContainer.ListOptions) ([]types.Container, error) {
|
client.ContainerListF = func(container.ListOptions) ([]types.Container, error) {
|
||||||
var containers []types.Container
|
var containers []types.Container
|
||||||
containers = append(containers, types.Container{
|
containers = append(containers, types.Container{
|
||||||
Names: []string{"/logspout/foo"},
|
Names: []string{"/logspout/foo"},
|
||||||
})
|
})
|
||||||
return containers, nil
|
return containers, nil
|
||||||
}
|
}
|
||||||
client.ContainerStatsF = func(string) (typeContainer.StatsResponseReader, error) {
|
client.ContainerStatsF = func(string) (container.StatsResponseReader, error) {
|
||||||
return typeContainer.StatsResponseReader{
|
return container.StatsResponseReader{
|
||||||
Body: io.NopCloser(strings.NewReader(`{"name": "logspout"}`)),
|
Body: io.NopCloser(strings.NewReader(`{"name": "logspout"}`)),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
@ -1232,15 +1232,15 @@ func TestContainerName(t *testing.T) {
|
||||||
name: "container stats without name uses container list name",
|
name: "container stats without name uses container list name",
|
||||||
clientFunc: func(string, *tls.Config) (Client, error) {
|
clientFunc: func(string, *tls.Config) (Client, error) {
|
||||||
client := baseClient
|
client := baseClient
|
||||||
client.ContainerListF = func(typeContainer.ListOptions) ([]types.Container, error) {
|
client.ContainerListF = func(container.ListOptions) ([]types.Container, error) {
|
||||||
var containers []types.Container
|
var containers []types.Container
|
||||||
containers = append(containers, types.Container{
|
containers = append(containers, types.Container{
|
||||||
Names: []string{"/logspout"},
|
Names: []string{"/logspout"},
|
||||||
})
|
})
|
||||||
return containers, nil
|
return containers, nil
|
||||||
}
|
}
|
||||||
client.ContainerStatsF = func(string) (typeContainer.StatsResponseReader, error) {
|
client.ContainerStatsF = func(string) (container.StatsResponseReader, error) {
|
||||||
return typeContainer.StatsResponseReader{
|
return container.StatsResponseReader{
|
||||||
Body: io.NopCloser(strings.NewReader(`{}`)),
|
Body: io.NopCloser(strings.NewReader(`{}`)),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
@ -1304,7 +1304,7 @@ func TestHostnameFromID(t *testing.T) {
|
||||||
|
|
||||||
func Test_parseContainerStatsPerDeviceAndTotal(t *testing.T) {
|
func Test_parseContainerStatsPerDeviceAndTotal(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
stat *typeContainer.StatsResponse
|
stat *container.StatsResponse
|
||||||
tags map[string]string
|
tags map[string]string
|
||||||
id string
|
id string
|
||||||
perDeviceInclude []string
|
perDeviceInclude []string
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import (
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
typeContainer "github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/pkg/stdcopy"
|
"github.com/docker/docker/pkg/stdcopy"
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/filter"
|
"github.com/influxdata/telegraf/filter"
|
||||||
"github.com/influxdata/telegraf/internal/docker"
|
"github.com/influxdata/telegraf/internal/docker"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ type DockerLogs struct {
|
||||||
ContainerStateExclude []string `toml:"container_state_exclude"`
|
ContainerStateExclude []string `toml:"container_state_exclude"`
|
||||||
IncludeSourceTag bool `toml:"source_tag"`
|
IncludeSourceTag bool `toml:"source_tag"`
|
||||||
|
|
||||||
tlsint.ClientConfig
|
common_tls.ClientConfig
|
||||||
|
|
||||||
newEnvClient func() (Client, error)
|
newEnvClient func() (Client, error)
|
||||||
newClient func(string, *tls.Config) (Client, error)
|
newClient func(string, *tls.Config) (Client, error)
|
||||||
|
|
@ -62,7 +62,7 @@ type DockerLogs struct {
|
||||||
labelFilter filter.Filter
|
labelFilter filter.Filter
|
||||||
containerFilter filter.Filter
|
containerFilter filter.Filter
|
||||||
stateFilter filter.Filter
|
stateFilter filter.Filter
|
||||||
opts typeContainer.ListOptions
|
opts container.ListOptions
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
containerList map[string]context.CancelFunc
|
containerList map[string]context.CancelFunc
|
||||||
|
|
@ -117,7 +117,7 @@ func (d *DockerLogs) Init() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if filterArgs.Len() != 0 {
|
if filterArgs.Len() != 0 {
|
||||||
d.opts = typeContainer.ListOptions{
|
d.opts = container.ListOptions{
|
||||||
Filters: filterArgs,
|
Filters: filterArgs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -206,18 +206,18 @@ func (d *DockerLogs) Gather(acc telegraf.Accumulator) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, container := range containers {
|
for _, cntnr := range containers {
|
||||||
if d.containerInContainerList(container.ID) {
|
if d.containerInContainerList(cntnr.ID) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
containerName := d.matchedContainerName(container.Names)
|
containerName := d.matchedContainerName(cntnr.Names)
|
||||||
if containerName == "" {
|
if containerName == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
d.addToContainerList(container.ID, cancel)
|
d.addToContainerList(cntnr.ID, cancel)
|
||||||
|
|
||||||
// Start a new goroutine for every new container that has logs to collect
|
// Start a new goroutine for every new container that has logs to collect
|
||||||
d.wg.Add(1)
|
d.wg.Add(1)
|
||||||
|
|
@ -229,15 +229,15 @@ func (d *DockerLogs) Gather(acc telegraf.Accumulator) error {
|
||||||
if err != nil && !errors.Is(err, context.Canceled) {
|
if err != nil && !errors.Is(err, context.Canceled) {
|
||||||
acc.AddError(err)
|
acc.AddError(err)
|
||||||
}
|
}
|
||||||
}(container)
|
}(cntnr)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DockerLogs) hasTTY(ctx context.Context, container types.Container) (bool, error) {
|
func (d *DockerLogs) hasTTY(ctx context.Context, cntnr types.Container) (bool, error) {
|
||||||
ctx, cancel := context.WithTimeout(ctx, time.Duration(d.Timeout))
|
ctx, cancel := context.WithTimeout(ctx, time.Duration(d.Timeout))
|
||||||
defer cancel()
|
defer cancel()
|
||||||
c, err := d.client.ContainerInspect(ctx, container.ID)
|
c, err := d.client.ContainerInspect(ctx, cntnr.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
@ -247,10 +247,10 @@ func (d *DockerLogs) hasTTY(ctx context.Context, container types.Container) (boo
|
||||||
func (d *DockerLogs) tailContainerLogs(
|
func (d *DockerLogs) tailContainerLogs(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
acc telegraf.Accumulator,
|
acc telegraf.Accumulator,
|
||||||
container types.Container,
|
cntnr types.Container,
|
||||||
containerName string,
|
containerName string,
|
||||||
) error {
|
) error {
|
||||||
imageName, imageVersion := docker.ParseImage(container.Image)
|
imageName, imageVersion := docker.ParseImage(cntnr.Image)
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"container_name": containerName,
|
"container_name": containerName,
|
||||||
"container_image": imageName,
|
"container_image": imageName,
|
||||||
|
|
@ -258,17 +258,17 @@ func (d *DockerLogs) tailContainerLogs(
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.IncludeSourceTag {
|
if d.IncludeSourceTag {
|
||||||
tags["source"] = hostnameFromID(container.ID)
|
tags["source"] = hostnameFromID(cntnr.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add matching container labels as tags
|
// Add matching container labels as tags
|
||||||
for k, label := range container.Labels {
|
for k, label := range cntnr.Labels {
|
||||||
if d.labelFilter.Match(k) {
|
if d.labelFilter.Match(k) {
|
||||||
tags[k] = label
|
tags[k] = label
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hasTTY, err := d.hasTTY(ctx, container)
|
hasTTY, err := d.hasTTY(ctx, cntnr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -276,13 +276,13 @@ func (d *DockerLogs) tailContainerLogs(
|
||||||
since := time.Time{}.Format(time.RFC3339Nano)
|
since := time.Time{}.Format(time.RFC3339Nano)
|
||||||
if !d.FromBeginning {
|
if !d.FromBeginning {
|
||||||
d.lastRecordMtx.Lock()
|
d.lastRecordMtx.Lock()
|
||||||
if ts, ok := d.lastRecord[container.ID]; ok {
|
if ts, ok := d.lastRecord[cntnr.ID]; ok {
|
||||||
since = ts.Format(time.RFC3339Nano)
|
since = ts.Format(time.RFC3339Nano)
|
||||||
}
|
}
|
||||||
d.lastRecordMtx.Unlock()
|
d.lastRecordMtx.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
logOptions := typeContainer.LogsOptions{
|
logOptions := container.LogsOptions{
|
||||||
ShowStdout: true,
|
ShowStdout: true,
|
||||||
ShowStderr: true,
|
ShowStderr: true,
|
||||||
Timestamps: true,
|
Timestamps: true,
|
||||||
|
|
@ -291,7 +291,7 @@ func (d *DockerLogs) tailContainerLogs(
|
||||||
Since: since,
|
Since: since,
|
||||||
}
|
}
|
||||||
|
|
||||||
logReader, err := d.client.ContainerLogs(ctx, container.ID, logOptions)
|
logReader, err := d.client.ContainerLogs(ctx, cntnr.ID, logOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -304,17 +304,17 @@ func (d *DockerLogs) tailContainerLogs(
|
||||||
// multiplexed.
|
// multiplexed.
|
||||||
var last time.Time
|
var last time.Time
|
||||||
if hasTTY {
|
if hasTTY {
|
||||||
last, err = tailStream(acc, tags, container.ID, logReader, "tty")
|
last, err = tailStream(acc, tags, cntnr.ID, logReader, "tty")
|
||||||
} else {
|
} else {
|
||||||
last, err = tailMultiplexed(acc, tags, container.ID, logReader)
|
last, err = tailMultiplexed(acc, tags, cntnr.ID, logReader)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if ts, ok := d.lastRecord[container.ID]; !ok || ts.Before(last) {
|
if ts, ok := d.lastRecord[cntnr.ID]; !ok || ts.Before(last) {
|
||||||
d.lastRecordMtx.Lock()
|
d.lastRecordMtx.Lock()
|
||||||
d.lastRecord[container.ID] = last
|
d.lastRecord[cntnr.ID] = last
|
||||||
d.lastRecordMtx.Unlock()
|
d.lastRecordMtx.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
jsonparser "github.com/influxdata/telegraf/plugins/parsers/json"
|
parsers_json "github.com/influxdata/telegraf/plugins/parsers/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -159,7 +159,7 @@ func (conn *dpdkConnector) processCommand(acc telegraf.Accumulator, log telegraf
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
jf := jsonparser.JSONFlattener{}
|
jf := parsers_json.JSONFlattener{}
|
||||||
err = jf.FullFlattenJSON("", value, true, true)
|
err = jf.FullFlattenJSON("", value, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
acc.AddError(fmt.Errorf("failed to flatten response: %w", err))
|
acc.AddError(fmt.Errorf("failed to flatten response: %w", err))
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/filter"
|
"github.com/influxdata/telegraf/filter"
|
||||||
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
jsonparser "github.com/influxdata/telegraf/plugins/parsers/json"
|
parsers_json "github.com/influxdata/telegraf/plugins/parsers/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed sample.conf
|
//go:embed sample.conf
|
||||||
|
|
@ -132,7 +132,7 @@ type Elasticsearch struct {
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
|
|
||||||
client *http.Client
|
client *http.Client
|
||||||
httpconfig.HTTPClientConfig
|
common_http.HTTPClientConfig
|
||||||
|
|
||||||
serverInfo map[string]serverInfo
|
serverInfo map[string]serverInfo
|
||||||
serverInfoMutex sync.Mutex
|
serverInfoMutex sync.Mutex
|
||||||
|
|
@ -152,7 +152,7 @@ func NewElasticsearch() *Elasticsearch {
|
||||||
return &Elasticsearch{
|
return &Elasticsearch{
|
||||||
ClusterStatsOnlyFromMaster: true,
|
ClusterStatsOnlyFromMaster: true,
|
||||||
ClusterHealthLevel: "indices",
|
ClusterHealthLevel: "indices",
|
||||||
HTTPClientConfig: httpconfig.HTTPClientConfig{
|
HTTPClientConfig: common_http.HTTPClientConfig{
|
||||||
ResponseHeaderTimeout: config.Duration(5 * time.Second),
|
ResponseHeaderTimeout: config.Duration(5 * time.Second),
|
||||||
Timeout: config.Duration(5 * time.Second),
|
Timeout: config.Duration(5 * time.Second),
|
||||||
},
|
},
|
||||||
|
|
@ -401,7 +401,7 @@ func (e *Elasticsearch) gatherNodeStats(url string, acc telegraf.Accumulator) er
|
||||||
if s == nil {
|
if s == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
f := jsonparser.JSONFlattener{}
|
f := parsers_json.JSONFlattener{}
|
||||||
// parse Json, ignoring strings and bools
|
// parse Json, ignoring strings and bools
|
||||||
err := f.FlattenJSON("", s)
|
err := f.FlattenJSON("", s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -523,7 +523,7 @@ func (e *Elasticsearch) gatherClusterStats(url string, acc telegraf.Accumulator)
|
||||||
}
|
}
|
||||||
|
|
||||||
for p, s := range stats {
|
for p, s := range stats {
|
||||||
f := jsonparser.JSONFlattener{}
|
f := parsers_json.JSONFlattener{}
|
||||||
// parse json, including bools and strings
|
// parse json, including bools and strings
|
||||||
err := f.FullFlattenJSON("", s, true, true)
|
err := f.FullFlattenJSON("", s, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -557,7 +557,7 @@ func (e *Elasticsearch) gatherIndicesStats(url string, acc telegraf.Accumulator)
|
||||||
// All Stats
|
// All Stats
|
||||||
for m, s := range indicesStats.All {
|
for m, s := range indicesStats.All {
|
||||||
// parse Json, ignoring strings and bools
|
// parse Json, ignoring strings and bools
|
||||||
jsonParser := jsonparser.JSONFlattener{}
|
jsonParser := parsers_json.JSONFlattener{}
|
||||||
err := jsonParser.FullFlattenJSON("_", s, true, true)
|
err := jsonParser.FullFlattenJSON("_", s, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -639,7 +639,7 @@ func (e *Elasticsearch) gatherSingleIndexStats(name string, index indexStat, now
|
||||||
"total": index.Total,
|
"total": index.Total,
|
||||||
}
|
}
|
||||||
for m, s := range stats {
|
for m, s := range stats {
|
||||||
f := jsonparser.JSONFlattener{}
|
f := parsers_json.JSONFlattener{}
|
||||||
// parse Json, getting strings and bools
|
// parse Json, getting strings and bools
|
||||||
err := f.FullFlattenJSON("", s, true, true)
|
err := f.FullFlattenJSON("", s, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -652,7 +652,7 @@ func (e *Elasticsearch) gatherSingleIndexStats(name string, index indexStat, now
|
||||||
for shardNumber, shards := range index.Shards {
|
for shardNumber, shards := range index.Shards {
|
||||||
for _, shard := range shards {
|
for _, shard := range shards {
|
||||||
// Get Shard Stats
|
// Get Shard Stats
|
||||||
flattened := jsonparser.JSONFlattener{}
|
flattened := parsers_json.JSONFlattener{}
|
||||||
err := flattened.FullFlattenJSON("", shard, true, true)
|
err := flattened.FullFlattenJSON("", shard, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ type ElasticsearchQuery struct {
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
|
|
||||||
httpclient *http.Client
|
httpclient *http.Client
|
||||||
httpconfig.HTTPClientConfig
|
common_http.HTTPClientConfig
|
||||||
|
|
||||||
esClient *elastic5.Client
|
esClient *elastic5.Client
|
||||||
}
|
}
|
||||||
|
|
@ -242,7 +242,7 @@ func init() {
|
||||||
inputs.Add("elasticsearch_query", func() telegraf.Input {
|
inputs.Add("elasticsearch_query", func() telegraf.Input {
|
||||||
return &ElasticsearchQuery{
|
return &ElasticsearchQuery{
|
||||||
HealthCheckInterval: config.Duration(time.Second * 10),
|
HealthCheckInterval: config.Duration(time.Second * 10),
|
||||||
HTTPClientConfig: httpconfig.HTTPClientConfig{
|
HTTPClientConfig: common_http.HTTPClientConfig{
|
||||||
ResponseHeaderTimeout: config.Duration(5 * time.Second),
|
ResponseHeaderTimeout: config.Duration(5 * time.Second),
|
||||||
Timeout: config.Duration(5 * time.Second),
|
Timeout: config.Duration(5 * time.Second),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -538,7 +538,7 @@ func setupIntegrationTest(t *testing.T) (*testutil.Container, error) {
|
||||||
)
|
)
|
||||||
e := &ElasticsearchQuery{
|
e := &ElasticsearchQuery{
|
||||||
URLs: []string{url},
|
URLs: []string{url},
|
||||||
HTTPClientConfig: httpconfig.HTTPClientConfig{
|
HTTPClientConfig: common_http.HTTPClientConfig{
|
||||||
ResponseHeaderTimeout: config.Duration(30 * time.Second),
|
ResponseHeaderTimeout: config.Duration(30 * time.Second),
|
||||||
Timeout: config.Duration(30 * time.Second),
|
Timeout: config.Duration(30 * time.Second),
|
||||||
},
|
},
|
||||||
|
|
@ -618,7 +618,7 @@ func TestElasticsearchQueryIntegration(t *testing.T) {
|
||||||
URLs: []string{
|
URLs: []string{
|
||||||
fmt.Sprintf("http://%s:%s", container.Address, container.Ports[servicePort]),
|
fmt.Sprintf("http://%s:%s", container.Address, container.Ports[servicePort]),
|
||||||
},
|
},
|
||||||
HTTPClientConfig: httpconfig.HTTPClientConfig{
|
HTTPClientConfig: common_http.HTTPClientConfig{
|
||||||
ResponseHeaderTimeout: config.Duration(30 * time.Second),
|
ResponseHeaderTimeout: config.Duration(30 * time.Second),
|
||||||
Timeout: config.Duration(30 * time.Second),
|
Timeout: config.Duration(30 * time.Second),
|
||||||
},
|
},
|
||||||
|
|
@ -684,7 +684,7 @@ func TestElasticsearchQueryIntegration_getMetricFields(t *testing.T) {
|
||||||
URLs: []string{
|
URLs: []string{
|
||||||
fmt.Sprintf("http://%s:%s", container.Address, container.Ports[servicePort]),
|
fmt.Sprintf("http://%s:%s", container.Address, container.Ports[servicePort]),
|
||||||
},
|
},
|
||||||
HTTPClientConfig: httpconfig.HTTPClientConfig{
|
HTTPClientConfig: common_http.HTTPClientConfig{
|
||||||
ResponseHeaderTimeout: config.Duration(30 * time.Second),
|
ResponseHeaderTimeout: config.Duration(30 * time.Second),
|
||||||
Timeout: config.Duration(30 * time.Second),
|
Timeout: config.Duration(30 * time.Second),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
ethtoolLib "github.com/safchain/ethtool"
|
"github.com/safchain/ethtool"
|
||||||
"github.com/vishvananda/netns"
|
"github.com/vishvananda/netns"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -24,7 +24,7 @@ type NamespacedResult struct {
|
||||||
type NamespaceGoroutine struct {
|
type NamespaceGoroutine struct {
|
||||||
name string
|
name string
|
||||||
handle netns.NsHandle
|
handle netns.NsHandle
|
||||||
ethtoolClient *ethtoolLib.Ethtool
|
ethtoolClient *ethtool.Ethtool
|
||||||
c chan NamespacedAction
|
c chan NamespacedAction
|
||||||
Log telegraf.Logger
|
Log telegraf.Logger
|
||||||
}
|
}
|
||||||
|
|
@ -71,7 +71,7 @@ func (n *NamespaceGoroutine) Stats(intf NamespacedInterface) (map[string]uint64,
|
||||||
|
|
||||||
func (n *NamespaceGoroutine) Get(intf NamespacedInterface) (map[string]uint64, error) {
|
func (n *NamespaceGoroutine) Get(intf NamespacedInterface) (map[string]uint64, error) {
|
||||||
result, err := n.Do(func(n *NamespaceGoroutine) (interface{}, error) {
|
result, err := n.Do(func(n *NamespaceGoroutine) (interface{}, error) {
|
||||||
ecmd := ethtoolLib.EthtoolCmd{}
|
ecmd := ethtool.EthtoolCmd{}
|
||||||
speed32, err := n.ethtoolClient.CmdGet(&ecmd, intf.Name)
|
speed32, err := n.ethtoolClient.CmdGet(&ecmd, intf.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -134,7 +134,7 @@ func (n *NamespaceGoroutine) Start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Every namespace needs its own connection to ethtool
|
// Every namespace needs its own connection to ethtool
|
||||||
e, err := ethtoolLib.NewEthtool()
|
e, err := ethtool.NewEthtool()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
n.Log.Errorf("Could not create ethtool client for namespace %q: %s", n.name, err.Error())
|
n.Log.Errorf("Could not create ethtool client for namespace %q: %s", n.name, err.Error())
|
||||||
started <- err
|
started <- err
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
eventhubClient "github.com/Azure/azure-event-hubs-go/v3"
|
eventhub "github.com/Azure/azure-event-hubs-go/v3"
|
||||||
"github.com/Azure/azure-event-hubs-go/v3/persist"
|
"github.com/Azure/azure-event-hubs-go/v3/persist"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -62,7 +62,7 @@ type EventHub struct {
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
|
|
||||||
// Azure
|
// Azure
|
||||||
hub *eventhubClient.Hub
|
hub *eventhub.Hub
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
|
|
@ -91,7 +91,7 @@ func (e *EventHub) Init() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set hub options
|
// Set hub options
|
||||||
hubOpts := []eventhubClient.HubOption{}
|
hubOpts := []eventhub.HubOption{}
|
||||||
|
|
||||||
if e.PersistenceDir != "" {
|
if e.PersistenceDir != "" {
|
||||||
persister, err := persist.NewFilePersister(e.PersistenceDir)
|
persister, err := persist.NewFilePersister(e.PersistenceDir)
|
||||||
|
|
@ -99,20 +99,20 @@ func (e *EventHub) Init() (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
hubOpts = append(hubOpts, eventhubClient.HubWithOffsetPersistence(persister))
|
hubOpts = append(hubOpts, eventhub.HubWithOffsetPersistence(persister))
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.UserAgent != "" {
|
if e.UserAgent != "" {
|
||||||
hubOpts = append(hubOpts, eventhubClient.HubWithUserAgent(e.UserAgent))
|
hubOpts = append(hubOpts, eventhub.HubWithUserAgent(e.UserAgent))
|
||||||
} else {
|
} else {
|
||||||
hubOpts = append(hubOpts, eventhubClient.HubWithUserAgent(internal.ProductToken()))
|
hubOpts = append(hubOpts, eventhub.HubWithUserAgent(internal.ProductToken()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create event hub connection
|
// Create event hub connection
|
||||||
if e.ConnectionString != "" {
|
if e.ConnectionString != "" {
|
||||||
e.hub, err = eventhubClient.NewHubFromConnectionString(e.ConnectionString, hubOpts...)
|
e.hub, err = eventhub.NewHubFromConnectionString(e.ConnectionString, hubOpts...)
|
||||||
} else {
|
} else {
|
||||||
e.hub, err = eventhubClient.NewHubFromEnvironment(hubOpts...)
|
e.hub, err = eventhub.NewHubFromEnvironment(hubOpts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
@ -155,25 +155,25 @@ func (e *EventHub) Start(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EventHub) configureReceiver() []eventhubClient.ReceiveOption {
|
func (e *EventHub) configureReceiver() []eventhub.ReceiveOption {
|
||||||
receiveOpts := []eventhubClient.ReceiveOption{}
|
receiveOpts := []eventhub.ReceiveOption{}
|
||||||
|
|
||||||
if e.ConsumerGroup != "" {
|
if e.ConsumerGroup != "" {
|
||||||
receiveOpts = append(receiveOpts, eventhubClient.ReceiveWithConsumerGroup(e.ConsumerGroup))
|
receiveOpts = append(receiveOpts, eventhub.ReceiveWithConsumerGroup(e.ConsumerGroup))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !e.FromTimestamp.IsZero() {
|
if !e.FromTimestamp.IsZero() {
|
||||||
receiveOpts = append(receiveOpts, eventhubClient.ReceiveFromTimestamp(e.FromTimestamp))
|
receiveOpts = append(receiveOpts, eventhub.ReceiveFromTimestamp(e.FromTimestamp))
|
||||||
} else if e.Latest {
|
} else if e.Latest {
|
||||||
receiveOpts = append(receiveOpts, eventhubClient.ReceiveWithLatestOffset())
|
receiveOpts = append(receiveOpts, eventhub.ReceiveWithLatestOffset())
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.PrefetchCount != 0 {
|
if e.PrefetchCount != 0 {
|
||||||
receiveOpts = append(receiveOpts, eventhubClient.ReceiveWithPrefetchCount(e.PrefetchCount))
|
receiveOpts = append(receiveOpts, eventhub.ReceiveWithPrefetchCount(e.PrefetchCount))
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.Epoch != 0 {
|
if e.Epoch != 0 {
|
||||||
receiveOpts = append(receiveOpts, eventhubClient.ReceiveWithEpoch(e.Epoch))
|
receiveOpts = append(receiveOpts, eventhub.ReceiveWithEpoch(e.Epoch))
|
||||||
}
|
}
|
||||||
|
|
||||||
return receiveOpts
|
return receiveOpts
|
||||||
|
|
@ -182,7 +182,7 @@ func (e *EventHub) configureReceiver() []eventhubClient.ReceiveOption {
|
||||||
// OnMessage handles an Event. When this function returns without error the
|
// OnMessage handles an Event. When this function returns without error the
|
||||||
// Event is immediately accepted and the offset is updated. If an error is
|
// Event is immediately accepted and the offset is updated. If an error is
|
||||||
// returned the Event is marked for redelivery.
|
// returned the Event is marked for redelivery.
|
||||||
func (e *EventHub) onMessage(ctx context.Context, event *eventhubClient.Event) error {
|
func (e *EventHub) onMessage(ctx context.Context, event *eventhub.Event) error {
|
||||||
metrics, err := e.createMetrics(event)
|
metrics, err := e.createMetrics(event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -264,7 +264,7 @@ func deepCopyMetrics(in []telegraf.Metric) []telegraf.Metric {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateMetrics returns the Metrics from the Event.
|
// CreateMetrics returns the Metrics from the Event.
|
||||||
func (e *EventHub) createMetrics(event *eventhubClient.Event) ([]telegraf.Metric, error) {
|
func (e *EventHub) createMetrics(event *eventhub.Event) ([]telegraf.Metric, error) {
|
||||||
metrics, err := e.parser.Parse(event.Data)
|
metrics, err := e.parser.Parse(event.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,13 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
osExec "os/exec"
|
"os/exec"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/internal"
|
|
||||||
"github.com/kballard/go-shellquote"
|
"github.com/kballard/go-shellquote"
|
||||||
|
|
||||||
|
"github.com/influxdata/telegraf/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c CommandRunner) Run(
|
func (c CommandRunner) Run(
|
||||||
|
|
@ -24,7 +25,7 @@ func (c CommandRunner) Run(
|
||||||
return nil, nil, fmt.Errorf("exec: unable to parse command: %w", err)
|
return nil, nil, fmt.Errorf("exec: unable to parse command: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := osExec.Command(splitCmd[0], splitCmd[1:]...)
|
cmd := exec.Command(splitCmd[0], splitCmd[1:]...)
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||||
|
|
||||||
if len(environments) > 0 {
|
if len(environments) > 0 {
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,13 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
osExec "os/exec"
|
"os/exec"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/internal"
|
|
||||||
"github.com/kballard/go-shellquote"
|
"github.com/kballard/go-shellquote"
|
||||||
|
|
||||||
|
"github.com/influxdata/telegraf/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c CommandRunner) Run(
|
func (c CommandRunner) Run(
|
||||||
|
|
@ -24,7 +25,7 @@ func (c CommandRunner) Run(
|
||||||
return nil, nil, fmt.Errorf("exec: unable to parse command: %w", err)
|
return nil, nil, fmt.Errorf("exec: unable to parse command: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := osExec.Command(splitCmd[0], splitCmd[1:]...)
|
cmd := exec.Command(splitCmd[0], splitCmd[1:]...)
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||||
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP,
|
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"github.com/influxdata/telegraf/models"
|
"github.com/influxdata/telegraf/models"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/prometheus"
|
"github.com/influxdata/telegraf/plugins/parsers/prometheus"
|
||||||
influxSerializer "github.com/influxdata/telegraf/plugins/serializers/influx"
|
serializers_influx "github.com/influxdata/telegraf/plugins/serializers/influx"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -413,7 +413,7 @@ func TestMain(m *testing.M) {
|
||||||
|
|
||||||
func runCounterProgram() error {
|
func runCounterProgram() error {
|
||||||
envMetricName := os.Getenv("METRIC_NAME")
|
envMetricName := os.Getenv("METRIC_NAME")
|
||||||
serializer := &influxSerializer.Serializer{}
|
serializer := &serializers_influx.Serializer{}
|
||||||
if err := serializer.Init(); err != nil {
|
if err := serializer.Init(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
githubLib "github.com/google/go-github/v32/github"
|
"github.com/google/go-github/v32/github"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -30,7 +30,7 @@ type GitHub struct {
|
||||||
AdditionalFields []string `toml:"additional_fields"`
|
AdditionalFields []string `toml:"additional_fields"`
|
||||||
EnterpriseBaseURL string `toml:"enterprise_base_url"`
|
EnterpriseBaseURL string `toml:"enterprise_base_url"`
|
||||||
HTTPTimeout config.Duration `toml:"http_timeout"`
|
HTTPTimeout config.Duration `toml:"http_timeout"`
|
||||||
githubClient *githubLib.Client
|
githubClient *github.Client
|
||||||
|
|
||||||
obfuscatedToken string
|
obfuscatedToken string
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ type GitHub struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create GitHub Client
|
// Create GitHub Client
|
||||||
func (g *GitHub) createGitHubClient(ctx context.Context) (*githubLib.Client, error) {
|
func (g *GitHub) createGitHubClient(ctx context.Context) (*github.Client, error) {
|
||||||
httpClient := &http.Client{
|
httpClient := &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
|
@ -65,11 +65,11 @@ func (g *GitHub) createGitHubClient(ctx context.Context) (*githubLib.Client, err
|
||||||
return g.newGithubClient(httpClient)
|
return g.newGithubClient(httpClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GitHub) newGithubClient(httpClient *http.Client) (*githubLib.Client, error) {
|
func (g *GitHub) newGithubClient(httpClient *http.Client) (*github.Client, error) {
|
||||||
if g.EnterpriseBaseURL != "" {
|
if g.EnterpriseBaseURL != "" {
|
||||||
return githubLib.NewEnterpriseClient(g.EnterpriseBaseURL, "", httpClient)
|
return github.NewEnterpriseClient(g.EnterpriseBaseURL, "", httpClient)
|
||||||
}
|
}
|
||||||
return githubLib.NewClient(httpClient), nil
|
return github.NewClient(httpClient), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*GitHub) SampleConfig() string {
|
func (*GitHub) SampleConfig() string {
|
||||||
|
|
@ -148,8 +148,8 @@ func (g *GitHub) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GitHub) handleRateLimit(response *githubLib.Response, err error) {
|
func (g *GitHub) handleRateLimit(response *github.Response, err error) {
|
||||||
var rlErr *githubLib.RateLimitError
|
var rlErr *github.RateLimitError
|
||||||
if err == nil {
|
if err == nil {
|
||||||
g.RateLimit.Set(int64(response.Rate.Limit))
|
g.RateLimit.Set(int64(response.Rate.Limit))
|
||||||
g.RateRemaining.Set(int64(response.Rate.Remaining))
|
g.RateRemaining.Set(int64(response.Rate.Remaining))
|
||||||
|
|
@ -168,7 +168,7 @@ func splitRepositoryName(repositoryName string) (owner, repository string, err e
|
||||||
return splits[0], splits[1], nil
|
return splits[0], splits[1], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLicense(rI *githubLib.Repository) string {
|
func getLicense(rI *github.Repository) string {
|
||||||
if licenseName := rI.GetLicense().GetName(); licenseName != "" {
|
if licenseName := rI.GetLicense().GetName(); licenseName != "" {
|
||||||
return licenseName
|
return licenseName
|
||||||
}
|
}
|
||||||
|
|
@ -176,7 +176,7 @@ func getLicense(rI *githubLib.Repository) string {
|
||||||
return "None"
|
return "None"
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTags(repositoryInfo *githubLib.Repository) map[string]string {
|
func getTags(repositoryInfo *github.Repository) map[string]string {
|
||||||
return map[string]string{
|
return map[string]string{
|
||||||
"owner": repositoryInfo.GetOwner().GetLogin(),
|
"owner": repositoryInfo.GetOwner().GetLogin(),
|
||||||
"name": repositoryInfo.GetName(),
|
"name": repositoryInfo.GetName(),
|
||||||
|
|
@ -185,7 +185,7 @@ func getTags(repositoryInfo *githubLib.Repository) map[string]string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFields(repositoryInfo *githubLib.Repository) map[string]interface{} {
|
func getFields(repositoryInfo *github.Repository) map[string]interface{} {
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
"stars": repositoryInfo.GetStargazersCount(),
|
"stars": repositoryInfo.GetStargazersCount(),
|
||||||
"subscribers": repositoryInfo.GetSubscribersCount(),
|
"subscribers": repositoryInfo.GetSubscribersCount(),
|
||||||
|
|
@ -198,9 +198,9 @@ func getFields(repositoryInfo *githubLib.Repository) map[string]interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GitHub) getPullRequestFields(ctx context.Context, owner, repo string) (map[string]interface{}, error) {
|
func (g *GitHub) getPullRequestFields(ctx context.Context, owner, repo string) (map[string]interface{}, error) {
|
||||||
options := githubLib.SearchOptions{
|
options := github.SearchOptions{
|
||||||
TextMatch: false,
|
TextMatch: false,
|
||||||
ListOptions: githubLib.ListOptions{
|
ListOptions: github.ListOptions{
|
||||||
PerPage: 100,
|
PerPage: 100,
|
||||||
Page: 1,
|
Page: 1,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,14 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/gnxi/utils/xpath"
|
"github.com/google/gnxi/utils/xpath"
|
||||||
gnmiLib "github.com/openconfig/gnmi/proto/gnmi"
|
"github.com/openconfig/gnmi/proto/gnmi"
|
||||||
"google.golang.org/grpc/keepalive"
|
"google.golang.org/grpc/keepalive"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/internal/choice"
|
"github.com/influxdata/telegraf/internal/choice"
|
||||||
internaltls "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/common/yangmodel"
|
"github.com/influxdata/telegraf/plugins/common/yangmodel"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
@ -65,7 +65,7 @@ type GNMI struct {
|
||||||
KeepaliveTimeout config.Duration `toml:"keepalive_timeout"`
|
KeepaliveTimeout config.Duration `toml:"keepalive_timeout"`
|
||||||
YangModelPaths []string `toml:"yang_model_paths"`
|
YangModelPaths []string `toml:"yang_model_paths"`
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
internaltls.ClientConfig
|
common_tls.ClientConfig
|
||||||
|
|
||||||
// Internal state
|
// Internal state
|
||||||
internalAliases map[*pathInfo]string
|
internalAliases map[*pathInfo]string
|
||||||
|
|
@ -85,7 +85,7 @@ type Subscription struct {
|
||||||
HeartbeatInterval config.Duration `toml:"heartbeat_interval"`
|
HeartbeatInterval config.Duration `toml:"heartbeat_interval"`
|
||||||
TagOnly bool `toml:"tag_only" deprecated:"1.25.0;1.35.0;please use 'tag_subscription's instead"`
|
TagOnly bool `toml:"tag_only" deprecated:"1.25.0;1.35.0;please use 'tag_subscription's instead"`
|
||||||
|
|
||||||
fullPath *gnmiLib.Path
|
fullPath *gnmi.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tag Subscription for a gNMI client
|
// Tag Subscription for a gNMI client
|
||||||
|
|
@ -201,15 +201,15 @@ func (c *GNMI) Init() error {
|
||||||
c.Log.Debugf("Internal alias mapping: %+v", c.internalAliases)
|
c.Log.Debugf("Internal alias mapping: %+v", c.internalAliases)
|
||||||
|
|
||||||
// Warn about configures insecure cipher suites
|
// Warn about configures insecure cipher suites
|
||||||
insecure := internaltls.InsecureCiphers(c.ClientConfig.TLSCipherSuites)
|
insecure := common_tls.InsecureCiphers(c.ClientConfig.TLSCipherSuites)
|
||||||
if len(insecure) > 0 {
|
if len(insecure) > 0 {
|
||||||
c.Log.Warnf("Configured insecure cipher suites: %s", strings.Join(insecure, ","))
|
c.Log.Warnf("Configured insecure cipher suites: %s", strings.Join(insecure, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the TLS configuration
|
// Check the TLS configuration
|
||||||
if _, err := c.ClientConfig.TLSConfig(); err != nil {
|
if _, err := c.ClientConfig.TLSConfig(); err != nil {
|
||||||
if errors.Is(err, internaltls.ErrCipherUnsupported) {
|
if errors.Is(err, common_tls.ErrCipherUnsupported) {
|
||||||
secure, insecure := internaltls.Ciphers()
|
secure, insecure := common_tls.Ciphers()
|
||||||
c.Log.Info("Supported secure ciphers:")
|
c.Log.Info("Supported secure ciphers:")
|
||||||
for _, name := range secure {
|
for _, name := range secure {
|
||||||
c.Log.Infof(" %s", name)
|
c.Log.Infof(" %s", name)
|
||||||
|
|
@ -310,18 +310,18 @@ func (c *GNMI) Start(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Subscription) buildSubscription() (*gnmiLib.Subscription, error) {
|
func (s *Subscription) buildSubscription() (*gnmi.Subscription, error) {
|
||||||
gnmiPath, err := parsePath(s.Origin, s.Path, "")
|
gnmiPath, err := parsePath(s.Origin, s.Path, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mode, ok := gnmiLib.SubscriptionMode_value[strings.ToUpper(s.SubscriptionMode)]
|
mode, ok := gnmi.SubscriptionMode_value[strings.ToUpper(s.SubscriptionMode)]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("invalid subscription mode %s", s.SubscriptionMode)
|
return nil, fmt.Errorf("invalid subscription mode %s", s.SubscriptionMode)
|
||||||
}
|
}
|
||||||
return &gnmiLib.Subscription{
|
return &gnmi.Subscription{
|
||||||
Path: gnmiPath,
|
Path: gnmiPath,
|
||||||
Mode: gnmiLib.SubscriptionMode(mode),
|
Mode: gnmi.SubscriptionMode(mode),
|
||||||
HeartbeatInterval: uint64(time.Duration(s.HeartbeatInterval).Nanoseconds()),
|
HeartbeatInterval: uint64(time.Duration(s.HeartbeatInterval).Nanoseconds()),
|
||||||
SampleInterval: uint64(time.Duration(s.SampleInterval).Nanoseconds()),
|
SampleInterval: uint64(time.Duration(s.SampleInterval).Nanoseconds()),
|
||||||
SuppressRedundant: s.SuppressRedundant,
|
SuppressRedundant: s.SuppressRedundant,
|
||||||
|
|
@ -329,9 +329,9 @@ func (s *Subscription) buildSubscription() (*gnmiLib.Subscription, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new gNMI SubscribeRequest
|
// Create a new gNMI SubscribeRequest
|
||||||
func (c *GNMI) newSubscribeRequest() (*gnmiLib.SubscribeRequest, error) {
|
func (c *GNMI) newSubscribeRequest() (*gnmi.SubscribeRequest, error) {
|
||||||
// Create subscription objects
|
// Create subscription objects
|
||||||
subscriptions := make([]*gnmiLib.Subscription, 0, len(c.Subscriptions)+len(c.TagSubscriptions))
|
subscriptions := make([]*gnmi.Subscription, 0, len(c.Subscriptions)+len(c.TagSubscriptions))
|
||||||
for _, subscription := range c.TagSubscriptions {
|
for _, subscription := range c.TagSubscriptions {
|
||||||
sub, err := subscription.buildSubscription()
|
sub, err := subscription.buildSubscription()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -363,12 +363,12 @@ func (c *GNMI) newSubscribeRequest() (*gnmiLib.SubscribeRequest, error) {
|
||||||
return nil, fmt.Errorf("unsupported encoding %s", c.Encoding)
|
return nil, fmt.Errorf("unsupported encoding %s", c.Encoding)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &gnmiLib.SubscribeRequest{
|
return &gnmi.SubscribeRequest{
|
||||||
Request: &gnmiLib.SubscribeRequest_Subscribe{
|
Request: &gnmi.SubscribeRequest_Subscribe{
|
||||||
Subscribe: &gnmiLib.SubscriptionList{
|
Subscribe: &gnmi.SubscriptionList{
|
||||||
Prefix: gnmiPath,
|
Prefix: gnmiPath,
|
||||||
Mode: gnmiLib.SubscriptionList_STREAM,
|
Mode: gnmi.SubscriptionList_STREAM,
|
||||||
Encoding: gnmiLib.Encoding(gnmiLib.Encoding_value[strings.ToUpper(c.Encoding)]),
|
Encoding: gnmi.Encoding(gnmi.Encoding_value[strings.ToUpper(c.Encoding)]),
|
||||||
Subscription: subscriptions,
|
Subscription: subscriptions,
|
||||||
UpdatesOnly: c.UpdatesOnly,
|
UpdatesOnly: c.UpdatesOnly,
|
||||||
},
|
},
|
||||||
|
|
@ -377,7 +377,7 @@ func (c *GNMI) newSubscribeRequest() (*gnmiLib.SubscribeRequest, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParsePath from XPath-like string to gNMI path structure
|
// ParsePath from XPath-like string to gNMI path structure
|
||||||
func parsePath(origin, pathToParse, target string) (*gnmiLib.Path, error) {
|
func parsePath(origin, pathToParse, target string) (*gnmi.Path, error) {
|
||||||
gnmiPath, err := xpath.ToGNMIPath(pathToParse)
|
gnmiPath, err := xpath.ToGNMIPath(pathToParse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
gnmiLib "github.com/openconfig/gnmi/proto/gnmi"
|
"github.com/openconfig/gnmi/proto/gnmi"
|
||||||
gnmiExt "github.com/openconfig/gnmi/proto/gnmi_ext"
|
"github.com/openconfig/gnmi/proto/gnmi_ext"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
jnprHeader "github.com/influxdata/telegraf/plugins/inputs/gnmi/extensions/jnpr_gnmi_extention"
|
"github.com/influxdata/telegraf/plugins/inputs/gnmi/extensions/jnpr_gnmi_extention"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
@ -34,12 +34,12 @@ func TestParsePath(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, "theorigin", parsed.Origin)
|
require.Equal(t, "theorigin", parsed.Origin)
|
||||||
require.Equal(t, "thetarget", parsed.Target)
|
require.Equal(t, "thetarget", parsed.Target)
|
||||||
require.Equal(t, []*gnmiLib.PathElem{{Name: "foo"}, {Name: "bar"},
|
require.Equal(t, []*gnmi.PathElem{{Name: "foo"}, {Name: "bar"},
|
||||||
{Name: "bla", Key: map[string]string{"shoo": "woo", "shoop": "/woop/"}}, {Name: "z"}}, parsed.Elem)
|
{Name: "bla", Key: map[string]string{"shoo": "woo", "shoop": "/woop/"}}, {Name: "z"}}, parsed.Elem)
|
||||||
|
|
||||||
parsed, err = parsePath("", "", "")
|
parsed, err = parsePath("", "", "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, &gnmiLib.Path{}, parsed)
|
require.Equal(t, &gnmi.Path{}, parsed)
|
||||||
|
|
||||||
parsed, err = parsePath("", "/foo[[", "")
|
parsed, err = parsePath("", "/foo[[", "")
|
||||||
require.Nil(t, parsed)
|
require.Nil(t, parsed)
|
||||||
|
|
@ -47,23 +47,23 @@ func TestParsePath(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type MockServer struct {
|
type MockServer struct {
|
||||||
SubscribeF func(gnmiLib.GNMI_SubscribeServer) error
|
SubscribeF func(gnmi.GNMI_SubscribeServer) error
|
||||||
GRPCServer *grpc.Server
|
GRPCServer *grpc.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MockServer) Capabilities(context.Context, *gnmiLib.CapabilityRequest) (*gnmiLib.CapabilityResponse, error) {
|
func (s *MockServer) Capabilities(context.Context, *gnmi.CapabilityRequest) (*gnmi.CapabilityResponse, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MockServer) Get(context.Context, *gnmiLib.GetRequest) (*gnmiLib.GetResponse, error) {
|
func (s *MockServer) Get(context.Context, *gnmi.GetRequest) (*gnmi.GetResponse, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MockServer) Set(context.Context, *gnmiLib.SetRequest) (*gnmiLib.SetResponse, error) {
|
func (s *MockServer) Set(context.Context, *gnmi.SetRequest) (*gnmi.SetResponse, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MockServer) Subscribe(server gnmiLib.GNMI_SubscribeServer) error {
|
func (s *MockServer) Subscribe(server gnmi.GNMI_SubscribeServer) error {
|
||||||
return s.SubscribeF(server)
|
return s.SubscribeF(server)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,12 +73,12 @@ func TestWaitError(t *testing.T) {
|
||||||
|
|
||||||
grpcServer := grpc.NewServer()
|
grpcServer := grpc.NewServer()
|
||||||
gnmiServer := &MockServer{
|
gnmiServer := &MockServer{
|
||||||
SubscribeF: func(gnmiLib.GNMI_SubscribeServer) error {
|
SubscribeF: func(gnmi.GNMI_SubscribeServer) error {
|
||||||
return errors.New("testerror")
|
return errors.New("testerror")
|
||||||
},
|
},
|
||||||
GRPCServer: grpcServer,
|
GRPCServer: grpcServer,
|
||||||
}
|
}
|
||||||
gnmiLib.RegisterGNMIServer(grpcServer, gnmiServer)
|
gnmi.RegisterGNMIServer(grpcServer, gnmiServer)
|
||||||
|
|
||||||
plugin := &GNMI{
|
plugin := &GNMI{
|
||||||
Log: testutil.Logger{},
|
Log: testutil.Logger{},
|
||||||
|
|
@ -115,7 +115,7 @@ func TestUsernamePassword(t *testing.T) {
|
||||||
|
|
||||||
grpcServer := grpc.NewServer()
|
grpcServer := grpc.NewServer()
|
||||||
gnmiServer := &MockServer{
|
gnmiServer := &MockServer{
|
||||||
SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error {
|
SubscribeF: func(server gnmi.GNMI_SubscribeServer) error {
|
||||||
metadata, ok := metadata.FromIncomingContext(server.Context())
|
metadata, ok := metadata.FromIncomingContext(server.Context())
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("failed to get metadata")
|
return errors.New("failed to get metadata")
|
||||||
|
|
@ -135,7 +135,7 @@ func TestUsernamePassword(t *testing.T) {
|
||||||
},
|
},
|
||||||
GRPCServer: grpcServer,
|
GRPCServer: grpcServer,
|
||||||
}
|
}
|
||||||
gnmiLib.RegisterGNMIServer(grpcServer, gnmiServer)
|
gnmi.RegisterGNMIServer(grpcServer, gnmiServer)
|
||||||
|
|
||||||
plugin := &GNMI{
|
plugin := &GNMI{
|
||||||
Log: testutil.Logger{},
|
Log: testutil.Logger{},
|
||||||
|
|
@ -168,12 +168,12 @@ func TestUsernamePassword(t *testing.T) {
|
||||||
require.ErrorContains(t, acc.Errors[0], "aborted gNMI subscription: rpc error: code = Unknown desc = success")
|
require.ErrorContains(t, acc.Errors[0], "aborted gNMI subscription: rpc error: code = Unknown desc = success")
|
||||||
}
|
}
|
||||||
|
|
||||||
func mockGNMINotification() *gnmiLib.Notification {
|
func mockGNMINotification() *gnmi.Notification {
|
||||||
return &gnmiLib.Notification{
|
return &gnmi.Notification{
|
||||||
Timestamp: 1543236572000000000,
|
Timestamp: 1543236572000000000,
|
||||||
Prefix: &gnmiLib.Path{
|
Prefix: &gnmi.Path{
|
||||||
Origin: "type",
|
Origin: "type",
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{
|
{
|
||||||
Name: "model",
|
Name: "model",
|
||||||
Key: map[string]string{"foo": "bar"},
|
Key: map[string]string{"foo": "bar"},
|
||||||
|
|
@ -181,35 +181,35 @@ func mockGNMINotification() *gnmiLib.Notification {
|
||||||
},
|
},
|
||||||
Target: "subscription",
|
Target: "subscription",
|
||||||
},
|
},
|
||||||
Update: []*gnmiLib.Update{
|
Update: []*gnmi.Update{
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "some"},
|
{Name: "some"},
|
||||||
{
|
{
|
||||||
Name: "path",
|
Name: "path",
|
||||||
Key: map[string]string{"name": "str", "uint64": "1234"}},
|
Key: map[string]string{"name": "str", "uint64": "1234"}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_IntVal{IntVal: 5678}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_IntVal{IntVal: 5678}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "other"},
|
{Name: "other"},
|
||||||
{Name: "path"},
|
{Name: "path"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_StringVal{StringVal: "foobar"}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_StringVal{StringVal: "foobar"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "other"},
|
{Name: "other"},
|
||||||
{Name: "this"},
|
{Name: "this"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_StringVal{StringVal: "that"}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_StringVal{StringVal: "that"}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -238,20 +238,20 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: &MockServer{
|
server: &MockServer{
|
||||||
SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error {
|
SubscribeF: func(server gnmi.GNMI_SubscribeServer) error {
|
||||||
notification := mockGNMINotification()
|
notification := mockGNMINotification()
|
||||||
err := server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_Update{Update: notification}})
|
err := server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_Update{Update: notification}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_SyncResponse{SyncResponse: true}})
|
err = server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_SyncResponse{SyncResponse: true}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
notification.Prefix.Elem[0].Key["foo"] = "bar2"
|
notification.Prefix.Elem[0].Key["foo"] = "bar2"
|
||||||
notification.Update[0].Path.Elem[1].Key["name"] = "str2"
|
notification.Update[0].Path.Elem[1].Key["name"] = "str2"
|
||||||
notification.Update[0].Val = &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_JsonVal{JsonVal: []byte{'"', '1', '2', '3', '"'}}}
|
notification.Update[0].Val = &gnmi.TypedValue{Value: &gnmi.TypedValue_JsonVal{JsonVal: []byte{'"', '1', '2', '3', '"'}}}
|
||||||
return server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_Update{Update: notification}})
|
return server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_Update{Update: notification}})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: []telegraf.Metric{
|
expected: []telegraf.Metric{
|
||||||
|
|
@ -327,14 +327,14 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: &MockServer{
|
server: &MockServer{
|
||||||
SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error {
|
SubscribeF: func(server gnmi.GNMI_SubscribeServer) error {
|
||||||
response := &gnmiLib.SubscribeResponse{
|
response := &gnmi.SubscribeResponse{
|
||||||
Response: &gnmiLib.SubscribeResponse_Update{
|
Response: &gnmi.SubscribeResponse_Update{
|
||||||
Update: &gnmiLib.Notification{
|
Update: &gnmi.Notification{
|
||||||
Timestamp: 1543236572000000000,
|
Timestamp: 1543236572000000000,
|
||||||
Prefix: &gnmiLib.Path{
|
Prefix: &gnmi.Path{
|
||||||
Origin: "type",
|
Origin: "type",
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{
|
{
|
||||||
Name: "state",
|
Name: "state",
|
||||||
},
|
},
|
||||||
|
|
@ -351,11 +351,11 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
Target: "subscription",
|
Target: "subscription",
|
||||||
},
|
},
|
||||||
Update: []*gnmiLib.Update{
|
Update: []*gnmi.Update{
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{},
|
Path: &gnmi.Path{},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_IntVal{IntVal: 42},
|
Value: &gnmi.TypedValue_IntVal{IntVal: 42},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -403,17 +403,17 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: &MockServer{
|
server: &MockServer{
|
||||||
SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error {
|
SubscribeF: func(server gnmi.GNMI_SubscribeServer) error {
|
||||||
tagResponse := &gnmiLib.SubscribeResponse{
|
tagResponse := &gnmi.SubscribeResponse{
|
||||||
Response: &gnmiLib.SubscribeResponse_Update{
|
Response: &gnmi.SubscribeResponse_Update{
|
||||||
Update: &gnmiLib.Notification{
|
Update: &gnmi.Notification{
|
||||||
Timestamp: 1543236571000000000,
|
Timestamp: 1543236571000000000,
|
||||||
Prefix: &gnmiLib.Path{},
|
Prefix: &gnmi.Path{},
|
||||||
Update: []*gnmiLib.Update{
|
Update: []*gnmi.Update{
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Origin: "",
|
Origin: "",
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{
|
{
|
||||||
Name: "interfaces",
|
Name: "interfaces",
|
||||||
},
|
},
|
||||||
|
|
@ -430,8 +430,8 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
Target: "",
|
Target: "",
|
||||||
},
|
},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_StringVal{StringVal: "foo"},
|
Value: &gnmi.TypedValue_StringVal{StringVal: "foo"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -441,19 +441,19 @@ func TestNotification(t *testing.T) {
|
||||||
if err := server.Send(tagResponse); err != nil {
|
if err := server.Send(tagResponse); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil {
|
if err := server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
taggedResponse := &gnmiLib.SubscribeResponse{
|
taggedResponse := &gnmi.SubscribeResponse{
|
||||||
Response: &gnmiLib.SubscribeResponse_Update{
|
Response: &gnmi.SubscribeResponse_Update{
|
||||||
Update: &gnmiLib.Notification{
|
Update: &gnmi.Notification{
|
||||||
Timestamp: 1543236572000000000,
|
Timestamp: 1543236572000000000,
|
||||||
Prefix: &gnmiLib.Path{},
|
Prefix: &gnmi.Path{},
|
||||||
Update: []*gnmiLib.Update{
|
Update: []*gnmi.Update{
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Origin: "",
|
Origin: "",
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{
|
{
|
||||||
Name: "interfaces",
|
Name: "interfaces",
|
||||||
},
|
},
|
||||||
|
|
@ -473,8 +473,8 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
Target: "",
|
Target: "",
|
||||||
},
|
},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_IntVal{IntVal: 42},
|
Value: &gnmi.TypedValue_IntVal{IntVal: 42},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -526,17 +526,17 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: &MockServer{
|
server: &MockServer{
|
||||||
SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error {
|
SubscribeF: func(server gnmi.GNMI_SubscribeServer) error {
|
||||||
tagResponse := &gnmiLib.SubscribeResponse{
|
tagResponse := &gnmi.SubscribeResponse{
|
||||||
Response: &gnmiLib.SubscribeResponse_Update{
|
Response: &gnmi.SubscribeResponse_Update{
|
||||||
Update: &gnmiLib.Notification{
|
Update: &gnmi.Notification{
|
||||||
Timestamp: 1543236571000000000,
|
Timestamp: 1543236571000000000,
|
||||||
Prefix: &gnmiLib.Path{},
|
Prefix: &gnmi.Path{},
|
||||||
Update: []*gnmiLib.Update{
|
Update: []*gnmi.Update{
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Origin: "",
|
Origin: "",
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{
|
{
|
||||||
Name: "network-instances",
|
Name: "network-instances",
|
||||||
},
|
},
|
||||||
|
|
@ -570,8 +570,8 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
Target: "",
|
Target: "",
|
||||||
},
|
},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_StringVal{StringVal: "EXAMPLE-PEER"},
|
Value: &gnmi.TypedValue_StringVal{StringVal: "EXAMPLE-PEER"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -581,19 +581,19 @@ func TestNotification(t *testing.T) {
|
||||||
if err := server.Send(tagResponse); err != nil {
|
if err := server.Send(tagResponse); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil {
|
if err := server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
taggedResponse := &gnmiLib.SubscribeResponse{
|
taggedResponse := &gnmi.SubscribeResponse{
|
||||||
Response: &gnmiLib.SubscribeResponse_Update{
|
Response: &gnmi.SubscribeResponse_Update{
|
||||||
Update: &gnmiLib.Notification{
|
Update: &gnmi.Notification{
|
||||||
Timestamp: 1543236572000000000,
|
Timestamp: 1543236572000000000,
|
||||||
Prefix: &gnmiLib.Path{},
|
Prefix: &gnmi.Path{},
|
||||||
Update: []*gnmiLib.Update{
|
Update: []*gnmi.Update{
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Origin: "",
|
Origin: "",
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{
|
{
|
||||||
Name: "network-instances",
|
Name: "network-instances",
|
||||||
},
|
},
|
||||||
|
|
@ -627,8 +627,8 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
Target: "",
|
Target: "",
|
||||||
},
|
},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_StringVal{StringVal: "ESTABLISHED"},
|
Value: &gnmi.TypedValue_StringVal{StringVal: "ESTABLISHED"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -674,17 +674,17 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: &MockServer{
|
server: &MockServer{
|
||||||
SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error {
|
SubscribeF: func(server gnmi.GNMI_SubscribeServer) error {
|
||||||
if err := server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil {
|
if err := server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
response := &gnmiLib.SubscribeResponse{
|
response := &gnmi.SubscribeResponse{
|
||||||
Response: &gnmiLib.SubscribeResponse_Update{
|
Response: &gnmi.SubscribeResponse_Update{
|
||||||
Update: &gnmiLib.Notification{
|
Update: &gnmi.Notification{
|
||||||
Timestamp: 1668762813698611837,
|
Timestamp: 1668762813698611837,
|
||||||
Prefix: &gnmiLib.Path{
|
Prefix: &gnmi.Path{
|
||||||
Origin: "openconfig",
|
Origin: "openconfig",
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "interfaces"},
|
{Name: "interfaces"},
|
||||||
{Name: "interface", Key: map[string]string{"name": "Ethernet1"}},
|
{Name: "interface", Key: map[string]string{"name": "Ethernet1"}},
|
||||||
{Name: "state"},
|
{Name: "state"},
|
||||||
|
|
@ -692,54 +692,54 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
Target: "OC-YANG",
|
Target: "OC-YANG",
|
||||||
},
|
},
|
||||||
Update: []*gnmiLib.Update{
|
Update: []*gnmi.Update{
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "in-broadcast-pkts"}}},
|
Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "in-broadcast-pkts"}}},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "in-discards"}}},
|
Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "in-discards"}}},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "in-errors"}}},
|
Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "in-errors"}}},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "in-fcs-errors"}}},
|
Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "in-fcs-errors"}}},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "in-unicast-pkts"}}},
|
Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "in-unicast-pkts"}}},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-broadcast-pkts"}}},
|
Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-broadcast-pkts"}}},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-discards"}}},
|
Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-discards"}}},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-errors"}}},
|
Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-errors"}}},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-multicast-pkts"}}},
|
Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-multicast-pkts"}}},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-octets"}}},
|
Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-octets"}}},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-pkts"}}},
|
Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-pkts"}}},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{Elem: []*gnmiLib.PathElem{{Name: "out-unicast-pkts"}}},
|
Path: &gnmi.Path{Elem: []*gnmi.PathElem{{Name: "out-unicast-pkts"}}},
|
||||||
Val: &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_UintVal{UintVal: 0}},
|
Val: &gnmi.TypedValue{Value: &gnmi.TypedValue_UintVal{UintVal: 0}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -791,90 +791,90 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: &MockServer{
|
server: &MockServer{
|
||||||
SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error {
|
SubscribeF: func(server gnmi.GNMI_SubscribeServer) error {
|
||||||
if err := server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil {
|
if err := server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
response := &gnmiLib.SubscribeResponse{
|
response := &gnmi.SubscribeResponse{
|
||||||
Response: &gnmiLib.SubscribeResponse_Update{
|
Response: &gnmi.SubscribeResponse_Update{
|
||||||
Update: &gnmiLib.Notification{
|
Update: &gnmi.Notification{
|
||||||
Timestamp: 1668771585733542546,
|
Timestamp: 1668771585733542546,
|
||||||
Prefix: &gnmiLib.Path{
|
Prefix: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "openconfig-platform:components"},
|
{Name: "openconfig-platform:components"},
|
||||||
{Name: "component", Key: map[string]string{"name": "TEMP 1"}},
|
{Name: "component", Key: map[string]string{"name": "TEMP 1"}},
|
||||||
{Name: "state"},
|
{Name: "state"},
|
||||||
},
|
},
|
||||||
Target: "OC-YANG",
|
Target: "OC-YANG",
|
||||||
},
|
},
|
||||||
Update: []*gnmiLib.Update{
|
Update: []*gnmi.Update{
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "temperature"},
|
{Name: "temperature"},
|
||||||
{Name: "low-threshold"},
|
{Name: "low-threshold"},
|
||||||
}},
|
}},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_FloatVal{FloatVal: 0},
|
Value: &gnmi.TypedValue_FloatVal{FloatVal: 0},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "temperature"},
|
{Name: "temperature"},
|
||||||
{Name: "timestamp"},
|
{Name: "timestamp"},
|
||||||
}},
|
}},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_StringVal{StringVal: "2022-11-18T11:39:26Z"},
|
Value: &gnmi.TypedValue_StringVal{StringVal: "2022-11-18T11:39:26Z"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "temperature"},
|
{Name: "temperature"},
|
||||||
{Name: "warning-status"},
|
{Name: "warning-status"},
|
||||||
}},
|
}},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_BoolVal{BoolVal: false},
|
Value: &gnmi.TypedValue_BoolVal{BoolVal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "name"},
|
{Name: "name"},
|
||||||
}},
|
}},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_StringVal{StringVal: "CPU On-board"},
|
Value: &gnmi.TypedValue_StringVal{StringVal: "CPU On-board"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "temperature"},
|
{Name: "temperature"},
|
||||||
{Name: "critical-high-threshold"},
|
{Name: "critical-high-threshold"},
|
||||||
}},
|
}},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_FloatVal{FloatVal: 94},
|
Value: &gnmi.TypedValue_FloatVal{FloatVal: 94},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "temperature"},
|
{Name: "temperature"},
|
||||||
{Name: "current"},
|
{Name: "current"},
|
||||||
}},
|
}},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_FloatVal{FloatVal: 29},
|
Value: &gnmi.TypedValue_FloatVal{FloatVal: 29},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "temperature"},
|
{Name: "temperature"},
|
||||||
{Name: "high-threshold"},
|
{Name: "high-threshold"},
|
||||||
}},
|
}},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_FloatVal{FloatVal: 90},
|
Value: &gnmi.TypedValue_FloatVal{FloatVal: 90},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -923,48 +923,48 @@ func TestNotification(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: &MockServer{
|
server: &MockServer{
|
||||||
SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error {
|
SubscribeF: func(server gnmi.GNMI_SubscribeServer) error {
|
||||||
if err := server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil {
|
if err := server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_SyncResponse{SyncResponse: true}}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
response := &gnmiLib.SubscribeResponse{
|
response := &gnmi.SubscribeResponse{
|
||||||
Response: &gnmiLib.SubscribeResponse_Update{
|
Response: &gnmi.SubscribeResponse_Update{
|
||||||
Update: &gnmiLib.Notification{
|
Update: &gnmi.Notification{
|
||||||
Timestamp: 1668771585733542546,
|
Timestamp: 1668771585733542546,
|
||||||
Prefix: &gnmiLib.Path{
|
Prefix: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "openconfig-platform:components"},
|
{Name: "openconfig-platform:components"},
|
||||||
{Name: "component", Key: map[string]string{"name": "CHASSIS0:FPC0"}},
|
{Name: "component", Key: map[string]string{"name": "CHASSIS0:FPC0"}},
|
||||||
{Name: "state"},
|
{Name: "state"},
|
||||||
},
|
},
|
||||||
Target: "OC-YANG",
|
Target: "OC-YANG",
|
||||||
},
|
},
|
||||||
Update: []*gnmiLib.Update{
|
Update: []*gnmi.Update{
|
||||||
{
|
{
|
||||||
Path: &gnmiLib.Path{
|
Path: &gnmi.Path{
|
||||||
Elem: []*gnmiLib.PathElem{
|
Elem: []*gnmi.PathElem{
|
||||||
{Name: "type"},
|
{Name: "type"},
|
||||||
}},
|
}},
|
||||||
Val: &gnmiLib.TypedValue{
|
Val: &gnmi.TypedValue{
|
||||||
Value: &gnmiLib.TypedValue_StringVal{StringVal: "LINECARD"},
|
Value: &gnmi.TypedValue_StringVal{StringVal: "LINECARD"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Extension: []*gnmiExt.Extension{{
|
Extension: []*gnmi_ext.Extension{{
|
||||||
Ext: &gnmiExt.Extension_RegisteredExt{
|
Ext: &gnmi_ext.Extension_RegisteredExt{
|
||||||
RegisteredExt: &gnmiExt.RegisteredExtension{
|
RegisteredExt: &gnmi_ext.RegisteredExtension{
|
||||||
// Juniper Header Extension
|
// Juniper Header Extension
|
||||||
// EID_JUNIPER_TELEMETRY_HEADER = 1;
|
// EID_JUNIPER_TELEMETRY_HEADER = 1;
|
||||||
Id: 1,
|
Id: 1,
|
||||||
Msg: func(jnprExt *jnprHeader.GnmiJuniperTelemetryHeaderExtension) []byte {
|
Msg: func(jnprExt *jnpr_gnmi_extention.GnmiJuniperTelemetryHeaderExtension) []byte {
|
||||||
b, err := proto.Marshal(jnprExt)
|
b, err := proto.Marshal(jnprExt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return b
|
return b
|
||||||
}(&jnprHeader.GnmiJuniperTelemetryHeaderExtension{ComponentId: 15, SubComponentId: 1, Component: "PICD"}),
|
}(&jnpr_gnmi_extention.GnmiJuniperTelemetryHeaderExtension{ComponentId: 15, SubComponentId: 1, Component: "PICD"}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
|
|
@ -1001,7 +1001,7 @@ func TestNotification(t *testing.T) {
|
||||||
|
|
||||||
grpcServer := grpc.NewServer()
|
grpcServer := grpc.NewServer()
|
||||||
tt.server.GRPCServer = grpcServer
|
tt.server.GRPCServer = grpcServer
|
||||||
gnmiLib.RegisterGNMIServer(grpcServer, tt.server)
|
gnmi.RegisterGNMIServer(grpcServer, tt.server)
|
||||||
|
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
require.NoError(t, tt.plugin.Init())
|
require.NoError(t, tt.plugin.Init())
|
||||||
|
|
@ -1051,13 +1051,13 @@ func TestRedial(t *testing.T) {
|
||||||
|
|
||||||
grpcServer := grpc.NewServer()
|
grpcServer := grpc.NewServer()
|
||||||
gnmiServer := &MockServer{
|
gnmiServer := &MockServer{
|
||||||
SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error {
|
SubscribeF: func(server gnmi.GNMI_SubscribeServer) error {
|
||||||
notification := mockGNMINotification()
|
notification := mockGNMINotification()
|
||||||
return server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_Update{Update: notification}})
|
return server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_Update{Update: notification}})
|
||||||
},
|
},
|
||||||
GRPCServer: grpcServer,
|
GRPCServer: grpcServer,
|
||||||
}
|
}
|
||||||
gnmiLib.RegisterGNMIServer(grpcServer, gnmiServer)
|
gnmi.RegisterGNMIServer(grpcServer, gnmiServer)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
@ -1081,16 +1081,16 @@ func TestRedial(t *testing.T) {
|
||||||
|
|
||||||
grpcServer = grpc.NewServer()
|
grpcServer = grpc.NewServer()
|
||||||
gnmiServer = &MockServer{
|
gnmiServer = &MockServer{
|
||||||
SubscribeF: func(server gnmiLib.GNMI_SubscribeServer) error {
|
SubscribeF: func(server gnmi.GNMI_SubscribeServer) error {
|
||||||
notification := mockGNMINotification()
|
notification := mockGNMINotification()
|
||||||
notification.Prefix.Elem[0].Key["foo"] = "bar2"
|
notification.Prefix.Elem[0].Key["foo"] = "bar2"
|
||||||
notification.Update[0].Path.Elem[1].Key["name"] = "str2"
|
notification.Update[0].Path.Elem[1].Key["name"] = "str2"
|
||||||
notification.Update[0].Val = &gnmiLib.TypedValue{Value: &gnmiLib.TypedValue_BoolVal{BoolVal: false}}
|
notification.Update[0].Val = &gnmi.TypedValue{Value: &gnmi.TypedValue_BoolVal{BoolVal: false}}
|
||||||
return server.Send(&gnmiLib.SubscribeResponse{Response: &gnmiLib.SubscribeResponse_Update{Update: notification}})
|
return server.Send(&gnmi.SubscribeResponse{Response: &gnmi.SubscribeResponse_Update{Update: notification}})
|
||||||
},
|
},
|
||||||
GRPCServer: grpcServer,
|
GRPCServer: grpcServer,
|
||||||
}
|
}
|
||||||
gnmiLib.RegisterGNMIServer(grpcServer, gnmiServer)
|
gnmi.RegisterGNMIServer(grpcServer, gnmiServer)
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
|
@ -1131,7 +1131,7 @@ func TestCases(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var entries []json.RawMessage
|
var entries []json.RawMessage
|
||||||
require.NoError(t, json.Unmarshal(buf, &entries))
|
require.NoError(t, json.Unmarshal(buf, &entries))
|
||||||
responses := make([]gnmiLib.SubscribeResponse, len(entries))
|
responses := make([]gnmi.SubscribeResponse, len(entries))
|
||||||
for i, entry := range entries {
|
for i, entry := range entries {
|
||||||
require.NoError(t, protojson.Unmarshal(entry, &responses[i]))
|
require.NoError(t, protojson.Unmarshal(entry, &responses[i]))
|
||||||
}
|
}
|
||||||
|
|
@ -1163,9 +1163,9 @@ func TestCases(t *testing.T) {
|
||||||
require.Len(t, cfg.Inputs, 1)
|
require.Len(t, cfg.Inputs, 1)
|
||||||
|
|
||||||
// Prepare the server response
|
// Prepare the server response
|
||||||
responseFunction := func(server gnmiLib.GNMI_SubscribeServer) error {
|
responseFunction := func(server gnmi.GNMI_SubscribeServer) error {
|
||||||
sync := &gnmiLib.SubscribeResponse{
|
sync := &gnmi.SubscribeResponse{
|
||||||
Response: &gnmiLib.SubscribeResponse_SyncResponse{
|
Response: &gnmi.SubscribeResponse_SyncResponse{
|
||||||
SyncResponse: true,
|
SyncResponse: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -1187,7 +1187,7 @@ func TestCases(t *testing.T) {
|
||||||
SubscribeF: responseFunction,
|
SubscribeF: responseFunction,
|
||||||
GRPCServer: grpcServer,
|
GRPCServer: grpcServer,
|
||||||
}
|
}
|
||||||
gnmiLib.RegisterGNMIServer(grpcServer, gnmiServer)
|
gnmi.RegisterGNMIServer(grpcServer, gnmiServer)
|
||||||
|
|
||||||
// Setup the plugin
|
// Setup the plugin
|
||||||
plugin := cfg.Inputs[0].Input.(*GNMI)
|
plugin := cfg.Inputs[0].Input.(*GNMI)
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
gnmiLib "github.com/openconfig/gnmi/proto/gnmi"
|
"github.com/openconfig/gnmi/proto/gnmi"
|
||||||
gnmiExt "github.com/openconfig/gnmi/proto/gnmi_ext"
|
"github.com/openconfig/gnmi/proto/gnmi_ext"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
|
|
@ -26,7 +26,7 @@ import (
|
||||||
"github.com/influxdata/telegraf/internal/choice"
|
"github.com/influxdata/telegraf/internal/choice"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
"github.com/influxdata/telegraf/plugins/common/yangmodel"
|
"github.com/influxdata/telegraf/plugins/common/yangmodel"
|
||||||
jnprHeader "github.com/influxdata/telegraf/plugins/inputs/gnmi/extensions/jnpr_gnmi_extention"
|
"github.com/influxdata/telegraf/plugins/inputs/gnmi/extensions/jnpr_gnmi_extention"
|
||||||
"github.com/influxdata/telegraf/selfstat"
|
"github.com/influxdata/telegraf/selfstat"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ type handler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubscribeGNMI and extract telemetry data
|
// SubscribeGNMI and extract telemetry data
|
||||||
func (h *handler) subscribeGNMI(ctx context.Context, acc telegraf.Accumulator, tlscfg *tls.Config, request *gnmiLib.SubscribeRequest) error {
|
func (h *handler) subscribeGNMI(ctx context.Context, acc telegraf.Accumulator, tlscfg *tls.Config, request *gnmi.SubscribeRequest) error {
|
||||||
var creds credentials.TransportCredentials
|
var creds credentials.TransportCredentials
|
||||||
if tlscfg != nil {
|
if tlscfg != nil {
|
||||||
creds = credentials.NewTLS(tlscfg)
|
creds = credentials.NewTLS(tlscfg)
|
||||||
|
|
@ -78,7 +78,7 @@ func (h *handler) subscribeGNMI(ctx context.Context, acc telegraf.Accumulator, t
|
||||||
}
|
}
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
subscribeClient, err := gnmiLib.NewGNMIClient(client).Subscribe(ctx)
|
subscribeClient, err := gnmi.NewGNMIClient(client).Subscribe(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to setup subscription: %w", err)
|
return fmt.Errorf("failed to setup subscription: %w", err)
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +99,7 @@ func (h *handler) subscribeGNMI(ctx context.Context, acc telegraf.Accumulator, t
|
||||||
|
|
||||||
defer h.log.Debugf("Connection to gNMI device %s closed", h.address)
|
defer h.log.Debugf("Connection to gNMI device %s closed", h.address)
|
||||||
for ctx.Err() == nil {
|
for ctx.Err() == nil {
|
||||||
var reply *gnmiLib.SubscribeResponse
|
var reply *gnmi.SubscribeResponse
|
||||||
if reply, err = subscribeClient.Recv(); err != nil {
|
if reply, err = subscribeClient.Recv(); err != nil {
|
||||||
if !errors.Is(err, io.EOF) && ctx.Err() == nil {
|
if !errors.Is(err, io.EOF) && ctx.Err() == nil {
|
||||||
connectStat.Set(0)
|
connectStat.Set(0)
|
||||||
|
|
@ -117,7 +117,7 @@ func (h *handler) subscribeGNMI(ctx context.Context, acc telegraf.Accumulator, t
|
||||||
h.log.Debugf("Got update_%v: %s", t, string(buf))
|
h.log.Debugf("Got update_%v: %s", t, string(buf))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if response, ok := reply.Response.(*gnmiLib.SubscribeResponse_Update); ok {
|
if response, ok := reply.Response.(*gnmi.SubscribeResponse_Update); ok {
|
||||||
h.handleSubscribeResponseUpdate(acc, response, reply.GetExtension())
|
h.handleSubscribeResponseUpdate(acc, response, reply.GetExtension())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +127,7 @@ func (h *handler) subscribeGNMI(ctx context.Context, acc telegraf.Accumulator, t
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle SubscribeResponse_Update message from gNMI and parse contained telemetry data
|
// Handle SubscribeResponse_Update message from gNMI and parse contained telemetry data
|
||||||
func (h *handler) handleSubscribeResponseUpdate(acc telegraf.Accumulator, response *gnmiLib.SubscribeResponse_Update, extension []*gnmiExt.Extension) {
|
func (h *handler) handleSubscribeResponseUpdate(acc telegraf.Accumulator, response *gnmi.SubscribeResponse_Update, extension []*gnmi_ext.Extension) {
|
||||||
grouper := metric.NewSeriesGrouper()
|
grouper := metric.NewSeriesGrouper()
|
||||||
timestamp := time.Unix(0, response.Update.Timestamp)
|
timestamp := time.Unix(0, response.Update.Timestamp)
|
||||||
|
|
||||||
|
|
@ -144,7 +144,7 @@ func (h *handler) handleSubscribeResponseUpdate(acc telegraf.Accumulator, respon
|
||||||
// Juniper Header extension
|
// Juniper Header extension
|
||||||
// Decode it only if user requested it
|
// Decode it only if user requested it
|
||||||
if choice.Contains("juniper_header", h.vendorExt) {
|
if choice.Contains("juniper_header", h.vendorExt) {
|
||||||
juniperHeader := &jnprHeader.GnmiJuniperTelemetryHeaderExtension{}
|
juniperHeader := &jnpr_gnmi_extention.GnmiJuniperTelemetryHeaderExtension{}
|
||||||
if err := proto.Unmarshal(currentExt, juniperHeader); err != nil {
|
if err := proto.Unmarshal(currentExt, juniperHeader); err != nil {
|
||||||
h.log.Errorf("unmarshal gnmi Juniper Header extension failed: %v", err)
|
h.log.Errorf("unmarshal gnmi Juniper Header extension failed: %v", err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package gnmi
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
gnmiLib "github.com/openconfig/gnmi/proto/gnmi"
|
"github.com/openconfig/gnmi/proto/gnmi"
|
||||||
)
|
)
|
||||||
|
|
||||||
type keySegment struct {
|
type keySegment struct {
|
||||||
|
|
@ -41,7 +41,7 @@ func newInfoFromString(path string) *pathInfo {
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
func newInfoFromPathWithoutKeys(path *gnmiLib.Path) *pathInfo {
|
func newInfoFromPathWithoutKeys(path *gnmi.Path) *pathInfo {
|
||||||
info := &pathInfo{
|
info := &pathInfo{
|
||||||
origin: path.Origin,
|
origin: path.Origin,
|
||||||
segments: make([]segment, 0, len(path.Elem)),
|
segments: make([]segment, 0, len(path.Elem)),
|
||||||
|
|
@ -57,7 +57,7 @@ func newInfoFromPathWithoutKeys(path *gnmiLib.Path) *pathInfo {
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
func newInfoFromPath(paths ...*gnmiLib.Path) *pathInfo {
|
func newInfoFromPath(paths ...*gnmi.Path) *pathInfo {
|
||||||
if len(paths) == 0 {
|
if len(paths) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -101,7 +101,7 @@ func (pi *pathInfo) empty() bool {
|
||||||
return len(pi.segments) == 0
|
return len(pi.segments) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pi *pathInfo) append(paths ...*gnmiLib.Path) *pathInfo {
|
func (pi *pathInfo) append(paths ...*gnmi.Path) *pathInfo {
|
||||||
// Copy the existing info
|
// Copy the existing info
|
||||||
path := &pathInfo{
|
path := &pathInfo{
|
||||||
origin: pi.origin,
|
origin: pi.origin,
|
||||||
|
|
@ -209,7 +209,7 @@ func (pi *pathInfo) normalize() {
|
||||||
pi.segments = segments
|
pi.segments = segments
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pi *pathInfo) equalsPathNoKeys(path *gnmiLib.Path) bool {
|
func (pi *pathInfo) equalsPathNoKeys(path *gnmi.Path) bool {
|
||||||
if len(pi.segments) != len(path.Elem) {
|
if len(pi.segments) != len(path.Elem) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
gnmiLib "github.com/openconfig/gnmi/proto/gnmi"
|
"github.com/openconfig/gnmi/proto/gnmi"
|
||||||
gnmiValue "github.com/openconfig/gnmi/value"
|
"github.com/openconfig/gnmi/value"
|
||||||
)
|
)
|
||||||
|
|
||||||
type keyValuePair struct {
|
type keyValuePair struct {
|
||||||
|
|
@ -20,27 +20,27 @@ type updateField struct {
|
||||||
value interface{}
|
value interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *handler) newFieldsFromUpdate(path *pathInfo, update *gnmiLib.Update) ([]updateField, error) {
|
func (h *handler) newFieldsFromUpdate(path *pathInfo, update *gnmi.Update) ([]updateField, error) {
|
||||||
if update.Val == nil || update.Val.Value == nil {
|
if update.Val == nil || update.Val.Value == nil {
|
||||||
return []updateField{{path: path}}, nil
|
return []updateField{{path: path}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply some special handling for special types
|
// Apply some special handling for special types
|
||||||
switch v := update.Val.Value.(type) {
|
switch v := update.Val.Value.(type) {
|
||||||
case *gnmiLib.TypedValue_AsciiVal: // not handled in ToScalar
|
case *gnmi.TypedValue_AsciiVal: // not handled in ToScalar
|
||||||
return []updateField{{path, v.AsciiVal}}, nil
|
return []updateField{{path, v.AsciiVal}}, nil
|
||||||
case *gnmiLib.TypedValue_JsonVal: // requires special path handling
|
case *gnmi.TypedValue_JsonVal: // requires special path handling
|
||||||
return processJSON(path, v.JsonVal)
|
return processJSON(path, v.JsonVal)
|
||||||
case *gnmiLib.TypedValue_JsonIetfVal: // requires special path handling
|
case *gnmi.TypedValue_JsonIetfVal: // requires special path handling
|
||||||
return h.processJSONIETF(path, v.JsonIetfVal)
|
return h.processJSONIETF(path, v.JsonIetfVal)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the protobuf "oneof" data to a Golang type.
|
// Convert the protobuf "oneof" data to a Golang type.
|
||||||
value, err := gnmiValue.ToScalar(update.Val)
|
nativeType, err := value.ToScalar(update.Val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return []updateField{{path, value}}, nil
|
return []updateField{{path, nativeType}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func processJSON(path *pathInfo, data []byte) ([]updateField, error) {
|
func processJSON(path *pathInfo, data []byte) ([]updateField, error) {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
jsonparser "github.com/influxdata/telegraf/plugins/parsers/json"
|
parsers_json "github.com/influxdata/telegraf/plugins/parsers/json"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -180,7 +180,7 @@ func TestRunGatherIterationWithPages(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createParser() telegraf.Parser {
|
func createParser() telegraf.Parser {
|
||||||
p := &jsonparser.Parser{
|
p := &parsers_json.Parser{
|
||||||
MetricName: "cpu",
|
MetricName: "cpu",
|
||||||
Query: "metrics",
|
Query: "metrics",
|
||||||
TagKeys: []string{"tags_datacenter", "tags_host"},
|
TagKeys: []string{"tags_datacenter", "tags_host"},
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ type HTTP struct {
|
||||||
SuccessStatusCodes []int `toml:"success_status_codes"`
|
SuccessStatusCodes []int `toml:"success_status_codes"`
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
|
|
||||||
httpconfig.HTTPClientConfig
|
common_http.HTTPClientConfig
|
||||||
|
|
||||||
client *http.Client
|
client *http.Client
|
||||||
parserFunc telegraf.ParserFunc
|
parserFunc telegraf.ParserFunc
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/plugins/common/oauth"
|
"github.com/influxdata/telegraf/plugins/common/oauth"
|
||||||
httpplugin "github.com/influxdata/telegraf/plugins/inputs/http"
|
httpplugin "github.com/influxdata/telegraf/plugins/inputs/http"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/csv"
|
"github.com/influxdata/telegraf/plugins/parsers/csv"
|
||||||
|
|
@ -349,7 +349,7 @@ func TestOAuthClientCredentialsGrant(t *testing.T) {
|
||||||
name: "success",
|
name: "success",
|
||||||
plugin: &httpplugin.HTTP{
|
plugin: &httpplugin.HTTP{
|
||||||
URLs: []string{u.String() + "/write"},
|
URLs: []string{u.String() + "/write"},
|
||||||
HTTPClientConfig: httpconfig.HTTPClientConfig{
|
HTTPClientConfig: common_http.HTTPClientConfig{
|
||||||
OAuth2Config: oauth.OAuth2Config{
|
OAuth2Config: oauth.OAuth2Config{
|
||||||
ClientID: "howdy",
|
ClientID: "howdy",
|
||||||
ClientSecret: "secret",
|
ClientSecret: "secret",
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import (
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/internal/choice"
|
"github.com/influxdata/telegraf/internal/choice"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -69,7 +69,7 @@ type HTTPListenerV2 struct {
|
||||||
BasicPassword string `toml:"basic_password"`
|
BasicPassword string `toml:"basic_password"`
|
||||||
HTTPHeaderTags map[string]string `toml:"http_header_tags"`
|
HTTPHeaderTags map[string]string `toml:"http_header_tags"`
|
||||||
|
|
||||||
tlsint.ServerConfig
|
common_tls.ServerConfig
|
||||||
tlsConf *tls.Config
|
tlsConf *tls.Config
|
||||||
|
|
||||||
TimeFunc
|
TimeFunc
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@
|
||||||
package infiniband
|
package infiniband
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Mellanox/rdmamap"
|
|
||||||
"github.com/influxdata/telegraf/testutil"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Mellanox/rdmamap"
|
||||||
|
|
||||||
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInfiniband(t *testing.T) {
|
func TestInfiniband(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/influx/influx_upstream"
|
"github.com/influxdata/telegraf/plugins/parsers/influx/influx_upstream"
|
||||||
|
|
@ -35,7 +35,7 @@ const (
|
||||||
type InfluxDBListener struct {
|
type InfluxDBListener struct {
|
||||||
ServiceAddress string `toml:"service_address"`
|
ServiceAddress string `toml:"service_address"`
|
||||||
port int
|
port int
|
||||||
tlsint.ServerConfig
|
common_tls.ServerConfig
|
||||||
|
|
||||||
ReadTimeout config.Duration `toml:"read_timeout"`
|
ReadTimeout config.Duration `toml:"read_timeout"`
|
||||||
WriteTimeout config.Duration `toml:"write_timeout"`
|
WriteTimeout config.Duration `toml:"write_timeout"`
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/influx/influx_upstream"
|
"github.com/influxdata/telegraf/plugins/parsers/influx/influx_upstream"
|
||||||
|
|
@ -52,7 +52,7 @@ const (
|
||||||
type InfluxDBV2Listener struct {
|
type InfluxDBV2Listener struct {
|
||||||
ServiceAddress string `toml:"service_address"`
|
ServiceAddress string `toml:"service_address"`
|
||||||
port int
|
port int
|
||||||
tlsint.ServerConfig
|
common_tls.ServerConfig
|
||||||
|
|
||||||
MaxUndeliveredMetrics int `toml:"max_undelivered_metrics"`
|
MaxUndeliveredMetrics int `toml:"max_undelivered_metrics"`
|
||||||
ReadTimeout config.Duration `toml:"read_timeout"`
|
ReadTimeout config.Duration `toml:"read_timeout"`
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/plugins/inputs/intel_baseband/mock"
|
mocks "github.com/influxdata/telegraf/plugins/inputs/intel_baseband/mock"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestWriteCommandToSocket(t *testing.T) {
|
func TestWriteCommandToSocket(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
ptel "github.com/intel/powertelemetry"
|
"github.com/intel/powertelemetry"
|
||||||
cpuUtil "github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v3/cpu"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
|
|
@ -90,8 +90,8 @@ func (p *PowerStat) Start(_ telegraf.Accumulator) error {
|
||||||
})
|
})
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var initErr *ptel.MultiError
|
var initErr *powertelemetry.MultiError
|
||||||
p.fetcher, err = ptel.New(opts...)
|
p.fetcher, err = powertelemetry.New(opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errors.As(err, &initErr) {
|
if !errors.As(err, &initErr) {
|
||||||
// Error caused by failing to get information about the CPU, or CPU is not supported.
|
// Error caused by failing to get information about the CPU, or CPU is not supported.
|
||||||
|
|
@ -441,7 +441,7 @@ func (p *PowerStat) addPerCPUMsrMetrics(acc telegraf.Accumulator, cpuID, coreID,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read several time-related MSR offsets.
|
// Read several time-related MSR offsets.
|
||||||
var moduleErr *ptel.ModuleNotInitializedError
|
var moduleErr *powertelemetry.ModuleNotInitializedError
|
||||||
err := p.fetcher.UpdatePerCPUMetrics(cpuID)
|
err := p.fetcher.UpdatePerCPUMetrics(cpuID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Add time-related MSR offset metrics to the accumulator
|
// Add time-related MSR offset metrics to the accumulator
|
||||||
|
|
@ -490,7 +490,7 @@ func (p *PowerStat) addCPUTimeRelatedMsrMetrics(acc telegraf.Accumulator, cpuID,
|
||||||
|
|
||||||
// addCPUPerfMetrics takes an accumulator, and adds to it enabled metrics which rely on perf.
|
// addCPUPerfMetrics takes an accumulator, and adds to it enabled metrics which rely on perf.
|
||||||
func (p *PowerStat) addCPUPerfMetrics(acc telegraf.Accumulator) {
|
func (p *PowerStat) addCPUPerfMetrics(acc telegraf.Accumulator) {
|
||||||
var moduleErr *ptel.ModuleNotInitializedError
|
var moduleErr *powertelemetry.ModuleNotInitializedError
|
||||||
|
|
||||||
// Read events related to perf-related metrics.
|
// Read events related to perf-related metrics.
|
||||||
err := p.fetcher.ReadPerfEvents()
|
err := p.fetcher.ReadPerfEvents()
|
||||||
|
|
@ -921,7 +921,7 @@ func (p *PowerStat) addUncoreFrequencyInitialLimits(acc telegraf.Accumulator, pa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always add to the accumulator errors not related to module not initialized.
|
// Always add to the accumulator errors not related to module not initialized.
|
||||||
var moduleErr *ptel.ModuleNotInitializedError
|
var moduleErr *powertelemetry.ModuleNotInitializedError
|
||||||
if !errors.As(err, &moduleErr) {
|
if !errors.As(err, &moduleErr) {
|
||||||
acc.AddError(fmt.Errorf("failed to get initial uncore frequency limits for package ID %v and die ID %v: %w", packageID, dieID, err))
|
acc.AddError(fmt.Errorf("failed to get initial uncore frequency limits for package ID %v and die ID %v: %w", packageID, dieID, err))
|
||||||
return
|
return
|
||||||
|
|
@ -961,7 +961,7 @@ func (p *PowerStat) addUncoreFrequencyCurrentValues(acc telegraf.Accumulator, pa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always add to the accumulator errors not related to module not initialized.
|
// Always add to the accumulator errors not related to module not initialized.
|
||||||
var moduleErr *ptel.ModuleNotInitializedError
|
var moduleErr *powertelemetry.ModuleNotInitializedError
|
||||||
if !errors.As(err, &moduleErr) {
|
if !errors.As(err, &moduleErr) {
|
||||||
acc.AddError(fmt.Errorf("failed to get current uncore frequency values for package ID %v and die ID %v: %w", packageID, dieID, err))
|
acc.AddError(fmt.Errorf("failed to get current uncore frequency values for package ID %v and die ID %v: %w", packageID, dieID, err))
|
||||||
return
|
return
|
||||||
|
|
@ -1024,7 +1024,7 @@ func getUncoreFreqCurrentValues(fetcher metricFetcher, packageID, dieID int) (un
|
||||||
|
|
||||||
// addMaxTurboFreqLimits fetches the max turbo frequency limits metric for a given package ID, and adds it to the accumulator.
|
// addMaxTurboFreqLimits fetches the max turbo frequency limits metric for a given package ID, and adds it to the accumulator.
|
||||||
func (p *PowerStat) addMaxTurboFreqLimits(acc telegraf.Accumulator, packageID int) {
|
func (p *PowerStat) addMaxTurboFreqLimits(acc telegraf.Accumulator, packageID int) {
|
||||||
var moduleErr *ptel.ModuleNotInitializedError
|
var moduleErr *powertelemetry.ModuleNotInitializedError
|
||||||
|
|
||||||
turboFreqList, err := p.fetcher.GetMaxTurboFreqList(packageID)
|
turboFreqList, err := p.fetcher.GetMaxTurboFreqList(packageID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -1076,7 +1076,7 @@ func (p *PowerStat) addMaxTurboFreqLimits(acc telegraf.Accumulator, packageID in
|
||||||
|
|
||||||
// isHybridCPU is a helper function that takes a slice of MaxTurboFreq structs and returns true if the CPU where these values belong to,
|
// isHybridCPU is a helper function that takes a slice of MaxTurboFreq structs and returns true if the CPU where these values belong to,
|
||||||
// is a hybrid CPU. Otherwise, returns false.
|
// is a hybrid CPU. Otherwise, returns false.
|
||||||
func isHybridCPU(turboFreqList []ptel.MaxTurboFreq) bool {
|
func isHybridCPU(turboFreqList []powertelemetry.MaxTurboFreq) bool {
|
||||||
for _, v := range turboFreqList {
|
for _, v := range turboFreqList {
|
||||||
if v.Secondary {
|
if v.Secondary {
|
||||||
return true
|
return true
|
||||||
|
|
@ -1089,7 +1089,7 @@ func isHybridCPU(turboFreqList []ptel.MaxTurboFreq) bool {
|
||||||
// In case it is not, disableUnsupportedMetrics will disable the option to gather those metrics.
|
// In case it is not, disableUnsupportedMetrics will disable the option to gather those metrics.
|
||||||
// Error is returned if there is an issue with retrieving processor information.
|
// Error is returned if there is an issue with retrieving processor information.
|
||||||
func (p *PowerStat) disableUnsupportedMetrics() error {
|
func (p *PowerStat) disableUnsupportedMetrics() error {
|
||||||
cpus, err := cpuUtil.Info()
|
cpus, err := cpu.Info()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error occurred while parsing CPU information: %w", err)
|
return fmt.Errorf("error occurred while parsing CPU information: %w", err)
|
||||||
}
|
}
|
||||||
|
|
@ -1104,27 +1104,27 @@ func (p *PowerStat) disableUnsupportedMetrics() error {
|
||||||
return fmt.Errorf("error occurred while parsing CPU model: %w", err)
|
return fmt.Errorf("error occurred while parsing CPU model: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ptel.CheckIfCPUC1StateResidencySupported(cpuModel); err != nil {
|
if err := powertelemetry.CheckIfCPUC1StateResidencySupported(cpuModel); err != nil {
|
||||||
p.disableCPUMetric(cpuC1StateResidency)
|
p.disableCPUMetric(cpuC1StateResidency)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ptel.CheckIfCPUC3StateResidencySupported(cpuModel); err != nil {
|
if err := powertelemetry.CheckIfCPUC3StateResidencySupported(cpuModel); err != nil {
|
||||||
p.disableCPUMetric(cpuC3StateResidency)
|
p.disableCPUMetric(cpuC3StateResidency)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ptel.CheckIfCPUC6StateResidencySupported(cpuModel); err != nil {
|
if err := powertelemetry.CheckIfCPUC6StateResidencySupported(cpuModel); err != nil {
|
||||||
p.disableCPUMetric(cpuC6StateResidency)
|
p.disableCPUMetric(cpuC6StateResidency)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ptel.CheckIfCPUC7StateResidencySupported(cpuModel); err != nil {
|
if err := powertelemetry.CheckIfCPUC7StateResidencySupported(cpuModel); err != nil {
|
||||||
p.disableCPUMetric(cpuC7StateResidency)
|
p.disableCPUMetric(cpuC7StateResidency)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ptel.CheckIfCPUTemperatureSupported(cpuModel); err != nil {
|
if err := powertelemetry.CheckIfCPUTemperatureSupported(cpuModel); err != nil {
|
||||||
p.disableCPUMetric(cpuTemperature)
|
p.disableCPUMetric(cpuTemperature)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ptel.CheckIfCPUBaseFrequencySupported(cpuModel); err != nil {
|
if err := powertelemetry.CheckIfCPUBaseFrequencySupported(cpuModel); err != nil {
|
||||||
p.disablePackageMetric(packageCPUBaseFrequency)
|
p.disablePackageMetric(packageCPUBaseFrequency)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
internaltls "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
authentication "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/auth"
|
authentication "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/auth"
|
||||||
telemetry "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/oc"
|
telemetry "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/oc"
|
||||||
|
|
@ -43,7 +43,7 @@ type OpenConfigTelemetry struct {
|
||||||
RetryDelay config.Duration `toml:"retry_delay"`
|
RetryDelay config.Duration `toml:"retry_delay"`
|
||||||
EnableTLS bool `toml:"enable_tls"`
|
EnableTLS bool `toml:"enable_tls"`
|
||||||
KeepAlivePeriod config.Duration `toml:"keep_alive_period"`
|
KeepAlivePeriod config.Duration `toml:"keep_alive_period"`
|
||||||
internaltls.ClientConfig
|
common_tls.ClientConfig
|
||||||
|
|
||||||
Log telegraf.Logger
|
Log telegraf.Logger
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/plugins/common/kafka"
|
"github.com/influxdata/telegraf/plugins/common/kafka"
|
||||||
"github.com/influxdata/telegraf/plugins/common/tls"
|
"github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/outputs"
|
"github.com/influxdata/telegraf/plugins/outputs"
|
||||||
kafkaOutput "github.com/influxdata/telegraf/plugins/outputs/kafka"
|
outputs_kafka "github.com/influxdata/telegraf/plugins/outputs/kafka"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/value"
|
"github.com/influxdata/telegraf/plugins/parsers/value"
|
||||||
influxSerializer "github.com/influxdata/telegraf/plugins/serializers/influx"
|
serializers_influx "github.com/influxdata/telegraf/plugins/serializers/influx"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -500,10 +500,10 @@ func TestKafkaRoundTripIntegration(t *testing.T) {
|
||||||
// Make kafka output
|
// Make kafka output
|
||||||
t.Logf("rt: starting output plugin")
|
t.Logf("rt: starting output plugin")
|
||||||
creator := outputs.Outputs["kafka"]
|
creator := outputs.Outputs["kafka"]
|
||||||
output, ok := creator().(*kafkaOutput.Kafka)
|
output, ok := creator().(*outputs_kafka.Kafka)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
s := &influxSerializer.Serializer{}
|
s := &serializers_influx.Serializer{}
|
||||||
require.NoError(t, s.Init())
|
require.NoError(t, s.Init())
|
||||||
output.SetSerializer(s)
|
output.SetSerializer(s)
|
||||||
output.Brokers = brokers
|
output.Brokers = brokers
|
||||||
|
|
@ -576,10 +576,10 @@ func TestKafkaTimestampSourceIntegration(t *testing.T) {
|
||||||
|
|
||||||
// Make kafka output
|
// Make kafka output
|
||||||
creator := outputs.Outputs["kafka"]
|
creator := outputs.Outputs["kafka"]
|
||||||
output, ok := creator().(*kafkaOutput.Kafka)
|
output, ok := creator().(*outputs_kafka.Kafka)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
s := &influxSerializer.Serializer{}
|
s := &serializers_influx.Serializer{}
|
||||||
require.NoError(t, s.Init())
|
require.NoError(t, s.Init())
|
||||||
output.SetSerializer(s)
|
output.SetSerializer(s)
|
||||||
output.Brokers = brokers
|
output.Brokers = brokers
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -95,12 +95,12 @@ type Kibana struct {
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
|
|
||||||
client *http.Client
|
client *http.Client
|
||||||
httpconfig.HTTPClientConfig
|
common_http.HTTPClientConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewKibana() *Kibana {
|
func NewKibana() *Kibana {
|
||||||
return &Kibana{
|
return &Kibana{
|
||||||
HTTPClientConfig: httpconfig.HTTPClientConfig{
|
HTTPClientConfig: common_http.HTTPClientConfig{
|
||||||
Timeout: config.Duration(5 * time.Second),
|
Timeout: config.Duration(5 * time.Second),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
internalaws "github.com/influxdata/telegraf/plugins/common/aws"
|
common_aws "github.com/influxdata/telegraf/plugins/common/aws"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ type (
|
||||||
|
|
||||||
lastSeqNum *big.Int
|
lastSeqNum *big.Int
|
||||||
|
|
||||||
internalaws.CredentialConfig
|
common_aws.CredentialConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
checkpoint struct {
|
checkpoint struct {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package kube_inventory
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
v1 "k8s.io/api/apps/v1"
|
apps "k8s.io/api/apps/v1"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
)
|
)
|
||||||
|
|
@ -19,7 +19,7 @@ func collectDaemonSets(ctx context.Context, acc telegraf.Accumulator, ki *Kubern
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ki *KubernetesInventory) gatherDaemonSet(d *v1.DaemonSet, acc telegraf.Accumulator) {
|
func (ki *KubernetesInventory) gatherDaemonSet(d *apps.DaemonSet, acc telegraf.Accumulator) {
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"generation": d.Generation,
|
"generation": d.Generation,
|
||||||
"current_number_scheduled": d.Status.CurrentNumberScheduled,
|
"current_number_scheduled": d.Status.CurrentNumberScheduled,
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
v1 "k8s.io/api/apps/v1"
|
apps "k8s.io/api/apps/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
|
|
@ -29,7 +29,7 @@ func TestDaemonSet(t *testing.T) {
|
||||||
name: "no daemon set",
|
name: "no daemon set",
|
||||||
handler: &mockHandler{
|
handler: &mockHandler{
|
||||||
responseMap: map[string]interface{}{
|
responseMap: map[string]interface{}{
|
||||||
"/daemonsets/": &v1.DaemonSetList{},
|
"/daemonsets/": &apps.DaemonSetList{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
hasError: false,
|
hasError: false,
|
||||||
|
|
@ -38,10 +38,10 @@ func TestDaemonSet(t *testing.T) {
|
||||||
name: "collect daemonsets",
|
name: "collect daemonsets",
|
||||||
handler: &mockHandler{
|
handler: &mockHandler{
|
||||||
responseMap: map[string]interface{}{
|
responseMap: map[string]interface{}{
|
||||||
"/daemonsets/": &v1.DaemonSetList{
|
"/daemonsets/": &apps.DaemonSetList{
|
||||||
Items: []v1.DaemonSet{
|
Items: []apps.DaemonSet{
|
||||||
{
|
{
|
||||||
Status: v1.DaemonSetStatus{
|
Status: apps.DaemonSetStatus{
|
||||||
CurrentNumberScheduled: 3,
|
CurrentNumberScheduled: 3,
|
||||||
DesiredNumberScheduled: 5,
|
DesiredNumberScheduled: 5,
|
||||||
NumberAvailable: 2,
|
NumberAvailable: 2,
|
||||||
|
|
@ -50,7 +50,7 @@ func TestDaemonSet(t *testing.T) {
|
||||||
NumberUnavailable: 1,
|
NumberUnavailable: 1,
|
||||||
UpdatedNumberScheduled: 2,
|
UpdatedNumberScheduled: 2,
|
||||||
},
|
},
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Generation: 11221,
|
Generation: 11221,
|
||||||
Namespace: "ns1",
|
Namespace: "ns1",
|
||||||
Name: "daemon1",
|
Name: "daemon1",
|
||||||
|
|
@ -58,10 +58,10 @@ func TestDaemonSet(t *testing.T) {
|
||||||
"lab1": "v1",
|
"lab1": "v1",
|
||||||
"lab2": "v2",
|
"lab2": "v2",
|
||||||
},
|
},
|
||||||
CreationTimestamp: metav1.Time{Time: now},
|
CreationTimestamp: meta.Time{Time: now},
|
||||||
},
|
},
|
||||||
Spec: v1.DaemonSetSpec{
|
Spec: apps.DaemonSetSpec{
|
||||||
Selector: &metav1.LabelSelector{
|
Selector: &meta.LabelSelector{
|
||||||
MatchLabels: map[string]string{
|
MatchLabels: map[string]string{
|
||||||
"select1": "s1",
|
"select1": "s1",
|
||||||
"select2": "s2",
|
"select2": "s2",
|
||||||
|
|
@ -108,7 +108,7 @@ func TestDaemonSet(t *testing.T) {
|
||||||
}
|
}
|
||||||
require.NoError(t, ks.createSelectorFilters())
|
require.NoError(t, ks.createSelectorFilters())
|
||||||
acc := new(testutil.Accumulator)
|
acc := new(testutil.Accumulator)
|
||||||
items := ((v.handler.responseMap["/daemonsets/"]).(*v1.DaemonSetList)).Items
|
items := ((v.handler.responseMap["/daemonsets/"]).(*apps.DaemonSetList)).Items
|
||||||
for i := range items {
|
for i := range items {
|
||||||
ks.gatherDaemonSet(&items[i], acc)
|
ks.gatherDaemonSet(&items[i], acc)
|
||||||
}
|
}
|
||||||
|
|
@ -131,10 +131,10 @@ func TestDaemonSetSelectorFilter(t *testing.T) {
|
||||||
cli := &client{}
|
cli := &client{}
|
||||||
|
|
||||||
responseMap := map[string]interface{}{
|
responseMap := map[string]interface{}{
|
||||||
"/daemonsets/": &v1.DaemonSetList{
|
"/daemonsets/": &apps.DaemonSetList{
|
||||||
Items: []v1.DaemonSet{
|
Items: []apps.DaemonSet{
|
||||||
{
|
{
|
||||||
Status: v1.DaemonSetStatus{
|
Status: apps.DaemonSetStatus{
|
||||||
CurrentNumberScheduled: 3,
|
CurrentNumberScheduled: 3,
|
||||||
DesiredNumberScheduled: 5,
|
DesiredNumberScheduled: 5,
|
||||||
NumberAvailable: 2,
|
NumberAvailable: 2,
|
||||||
|
|
@ -143,7 +143,7 @@ func TestDaemonSetSelectorFilter(t *testing.T) {
|
||||||
NumberUnavailable: 1,
|
NumberUnavailable: 1,
|
||||||
UpdatedNumberScheduled: 2,
|
UpdatedNumberScheduled: 2,
|
||||||
},
|
},
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Generation: 11221,
|
Generation: 11221,
|
||||||
Namespace: "ns1",
|
Namespace: "ns1",
|
||||||
Name: "daemon1",
|
Name: "daemon1",
|
||||||
|
|
@ -151,10 +151,10 @@ func TestDaemonSetSelectorFilter(t *testing.T) {
|
||||||
"lab1": "v1",
|
"lab1": "v1",
|
||||||
"lab2": "v2",
|
"lab2": "v2",
|
||||||
},
|
},
|
||||||
CreationTimestamp: metav1.Time{Time: time.Now()},
|
CreationTimestamp: meta.Time{Time: time.Now()},
|
||||||
},
|
},
|
||||||
Spec: v1.DaemonSetSpec{
|
Spec: apps.DaemonSetSpec{
|
||||||
Selector: &metav1.LabelSelector{
|
Selector: &meta.LabelSelector{
|
||||||
MatchLabels: map[string]string{
|
MatchLabels: map[string]string{
|
||||||
"select1": "s1",
|
"select1": "s1",
|
||||||
"select2": "s2",
|
"select2": "s2",
|
||||||
|
|
@ -269,7 +269,7 @@ func TestDaemonSetSelectorFilter(t *testing.T) {
|
||||||
ks.SelectorExclude = v.exclude
|
ks.SelectorExclude = v.exclude
|
||||||
require.NoError(t, ks.createSelectorFilters())
|
require.NoError(t, ks.createSelectorFilters())
|
||||||
acc := new(testutil.Accumulator)
|
acc := new(testutil.Accumulator)
|
||||||
items := ((v.handler.responseMap["/daemonsets/"]).(*v1.DaemonSetList)).Items
|
items := ((v.handler.responseMap["/daemonsets/"]).(*apps.DaemonSetList)).Items
|
||||||
for i := range items {
|
for i := range items {
|
||||||
ks.gatherDaemonSet(&items[i], acc)
|
ks.gatherDaemonSet(&items[i], acc)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package kube_inventory
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
v1 "k8s.io/api/apps/v1"
|
"k8s.io/api/apps/v1"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
v1 "k8s.io/api/apps/v1"
|
"k8s.io/api/apps/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package kube_inventory
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
v1 "k8s.io/api/apps/v1"
|
"k8s.io/api/apps/v1"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
v1 "k8s.io/api/apps/v1"
|
"k8s.io/api/apps/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
commontls "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ type LDAP struct {
|
||||||
BindDn string `toml:"bind_dn"`
|
BindDn string `toml:"bind_dn"`
|
||||||
BindPassword config.Secret `toml:"bind_password"`
|
BindPassword config.Secret `toml:"bind_password"`
|
||||||
ReverseFieldNames bool `toml:"reverse_field_names"`
|
ReverseFieldNames bool `toml:"reverse_field_names"`
|
||||||
commontls.ClientConfig
|
common_tls.ClientConfig
|
||||||
|
|
||||||
tlsCfg *tls.Config
|
tlsCfg *tls.Config
|
||||||
requests []request
|
requests []request
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
commontls "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -312,7 +312,7 @@ func TestOpenLDAPStartTLSIntegration(t *testing.T) {
|
||||||
Server: "starttls://" + container.Address + ":" + port,
|
Server: "starttls://" + container.Address + ":" + port,
|
||||||
BindDn: "CN=manager,DC=example,DC=org",
|
BindDn: "CN=manager,DC=example,DC=org",
|
||||||
BindPassword: config.NewSecret([]byte("secret")),
|
BindPassword: config.NewSecret([]byte("secret")),
|
||||||
ClientConfig: commontls.ClientConfig{
|
ClientConfig: common_tls.ClientConfig{
|
||||||
TLSCA: pkiPaths.ClientCert,
|
TLSCA: pkiPaths.ClientCert,
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
},
|
},
|
||||||
|
|
@ -420,7 +420,7 @@ func TestOpenLDAPLDAPSIntegration(t *testing.T) {
|
||||||
Server: "ldaps://" + container.Address + ":" + port,
|
Server: "ldaps://" + container.Address + ":" + port,
|
||||||
BindDn: "CN=manager,DC=example,DC=org",
|
BindDn: "CN=manager,DC=example,DC=org",
|
||||||
BindPassword: config.NewSecret([]byte("secret")),
|
BindPassword: config.NewSecret([]byte("secret")),
|
||||||
ClientConfig: commontls.ClientConfig{
|
ClientConfig: common_tls.ClientConfig{
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/internal/choice"
|
"github.com/influxdata/telegraf/internal/choice"
|
||||||
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
jsonParser "github.com/influxdata/telegraf/plugins/parsers/json"
|
parsers_json "github.com/influxdata/telegraf/plugins/parsers/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed sample.conf
|
//go:embed sample.conf
|
||||||
|
|
@ -43,7 +43,7 @@ type Logstash struct {
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
|
|
||||||
client *http.Client
|
client *http.Client
|
||||||
httpconfig.HTTPClientConfig
|
common_http.HTTPClientConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type processStats struct {
|
type processStats struct {
|
||||||
|
|
@ -183,7 +183,7 @@ func (logstash *Logstash) gatherJVMStats(address string, accumulator telegraf.Ac
|
||||||
"source": jvmStats.Host,
|
"source": jvmStats.Host,
|
||||||
}
|
}
|
||||||
|
|
||||||
flattener := jsonParser.JSONFlattener{}
|
flattener := parsers_json.JSONFlattener{}
|
||||||
err = flattener.FlattenJSON("", jvmStats.JVM)
|
err = flattener.FlattenJSON("", jvmStats.JVM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -209,7 +209,7 @@ func (logstash *Logstash) gatherProcessStats(address string, accumulator telegra
|
||||||
"source": processStats.Host,
|
"source": processStats.Host,
|
||||||
}
|
}
|
||||||
|
|
||||||
flattener := jsonParser.JSONFlattener{}
|
flattener := parsers_json.JSONFlattener{}
|
||||||
err = flattener.FlattenJSON("", processStats.Process)
|
err = flattener.FlattenJSON("", processStats.Process)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -235,7 +235,7 @@ func (logstash *Logstash) gatherPluginsStats(
|
||||||
for tag, value := range tags {
|
for tag, value := range tags {
|
||||||
pluginTags[tag] = value
|
pluginTags[tag] = value
|
||||||
}
|
}
|
||||||
flattener := jsonParser.JSONFlattener{}
|
flattener := parsers_json.JSONFlattener{}
|
||||||
err := flattener.FlattenJSON("", plugin.Events)
|
err := flattener.FlattenJSON("", plugin.Events)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -264,7 +264,7 @@ func (logstash *Logstash) gatherPluginsStats(
|
||||||
"with_errors": 9089
|
"with_errors": 9089
|
||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
flattener := jsonParser.JSONFlattener{}
|
flattener := parsers_json.JSONFlattener{}
|
||||||
err := flattener.FlattenJSON("", plugin.BulkRequests)
|
err := flattener.FlattenJSON("", plugin.BulkRequests)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -287,7 +287,7 @@ func (logstash *Logstash) gatherPluginsStats(
|
||||||
"retryable_failures": 13733
|
"retryable_failures": 13733
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
flattener = jsonParser.JSONFlattener{}
|
flattener = parsers_json.JSONFlattener{}
|
||||||
err = flattener.FlattenJSON("", plugin.Documents)
|
err = flattener.FlattenJSON("", plugin.Documents)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -325,7 +325,7 @@ func (logstash *Logstash) gatherQueueStats(queue pipelineQueue, tags map[string]
|
||||||
}
|
}
|
||||||
|
|
||||||
if queue.Type != "memory" {
|
if queue.Type != "memory" {
|
||||||
flattener := jsonParser.JSONFlattener{}
|
flattener := parsers_json.JSONFlattener{}
|
||||||
err := flattener.FlattenJSON("", queue.Capacity)
|
err := flattener.FlattenJSON("", queue.Capacity)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -368,7 +368,7 @@ func (logstash *Logstash) gatherPipelineStats(address string, accumulator telegr
|
||||||
"source": pipelineStats.Host,
|
"source": pipelineStats.Host,
|
||||||
}
|
}
|
||||||
|
|
||||||
flattener := jsonParser.JSONFlattener{}
|
flattener := parsers_json.JSONFlattener{}
|
||||||
err = flattener.FlattenJSON("", pipelineStats.Pipeline.Events)
|
err = flattener.FlattenJSON("", pipelineStats.Pipeline.Events)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -414,7 +414,7 @@ func (logstash *Logstash) gatherPipelinesStats(address string, accumulator teleg
|
||||||
"source": pipelinesStats.Host,
|
"source": pipelinesStats.Host,
|
||||||
}
|
}
|
||||||
|
|
||||||
flattener := jsonParser.JSONFlattener{}
|
flattener := parsers_json.JSONFlattener{}
|
||||||
err := flattener.FlattenJSON("", pipeline.Events)
|
err := flattener.FlattenJSON("", pipeline.Events)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -520,7 +520,7 @@ func newLogstash() *Logstash {
|
||||||
URL: "http://127.0.0.1:9600",
|
URL: "http://127.0.0.1:9600",
|
||||||
Collect: []string{"pipelines", "process", "jvm"},
|
Collect: []string{"pipelines", "process", "jvm"},
|
||||||
Headers: make(map[string]string),
|
Headers: make(map[string]string),
|
||||||
HTTPClientConfig: httpconfig.HTTPClientConfig{
|
HTTPClientConfig: common_http.HTTPClientConfig{
|
||||||
Timeout: config.Duration(5 * time.Second),
|
Timeout: config.Duration(5 * time.Second),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"golang.org/x/net/proxy"
|
"golang.org/x/net/proxy"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -27,7 +27,7 @@ type Memcached struct {
|
||||||
Servers []string `toml:"servers"`
|
Servers []string `toml:"servers"`
|
||||||
UnixSockets []string `toml:"unix_sockets"`
|
UnixSockets []string `toml:"unix_sockets"`
|
||||||
EnableTLS bool `toml:"enable_tls"`
|
EnableTLS bool `toml:"enable_tls"`
|
||||||
tlsint.ClientConfig
|
common_tls.ClientConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultTimeout = 5 * time.Second
|
var defaultTimeout = 5 * time.Second
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/plugins/common/tls"
|
"github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
jsonparser "github.com/influxdata/telegraf/plugins/parsers/json"
|
parsers_json "github.com/influxdata/telegraf/plugins/parsers/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed sample.conf
|
//go:embed sample.conf
|
||||||
|
|
@ -525,7 +525,7 @@ func (m *Mesos) gatherMainMetrics(u *url.URL, role Role, acc telegraf.Accumulato
|
||||||
|
|
||||||
m.filterMetrics(role, &jsonOut)
|
m.filterMetrics(role, &jsonOut)
|
||||||
|
|
||||||
jf := jsonparser.JSONFlattener{}
|
jf := parsers_json.JSONFlattener{}
|
||||||
|
|
||||||
err = jf.FlattenJSON("", jsonOut)
|
err = jf.FlattenJSON("", jsonOut)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/internal/choice"
|
"github.com/influxdata/telegraf/internal/choice"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ type MongoDB struct {
|
||||||
GatherTopStat bool
|
GatherTopStat bool
|
||||||
DisconnectedServersBehavior string
|
DisconnectedServersBehavior string
|
||||||
ColStatsDbs []string
|
ColStatsDbs []string
|
||||||
tlsint.ClientConfig
|
common_tls.ClientConfig
|
||||||
|
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ import (
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/plugins/common/tls"
|
"github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
v1 "github.com/influxdata/telegraf/plugins/inputs/mysql/v1"
|
"github.com/influxdata/telegraf/plugins/inputs/mysql/v1"
|
||||||
v2 "github.com/influxdata/telegraf/plugins/inputs/mysql/v2"
|
"github.com/influxdata/telegraf/plugins/inputs/mysql/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed sample.conf
|
//go:embed sample.conf
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
influxtls "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ type OpensearchQuery struct {
|
||||||
|
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
|
|
||||||
influxtls.ClientConfig
|
common_tls.ClientConfig
|
||||||
osClient *opensearch.Client
|
osClient *opensearch.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ import (
|
||||||
"github.com/gophercloud/gophercloud/v2/openstack/orchestration/v1/stacks"
|
"github.com/gophercloud/gophercloud/v2/openstack/orchestration/v1/stacks"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ type OpenStack struct {
|
||||||
MeasureRequest bool `toml:"measure_openstack_requests"`
|
MeasureRequest bool `toml:"measure_openstack_requests"`
|
||||||
AllTenants bool `toml:"query_all_tenants"`
|
AllTenants bool `toml:"query_all_tenants"`
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
httpconfig.HTTPClientConfig
|
common_http.HTTPClientConfig
|
||||||
|
|
||||||
client *http.Client
|
client *http.Client
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ import (
|
||||||
"github.com/influxdata/influxdb-observability/otel2influx"
|
"github.com/influxdata/influxdb-observability/otel2influx"
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
tmetric "github.com/influxdata/telegraf/metric"
|
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
|
|
@ -86,7 +85,7 @@ func TestOpenTelemetry(t *testing.T) {
|
||||||
exesuffix = ".exe"
|
exesuffix = ".exe"
|
||||||
}
|
}
|
||||||
expected := []telegraf.Metric{
|
expected := []telegraf.Metric{
|
||||||
tmetric.New(
|
testutil.MustMetric(
|
||||||
"measurement-counter",
|
"measurement-counter",
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"otel.library.name": "library-name",
|
"otel.library.name": "library-name",
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,14 @@ import (
|
||||||
"slices"
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
p4ConfigV1 "github.com/p4lang/p4runtime/go/p4/config/v1"
|
p4_config "github.com/p4lang/p4runtime/go/p4/config/v1"
|
||||||
p4v1 "github.com/p4lang/p4runtime/go/p4/v1"
|
p4 "github.com/p4lang/p4runtime/go/p4/v1"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
internaltls "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -36,10 +36,10 @@ type P4runtime struct {
|
||||||
CounterNamesInclude []string `toml:"counter_names_include"`
|
CounterNamesInclude []string `toml:"counter_names_include"`
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
EnableTLS bool `toml:"enable_tls"`
|
EnableTLS bool `toml:"enable_tls"`
|
||||||
internaltls.ClientConfig
|
common_tls.ClientConfig
|
||||||
|
|
||||||
conn *grpc.ClientConn
|
conn *grpc.ClientConn
|
||||||
client p4v1.P4RuntimeClient
|
client p4.P4RuntimeClient
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ func (p *P4runtime) Gather(acc telegraf.Accumulator) error {
|
||||||
|
|
||||||
for _, counter := range filteredCounters {
|
for _, counter := range filteredCounters {
|
||||||
p.wg.Add(1)
|
p.wg.Add(1)
|
||||||
go func(counter *p4ConfigV1.Counter) {
|
go func(counter *p4_config.Counter) {
|
||||||
defer p.wg.Done()
|
defer p.wg.Done()
|
||||||
entries, err := p.readAllEntries(counter.Preamble.Id)
|
entries, err := p.readAllEntries(counter.Preamble.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -136,10 +136,10 @@ func initConnection(endpoint string, tlscfg *tls.Config) (*grpc.ClientConn, erro
|
||||||
return grpc.NewClient(endpoint, grpc.WithTransportCredentials(creds))
|
return grpc.NewClient(endpoint, grpc.WithTransportCredentials(creds))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *P4runtime) getP4Info() (*p4ConfigV1.P4Info, error) {
|
func (p *P4runtime) getP4Info() (*p4_config.P4Info, error) {
|
||||||
req := &p4v1.GetForwardingPipelineConfigRequest{
|
req := &p4.GetForwardingPipelineConfigRequest{
|
||||||
DeviceId: p.DeviceID,
|
DeviceId: p.DeviceID,
|
||||||
ResponseType: p4v1.GetForwardingPipelineConfigRequest_ALL,
|
ResponseType: p4.GetForwardingPipelineConfigRequest_ALL,
|
||||||
}
|
}
|
||||||
resp, err := p.client.GetForwardingPipelineConfig(context.Background(), req)
|
resp, err := p.client.GetForwardingPipelineConfig(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -165,12 +165,12 @@ func (p *P4runtime) getP4Info() (*p4ConfigV1.P4Info, error) {
|
||||||
return p4info, nil
|
return p4info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func filterCounters(counters []*p4ConfigV1.Counter, counterNamesInclude []string) []*p4ConfigV1.Counter {
|
func filterCounters(counters []*p4_config.Counter, counterNamesInclude []string) []*p4_config.Counter {
|
||||||
if len(counterNamesInclude) == 0 {
|
if len(counterNamesInclude) == 0 {
|
||||||
return counters
|
return counters
|
||||||
}
|
}
|
||||||
|
|
||||||
var filteredCounters []*p4ConfigV1.Counter
|
var filteredCounters []*p4_config.Counter
|
||||||
for _, counter := range counters {
|
for _, counter := range counters {
|
||||||
if counter == nil {
|
if counter == nil {
|
||||||
continue
|
continue
|
||||||
|
|
@ -197,16 +197,16 @@ func (p *P4runtime) newP4RuntimeClient() error {
|
||||||
return fmt.Errorf("cannot connect to the server: %w", err)
|
return fmt.Errorf("cannot connect to the server: %w", err)
|
||||||
}
|
}
|
||||||
p.conn = conn
|
p.conn = conn
|
||||||
p.client = p4v1.NewP4RuntimeClient(conn)
|
p.client = p4.NewP4RuntimeClient(conn)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *P4runtime) readAllEntries(counterID uint32) ([]*p4v1.Entity, error) {
|
func (p *P4runtime) readAllEntries(counterID uint32) ([]*p4.Entity, error) {
|
||||||
readRequest := &p4v1.ReadRequest{
|
readRequest := &p4.ReadRequest{
|
||||||
DeviceId: p.DeviceID,
|
DeviceId: p.DeviceID,
|
||||||
Entities: []*p4v1.Entity{{
|
Entities: []*p4.Entity{{
|
||||||
Entity: &p4v1.Entity_CounterEntry{
|
Entity: &p4.Entity_CounterEntry{
|
||||||
CounterEntry: &p4v1.CounterEntry{
|
CounterEntry: &p4.CounterEntry{
|
||||||
CounterId: counterID}}}}}
|
CounterId: counterID}}}}}
|
||||||
|
|
||||||
stream, err := p.client.Read(context.Background(), readRequest)
|
stream, err := p.client.Read(context.Background(), readRequest)
|
||||||
|
|
|
||||||
|
|
@ -3,49 +3,49 @@ package p4runtime
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
p4v1 "github.com/p4lang/p4runtime/go/p4/v1"
|
p4 "github.com/p4lang/p4runtime/go/p4/v1"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type fakeP4RuntimeClient struct {
|
type fakeP4RuntimeClient struct {
|
||||||
writeFn func(
|
writeFn func(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
in *p4v1.WriteRequest,
|
in *p4.WriteRequest,
|
||||||
opts ...grpc.CallOption,
|
opts ...grpc.CallOption,
|
||||||
) (*p4v1.WriteResponse, error)
|
) (*p4.WriteResponse, error)
|
||||||
|
|
||||||
readFn func(
|
readFn func(
|
||||||
in *p4v1.ReadRequest,
|
in *p4.ReadRequest,
|
||||||
) (p4v1.P4Runtime_ReadClient, error)
|
) (p4.P4Runtime_ReadClient, error)
|
||||||
|
|
||||||
setForwardingPipelineConfigFn func(
|
setForwardingPipelineConfigFn func(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
in *p4v1.SetForwardingPipelineConfigRequest,
|
in *p4.SetForwardingPipelineConfigRequest,
|
||||||
opts ...grpc.CallOption,
|
opts ...grpc.CallOption,
|
||||||
) (*p4v1.SetForwardingPipelineConfigResponse, error)
|
) (*p4.SetForwardingPipelineConfigResponse, error)
|
||||||
|
|
||||||
getForwardingPipelineConfigFn func() (*p4v1.GetForwardingPipelineConfigResponse, error)
|
getForwardingPipelineConfigFn func() (*p4.GetForwardingPipelineConfigResponse, error)
|
||||||
|
|
||||||
streamChannelFn func(
|
streamChannelFn func(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
opts ...grpc.CallOption,
|
opts ...grpc.CallOption,
|
||||||
) (p4v1.P4Runtime_StreamChannelClient, error)
|
) (p4.P4Runtime_StreamChannelClient, error)
|
||||||
|
|
||||||
capabilitiesFn func(
|
capabilitiesFn func(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
in *p4v1.CapabilitiesRequest,
|
in *p4.CapabilitiesRequest,
|
||||||
opts ...grpc.CallOption,
|
opts ...grpc.CallOption,
|
||||||
) (*p4v1.CapabilitiesResponse, error)
|
) (*p4.CapabilitiesResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fakeP4RuntimeClient implements the p4v1.P4RuntimeClient interface
|
// fakeP4RuntimeClient implements the v1.P4RuntimeClient interface
|
||||||
var _ p4v1.P4RuntimeClient = &fakeP4RuntimeClient{}
|
var _ p4.P4RuntimeClient = &fakeP4RuntimeClient{}
|
||||||
|
|
||||||
func (c *fakeP4RuntimeClient) Write(
|
func (c *fakeP4RuntimeClient) Write(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
in *p4v1.WriteRequest,
|
in *p4.WriteRequest,
|
||||||
opts ...grpc.CallOption,
|
opts ...grpc.CallOption,
|
||||||
) (*p4v1.WriteResponse, error) {
|
) (*p4.WriteResponse, error) {
|
||||||
if c.writeFn == nil {
|
if c.writeFn == nil {
|
||||||
panic("No mock defined for Write RPC")
|
panic("No mock defined for Write RPC")
|
||||||
}
|
}
|
||||||
|
|
@ -54,9 +54,9 @@ func (c *fakeP4RuntimeClient) Write(
|
||||||
|
|
||||||
func (c *fakeP4RuntimeClient) Read(
|
func (c *fakeP4RuntimeClient) Read(
|
||||||
_ context.Context,
|
_ context.Context,
|
||||||
in *p4v1.ReadRequest,
|
in *p4.ReadRequest,
|
||||||
_ ...grpc.CallOption,
|
_ ...grpc.CallOption,
|
||||||
) (p4v1.P4Runtime_ReadClient, error) {
|
) (p4.P4Runtime_ReadClient, error) {
|
||||||
if c.readFn == nil {
|
if c.readFn == nil {
|
||||||
panic("No mock defined for Read RPC")
|
panic("No mock defined for Read RPC")
|
||||||
}
|
}
|
||||||
|
|
@ -65,9 +65,9 @@ func (c *fakeP4RuntimeClient) Read(
|
||||||
|
|
||||||
func (c *fakeP4RuntimeClient) SetForwardingPipelineConfig(
|
func (c *fakeP4RuntimeClient) SetForwardingPipelineConfig(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
in *p4v1.SetForwardingPipelineConfigRequest,
|
in *p4.SetForwardingPipelineConfigRequest,
|
||||||
opts ...grpc.CallOption,
|
opts ...grpc.CallOption,
|
||||||
) (*p4v1.SetForwardingPipelineConfigResponse, error) {
|
) (*p4.SetForwardingPipelineConfigResponse, error) {
|
||||||
if c.setForwardingPipelineConfigFn == nil {
|
if c.setForwardingPipelineConfigFn == nil {
|
||||||
panic("No mock defined for SetForwardingPipelineConfig RPC")
|
panic("No mock defined for SetForwardingPipelineConfig RPC")
|
||||||
}
|
}
|
||||||
|
|
@ -76,9 +76,9 @@ func (c *fakeP4RuntimeClient) SetForwardingPipelineConfig(
|
||||||
|
|
||||||
func (c *fakeP4RuntimeClient) GetForwardingPipelineConfig(
|
func (c *fakeP4RuntimeClient) GetForwardingPipelineConfig(
|
||||||
context.Context,
|
context.Context,
|
||||||
*p4v1.GetForwardingPipelineConfigRequest,
|
*p4.GetForwardingPipelineConfigRequest,
|
||||||
...grpc.CallOption,
|
...grpc.CallOption,
|
||||||
) (*p4v1.GetForwardingPipelineConfigResponse, error) {
|
) (*p4.GetForwardingPipelineConfigResponse, error) {
|
||||||
if c.getForwardingPipelineConfigFn == nil {
|
if c.getForwardingPipelineConfigFn == nil {
|
||||||
panic("No mock defined for GetForwardingPipelineConfig RPC")
|
panic("No mock defined for GetForwardingPipelineConfig RPC")
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +88,7 @@ func (c *fakeP4RuntimeClient) GetForwardingPipelineConfig(
|
||||||
func (c *fakeP4RuntimeClient) StreamChannel(
|
func (c *fakeP4RuntimeClient) StreamChannel(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
opts ...grpc.CallOption,
|
opts ...grpc.CallOption,
|
||||||
) (p4v1.P4Runtime_StreamChannelClient, error) {
|
) (p4.P4Runtime_StreamChannelClient, error) {
|
||||||
if c.streamChannelFn == nil {
|
if c.streamChannelFn == nil {
|
||||||
panic("No mock defined for StreamChannel")
|
panic("No mock defined for StreamChannel")
|
||||||
}
|
}
|
||||||
|
|
@ -97,9 +97,9 @@ func (c *fakeP4RuntimeClient) StreamChannel(
|
||||||
|
|
||||||
func (c *fakeP4RuntimeClient) Capabilities(
|
func (c *fakeP4RuntimeClient) Capabilities(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
in *p4v1.CapabilitiesRequest,
|
in *p4.CapabilitiesRequest,
|
||||||
opts ...grpc.CallOption,
|
opts ...grpc.CallOption,
|
||||||
) (*p4v1.CapabilitiesResponse, error) {
|
) (*p4.CapabilitiesResponse, error) {
|
||||||
if c.capabilitiesFn == nil {
|
if c.capabilitiesFn == nil {
|
||||||
panic("No mock defined for Capabilities RPC")
|
panic("No mock defined for Capabilities RPC")
|
||||||
}
|
}
|
||||||
|
|
@ -108,13 +108,13 @@ func (c *fakeP4RuntimeClient) Capabilities(
|
||||||
|
|
||||||
type fakeP4RuntimeReadClient struct {
|
type fakeP4RuntimeReadClient struct {
|
||||||
grpc.ClientStream
|
grpc.ClientStream
|
||||||
recvFn func() (*p4v1.ReadResponse, error)
|
recvFn func() (*p4.ReadResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fakeP4RuntimeReadClient implements the p4v1.P4Runtime_ReadClient interface
|
// fakeP4RuntimeReadClient implements the v1.P4Runtime_ReadClient interface
|
||||||
var _ p4v1.P4Runtime_ReadClient = &fakeP4RuntimeReadClient{}
|
var _ p4.P4Runtime_ReadClient = &fakeP4RuntimeReadClient{}
|
||||||
|
|
||||||
func (c *fakeP4RuntimeReadClient) Recv() (*p4v1.ReadResponse, error) {
|
func (c *fakeP4RuntimeReadClient) Recv() (*p4.ReadResponse, error) {
|
||||||
if c.recvFn == nil {
|
if c.recvFn == nil {
|
||||||
panic("No mock provided for Recv function")
|
panic("No mock provided for Recv function")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
p4ConfigV1 "github.com/p4lang/p4runtime/go/p4/config/v1"
|
p4_config "github.com/p4lang/p4runtime/go/p4/config/v1"
|
||||||
p4v1 "github.com/p4lang/p4runtime/go/p4/v1"
|
p4 "github.com/p4lang/p4runtime/go/p4/v1"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
|
|
@ -21,23 +21,23 @@ import (
|
||||||
func createCounter(
|
func createCounter(
|
||||||
name string,
|
name string,
|
||||||
id uint32,
|
id uint32,
|
||||||
unit p4ConfigV1.CounterSpec_Unit,
|
unit p4_config.CounterSpec_Unit,
|
||||||
) *p4ConfigV1.Counter {
|
) *p4_config.Counter {
|
||||||
return &p4ConfigV1.Counter{
|
return &p4_config.Counter{
|
||||||
Preamble: &p4ConfigV1.Preamble{Name: name, Id: id},
|
Preamble: &p4_config.Preamble{Name: name, Id: id},
|
||||||
Spec: &p4ConfigV1.CounterSpec{Unit: unit},
|
Spec: &p4_config.CounterSpec{Unit: unit},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createEntityCounterEntry(
|
func createEntityCounterEntry(
|
||||||
counterID uint32,
|
counterID uint32,
|
||||||
index int64,
|
index int64,
|
||||||
data *p4v1.CounterData,
|
data *p4.CounterData,
|
||||||
) *p4v1.Entity_CounterEntry {
|
) *p4.Entity_CounterEntry {
|
||||||
return &p4v1.Entity_CounterEntry{
|
return &p4.Entity_CounterEntry{
|
||||||
CounterEntry: &p4v1.CounterEntry{
|
CounterEntry: &p4.CounterEntry{
|
||||||
CounterId: counterID,
|
CounterId: counterID,
|
||||||
Index: &p4v1.Index{Index: index},
|
Index: &p4.Index{Index: index},
|
||||||
Data: data,
|
Data: data,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -73,20 +73,20 @@ func TestInitDefault(t *testing.T) {
|
||||||
|
|
||||||
func TestErrorGetP4Info(t *testing.T) {
|
func TestErrorGetP4Info(t *testing.T) {
|
||||||
responses := []struct {
|
responses := []struct {
|
||||||
getForwardingPipelineConfigResponse *p4v1.GetForwardingPipelineConfigResponse
|
getForwardingPipelineConfigResponse *p4.GetForwardingPipelineConfigResponse
|
||||||
getForwardingPipelineConfigResponseError error
|
getForwardingPipelineConfigResponseError error
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
getForwardingPipelineConfigResponse: nil,
|
getForwardingPipelineConfigResponse: nil,
|
||||||
getForwardingPipelineConfigResponseError: errors.New("error when retrieving forwarding pipeline config"),
|
getForwardingPipelineConfigResponseError: errors.New("error when retrieving forwarding pipeline config"),
|
||||||
}, {
|
}, {
|
||||||
getForwardingPipelineConfigResponse: &p4v1.GetForwardingPipelineConfigResponse{
|
getForwardingPipelineConfigResponse: &p4.GetForwardingPipelineConfigResponse{
|
||||||
Config: nil,
|
Config: nil,
|
||||||
},
|
},
|
||||||
getForwardingPipelineConfigResponseError: nil,
|
getForwardingPipelineConfigResponseError: nil,
|
||||||
}, {
|
}, {
|
||||||
getForwardingPipelineConfigResponse: &p4v1.GetForwardingPipelineConfigResponse{
|
getForwardingPipelineConfigResponse: &p4.GetForwardingPipelineConfigResponse{
|
||||||
Config: &p4v1.ForwardingPipelineConfig{P4Info: nil},
|
Config: &p4.ForwardingPipelineConfig{P4Info: nil},
|
||||||
},
|
},
|
||||||
getForwardingPipelineConfigResponseError: nil,
|
getForwardingPipelineConfigResponseError: nil,
|
||||||
},
|
},
|
||||||
|
|
@ -94,7 +94,7 @@ func TestErrorGetP4Info(t *testing.T) {
|
||||||
|
|
||||||
for _, response := range responses {
|
for _, response := range responses {
|
||||||
p4RtClient := &fakeP4RuntimeClient{
|
p4RtClient := &fakeP4RuntimeClient{
|
||||||
getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) {
|
getForwardingPipelineConfigFn: func() (*p4.GetForwardingPipelineConfigResponse, error) {
|
||||||
return response.getForwardingPipelineConfigResponse, response.getForwardingPipelineConfigResponseError
|
return response.getForwardingPipelineConfigResponse, response.getForwardingPipelineConfigResponseError
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -111,23 +111,23 @@ func TestErrorGetP4Info(t *testing.T) {
|
||||||
|
|
||||||
func TestOneCounterRead(t *testing.T) {
|
func TestOneCounterRead(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
forwardingPipelineConfig *p4v1.ForwardingPipelineConfig
|
forwardingPipelineConfig *p4.ForwardingPipelineConfig
|
||||||
EntityCounterEntry *p4v1.Entity_CounterEntry
|
EntityCounterEntry *p4.Entity_CounterEntry
|
||||||
expected []telegraf.Metric
|
expected []telegraf.Metric
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
forwardingPipelineConfig: &p4v1.ForwardingPipelineConfig{
|
forwardingPipelineConfig: &p4.ForwardingPipelineConfig{
|
||||||
P4Info: &p4ConfigV1.P4Info{
|
P4Info: &p4_config.P4Info{
|
||||||
Counters: []*p4ConfigV1.Counter{
|
Counters: []*p4_config.Counter{
|
||||||
createCounter("foo", 1111, p4ConfigV1.CounterSpec_BOTH),
|
createCounter("foo", 1111, p4_config.CounterSpec_BOTH),
|
||||||
},
|
},
|
||||||
PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"},
|
PkgInfo: &p4_config.PkgInfo{Name: "P4Program"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
EntityCounterEntry: createEntityCounterEntry(
|
EntityCounterEntry: createEntityCounterEntry(
|
||||||
1111,
|
1111,
|
||||||
5,
|
5,
|
||||||
&p4v1.CounterData{ByteCount: 5, PacketCount: 1},
|
&p4.CounterData{ByteCount: 5, PacketCount: 1},
|
||||||
),
|
),
|
||||||
expected: []telegraf.Metric{testutil.MustMetric(
|
expected: []telegraf.Metric{testutil.MustMetric(
|
||||||
"p4_runtime",
|
"p4_runtime",
|
||||||
|
|
@ -143,22 +143,22 @@ func TestOneCounterRead(t *testing.T) {
|
||||||
time.Unix(0, 0)),
|
time.Unix(0, 0)),
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
forwardingPipelineConfig: &p4v1.ForwardingPipelineConfig{
|
forwardingPipelineConfig: &p4.ForwardingPipelineConfig{
|
||||||
P4Info: &p4ConfigV1.P4Info{
|
P4Info: &p4_config.P4Info{
|
||||||
Counters: []*p4ConfigV1.Counter{
|
Counters: []*p4_config.Counter{
|
||||||
createCounter(
|
createCounter(
|
||||||
"foo",
|
"foo",
|
||||||
2222,
|
2222,
|
||||||
p4ConfigV1.CounterSpec_BYTES,
|
p4_config.CounterSpec_BYTES,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"},
|
PkgInfo: &p4_config.PkgInfo{Name: "P4Program"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
EntityCounterEntry: createEntityCounterEntry(
|
EntityCounterEntry: createEntityCounterEntry(
|
||||||
2222,
|
2222,
|
||||||
5,
|
5,
|
||||||
&p4v1.CounterData{ByteCount: 5},
|
&p4.CounterData{ByteCount: 5},
|
||||||
),
|
),
|
||||||
expected: []telegraf.Metric{testutil.MustMetric(
|
expected: []telegraf.Metric{testutil.MustMetric(
|
||||||
"p4_runtime",
|
"p4_runtime",
|
||||||
|
|
@ -174,22 +174,22 @@ func TestOneCounterRead(t *testing.T) {
|
||||||
time.Unix(0, 0)),
|
time.Unix(0, 0)),
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
forwardingPipelineConfig: &p4v1.ForwardingPipelineConfig{
|
forwardingPipelineConfig: &p4.ForwardingPipelineConfig{
|
||||||
P4Info: &p4ConfigV1.P4Info{
|
P4Info: &p4_config.P4Info{
|
||||||
Counters: []*p4ConfigV1.Counter{
|
Counters: []*p4_config.Counter{
|
||||||
createCounter(
|
createCounter(
|
||||||
"foo",
|
"foo",
|
||||||
3333,
|
3333,
|
||||||
p4ConfigV1.CounterSpec_PACKETS,
|
p4_config.CounterSpec_PACKETS,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"},
|
PkgInfo: &p4_config.PkgInfo{Name: "P4Program"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
EntityCounterEntry: createEntityCounterEntry(
|
EntityCounterEntry: createEntityCounterEntry(
|
||||||
3333,
|
3333,
|
||||||
5,
|
5,
|
||||||
&p4v1.CounterData{PacketCount: 1},
|
&p4.CounterData{PacketCount: 1},
|
||||||
),
|
),
|
||||||
expected: []telegraf.Metric{testutil.MustMetric(
|
expected: []telegraf.Metric{testutil.MustMetric(
|
||||||
"p4_runtime",
|
"p4_runtime",
|
||||||
|
|
@ -205,18 +205,18 @@ func TestOneCounterRead(t *testing.T) {
|
||||||
time.Unix(0, 0)),
|
time.Unix(0, 0)),
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
forwardingPipelineConfig: &p4v1.ForwardingPipelineConfig{
|
forwardingPipelineConfig: &p4.ForwardingPipelineConfig{
|
||||||
P4Info: &p4ConfigV1.P4Info{
|
P4Info: &p4_config.P4Info{
|
||||||
Counters: []*p4ConfigV1.Counter{
|
Counters: []*p4_config.Counter{
|
||||||
createCounter("foo", 4444, p4ConfigV1.CounterSpec_BOTH),
|
createCounter("foo", 4444, p4_config.CounterSpec_BOTH),
|
||||||
},
|
},
|
||||||
PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"},
|
PkgInfo: &p4_config.PkgInfo{Name: "P4Program"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
EntityCounterEntry: createEntityCounterEntry(
|
EntityCounterEntry: createEntityCounterEntry(
|
||||||
4444,
|
4444,
|
||||||
5,
|
5,
|
||||||
&p4v1.CounterData{},
|
&p4.CounterData{},
|
||||||
),
|
),
|
||||||
expected: nil,
|
expected: nil,
|
||||||
},
|
},
|
||||||
|
|
@ -224,19 +224,19 @@ func TestOneCounterRead(t *testing.T) {
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
p4RtReadClient := &fakeP4RuntimeReadClient{
|
p4RtReadClient := &fakeP4RuntimeReadClient{
|
||||||
recvFn: func() (*p4v1.ReadResponse, error) {
|
recvFn: func() (*p4.ReadResponse, error) {
|
||||||
return &p4v1.ReadResponse{
|
return &p4.ReadResponse{
|
||||||
Entities: []*p4v1.Entity{{Entity: tt.EntityCounterEntry}},
|
Entities: []*p4.Entity{{Entity: tt.EntityCounterEntry}},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
p4RtClient := &fakeP4RuntimeClient{
|
p4RtClient := &fakeP4RuntimeClient{
|
||||||
readFn: func(*p4v1.ReadRequest) (p4v1.P4Runtime_ReadClient, error) {
|
readFn: func(*p4.ReadRequest) (p4.P4Runtime_ReadClient, error) {
|
||||||
return p4RtReadClient, nil
|
return p4RtReadClient, nil
|
||||||
},
|
},
|
||||||
getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) {
|
getForwardingPipelineConfigFn: func() (*p4.GetForwardingPipelineConfigResponse, error) {
|
||||||
return &p4v1.GetForwardingPipelineConfigResponse{
|
return &p4.GetForwardingPipelineConfigResponse{
|
||||||
Config: tt.forwardingPipelineConfig,
|
Config: tt.forwardingPipelineConfig,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
|
@ -270,19 +270,19 @@ func TestMultipleEntitiesSingleCounterRead(t *testing.T) {
|
||||||
totalNumOfEntries,
|
totalNumOfEntries,
|
||||||
"totalNumOfCounters",
|
"totalNumOfCounters",
|
||||||
)
|
)
|
||||||
entities := make([]*p4v1.Entity, 0, totalNumOfEntries)
|
entities := make([]*p4.Entity, 0, totalNumOfEntries)
|
||||||
p4InfoCounters := make([]*p4ConfigV1.Counter, 0, totalNumOfEntries)
|
p4InfoCounters := make([]*p4_config.Counter, 0, totalNumOfEntries)
|
||||||
p4InfoCounters = append(
|
p4InfoCounters = append(
|
||||||
p4InfoCounters,
|
p4InfoCounters,
|
||||||
createCounter("foo", 0, p4ConfigV1.CounterSpec_BOTH),
|
createCounter("foo", 0, p4_config.CounterSpec_BOTH),
|
||||||
)
|
)
|
||||||
|
|
||||||
for i := 0; i < totalNumOfEntries; i++ {
|
for i := 0; i < totalNumOfEntries; i++ {
|
||||||
counterEntry := &p4v1.Entity{
|
counterEntry := &p4.Entity{
|
||||||
Entity: createEntityCounterEntry(
|
Entity: createEntityCounterEntry(
|
||||||
0,
|
0,
|
||||||
int64(i),
|
int64(i),
|
||||||
&p4v1.CounterData{
|
&p4.CounterData{
|
||||||
ByteCount: int64(10),
|
ByteCount: int64(10),
|
||||||
PacketCount: int64(10),
|
PacketCount: int64(10),
|
||||||
},
|
},
|
||||||
|
|
@ -306,25 +306,25 @@ func TestMultipleEntitiesSingleCounterRead(t *testing.T) {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
forwardingPipelineConfig := &p4v1.ForwardingPipelineConfig{
|
forwardingPipelineConfig := &p4.ForwardingPipelineConfig{
|
||||||
P4Info: &p4ConfigV1.P4Info{
|
P4Info: &p4_config.P4Info{
|
||||||
Counters: p4InfoCounters,
|
Counters: p4InfoCounters,
|
||||||
PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"},
|
PkgInfo: &p4_config.PkgInfo{Name: "P4Program"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
p4RtReadClient := &fakeP4RuntimeReadClient{
|
p4RtReadClient := &fakeP4RuntimeReadClient{
|
||||||
recvFn: func() (*p4v1.ReadResponse, error) {
|
recvFn: func() (*p4.ReadResponse, error) {
|
||||||
return &p4v1.ReadResponse{Entities: entities}, nil
|
return &p4.ReadResponse{Entities: entities}, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
p4RtClient := &fakeP4RuntimeClient{
|
p4RtClient := &fakeP4RuntimeClient{
|
||||||
readFn: func(*p4v1.ReadRequest) (p4v1.P4Runtime_ReadClient, error) {
|
readFn: func(*p4.ReadRequest) (p4.P4Runtime_ReadClient, error) {
|
||||||
return p4RtReadClient, nil
|
return p4RtReadClient, nil
|
||||||
},
|
},
|
||||||
getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) {
|
getForwardingPipelineConfigFn: func() (*p4.GetForwardingPipelineConfigResponse, error) {
|
||||||
return &p4v1.GetForwardingPipelineConfigResponse{
|
return &p4.GetForwardingPipelineConfigResponse{
|
||||||
Config: forwardingPipelineConfig,
|
Config: forwardingPipelineConfig,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
|
@ -359,7 +359,7 @@ func TestSingleEntitiesMultipleCounterRead(t *testing.T) {
|
||||||
totalNumOfCounters,
|
totalNumOfCounters,
|
||||||
"totalNumOfCounters",
|
"totalNumOfCounters",
|
||||||
)
|
)
|
||||||
p4InfoCounters := make([]*p4ConfigV1.Counter, 0, totalNumOfCounters)
|
p4InfoCounters := make([]*p4_config.Counter, 0, totalNumOfCounters)
|
||||||
|
|
||||||
for i := 1; i <= totalNumOfCounters; i++ {
|
for i := 1; i <= totalNumOfCounters; i++ {
|
||||||
counterName := fmt.Sprintf("foo%v", i)
|
counterName := fmt.Sprintf("foo%v", i)
|
||||||
|
|
@ -368,7 +368,7 @@ func TestSingleEntitiesMultipleCounterRead(t *testing.T) {
|
||||||
createCounter(
|
createCounter(
|
||||||
counterName,
|
counterName,
|
||||||
uint32(i),
|
uint32(i),
|
||||||
p4ConfigV1.CounterSpec_BOTH,
|
p4_config.CounterSpec_BOTH,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -388,24 +388,24 @@ func TestSingleEntitiesMultipleCounterRead(t *testing.T) {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
forwardingPipelineConfig := &p4v1.ForwardingPipelineConfig{
|
forwardingPipelineConfig := &p4.ForwardingPipelineConfig{
|
||||||
P4Info: &p4ConfigV1.P4Info{
|
P4Info: &p4_config.P4Info{
|
||||||
Counters: p4InfoCounters,
|
Counters: p4InfoCounters,
|
||||||
PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"},
|
PkgInfo: &p4_config.PkgInfo{Name: "P4Program"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
p4RtClient := &fakeP4RuntimeClient{
|
p4RtClient := &fakeP4RuntimeClient{
|
||||||
readFn: func(in *p4v1.ReadRequest) (p4v1.P4Runtime_ReadClient, error) {
|
readFn: func(in *p4.ReadRequest) (p4.P4Runtime_ReadClient, error) {
|
||||||
counterID := in.Entities[0].GetCounterEntry().CounterId
|
counterID := in.Entities[0].GetCounterEntry().CounterId
|
||||||
return &fakeP4RuntimeReadClient{
|
return &fakeP4RuntimeReadClient{
|
||||||
recvFn: func() (*p4v1.ReadResponse, error) {
|
recvFn: func() (*p4.ReadResponse, error) {
|
||||||
return &p4v1.ReadResponse{
|
return &p4.ReadResponse{
|
||||||
Entities: []*p4v1.Entity{{
|
Entities: []*p4.Entity{{
|
||||||
Entity: createEntityCounterEntry(
|
Entity: createEntityCounterEntry(
|
||||||
counterID,
|
counterID,
|
||||||
1,
|
1,
|
||||||
&p4v1.CounterData{
|
&p4.CounterData{
|
||||||
ByteCount: 10,
|
ByteCount: 10,
|
||||||
PacketCount: 10,
|
PacketCount: 10,
|
||||||
},
|
},
|
||||||
|
|
@ -415,8 +415,8 @@ func TestSingleEntitiesMultipleCounterRead(t *testing.T) {
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) {
|
getForwardingPipelineConfigFn: func() (*p4.GetForwardingPipelineConfigResponse, error) {
|
||||||
return &p4v1.GetForwardingPipelineConfigResponse{
|
return &p4.GetForwardingPipelineConfigResponse{
|
||||||
Config: forwardingPipelineConfig,
|
Config: forwardingPipelineConfig,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
|
@ -442,13 +442,13 @@ func TestSingleEntitiesMultipleCounterRead(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoCountersAvailable(t *testing.T) {
|
func TestNoCountersAvailable(t *testing.T) {
|
||||||
forwardingPipelineConfig := &p4v1.ForwardingPipelineConfig{
|
forwardingPipelineConfig := &p4.ForwardingPipelineConfig{
|
||||||
P4Info: &p4ConfigV1.P4Info{Counters: []*p4ConfigV1.Counter{}},
|
P4Info: &p4_config.P4Info{Counters: []*p4_config.Counter{}},
|
||||||
}
|
}
|
||||||
|
|
||||||
p4RtClient := &fakeP4RuntimeClient{
|
p4RtClient := &fakeP4RuntimeClient{
|
||||||
getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) {
|
getForwardingPipelineConfigFn: func() (*p4.GetForwardingPipelineConfigResponse, error) {
|
||||||
return &p4v1.GetForwardingPipelineConfigResponse{
|
return &p4.GetForwardingPipelineConfigResponse{
|
||||||
Config: forwardingPipelineConfig,
|
Config: forwardingPipelineConfig,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
|
@ -464,18 +464,18 @@ func TestNoCountersAvailable(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterCounters(t *testing.T) {
|
func TestFilterCounters(t *testing.T) {
|
||||||
forwardingPipelineConfig := &p4v1.ForwardingPipelineConfig{
|
forwardingPipelineConfig := &p4.ForwardingPipelineConfig{
|
||||||
P4Info: &p4ConfigV1.P4Info{
|
P4Info: &p4_config.P4Info{
|
||||||
Counters: []*p4ConfigV1.Counter{
|
Counters: []*p4_config.Counter{
|
||||||
createCounter("foo", 1, p4ConfigV1.CounterSpec_BOTH),
|
createCounter("foo", 1, p4_config.CounterSpec_BOTH),
|
||||||
},
|
},
|
||||||
PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"},
|
PkgInfo: &p4_config.PkgInfo{Name: "P4Program"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
p4RtClient := &fakeP4RuntimeClient{
|
p4RtClient := &fakeP4RuntimeClient{
|
||||||
getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) {
|
getForwardingPipelineConfigFn: func() (*p4.GetForwardingPipelineConfigResponse, error) {
|
||||||
return &p4v1.GetForwardingPipelineConfigResponse{
|
return &p4.GetForwardingPipelineConfigResponse{
|
||||||
Config: forwardingPipelineConfig,
|
Config: forwardingPipelineConfig,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
|
@ -500,31 +500,31 @@ func TestFilterCounters(t *testing.T) {
|
||||||
|
|
||||||
func TestFailReadCounterEntryFromEntry(t *testing.T) {
|
func TestFailReadCounterEntryFromEntry(t *testing.T) {
|
||||||
p4RtReadClient := &fakeP4RuntimeReadClient{
|
p4RtReadClient := &fakeP4RuntimeReadClient{
|
||||||
recvFn: func() (*p4v1.ReadResponse, error) {
|
recvFn: func() (*p4.ReadResponse, error) {
|
||||||
return &p4v1.ReadResponse{
|
return &p4.ReadResponse{
|
||||||
Entities: []*p4v1.Entity{{
|
Entities: []*p4.Entity{{
|
||||||
Entity: &p4v1.Entity_TableEntry{
|
Entity: &p4.Entity_TableEntry{
|
||||||
TableEntry: &p4v1.TableEntry{},
|
TableEntry: &p4.TableEntry{},
|
||||||
}}}}, nil
|
}}}}, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
p4RtClient := &fakeP4RuntimeClient{
|
p4RtClient := &fakeP4RuntimeClient{
|
||||||
readFn: func(*p4v1.ReadRequest) (p4v1.P4Runtime_ReadClient, error) {
|
readFn: func(*p4.ReadRequest) (p4.P4Runtime_ReadClient, error) {
|
||||||
return p4RtReadClient, nil
|
return p4RtReadClient, nil
|
||||||
},
|
},
|
||||||
getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) {
|
getForwardingPipelineConfigFn: func() (*p4.GetForwardingPipelineConfigResponse, error) {
|
||||||
return &p4v1.GetForwardingPipelineConfigResponse{
|
return &p4.GetForwardingPipelineConfigResponse{
|
||||||
Config: &p4v1.ForwardingPipelineConfig{
|
Config: &p4.ForwardingPipelineConfig{
|
||||||
P4Info: &p4ConfigV1.P4Info{
|
P4Info: &p4_config.P4Info{
|
||||||
Counters: []*p4ConfigV1.Counter{
|
Counters: []*p4_config.Counter{
|
||||||
createCounter(
|
createCounter(
|
||||||
"foo",
|
"foo",
|
||||||
1111,
|
1111,
|
||||||
p4ConfigV1.CounterSpec_BOTH,
|
p4_config.CounterSpec_BOTH,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"},
|
PkgInfo: &p4_config.PkgInfo{Name: "P4Program"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
|
|
@ -553,21 +553,21 @@ func TestFailReadCounterEntryFromEntry(t *testing.T) {
|
||||||
|
|
||||||
func TestFailReadAllEntries(t *testing.T) {
|
func TestFailReadAllEntries(t *testing.T) {
|
||||||
p4RtClient := &fakeP4RuntimeClient{
|
p4RtClient := &fakeP4RuntimeClient{
|
||||||
readFn: func(*p4v1.ReadRequest) (p4v1.P4Runtime_ReadClient, error) {
|
readFn: func(*p4.ReadRequest) (p4.P4Runtime_ReadClient, error) {
|
||||||
return nil, errors.New("connection error")
|
return nil, errors.New("connection error")
|
||||||
},
|
},
|
||||||
getForwardingPipelineConfigFn: func() (*p4v1.GetForwardingPipelineConfigResponse, error) {
|
getForwardingPipelineConfigFn: func() (*p4.GetForwardingPipelineConfigResponse, error) {
|
||||||
return &p4v1.GetForwardingPipelineConfigResponse{
|
return &p4.GetForwardingPipelineConfigResponse{
|
||||||
Config: &p4v1.ForwardingPipelineConfig{
|
Config: &p4.ForwardingPipelineConfig{
|
||||||
P4Info: &p4ConfigV1.P4Info{
|
P4Info: &p4_config.P4Info{
|
||||||
Counters: []*p4ConfigV1.Counter{
|
Counters: []*p4_config.Counter{
|
||||||
createCounter(
|
createCounter(
|
||||||
"foo",
|
"foo",
|
||||||
1111,
|
1111,
|
||||||
p4ConfigV1.CounterSpec_BOTH,
|
p4_config.CounterSpec_BOTH,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
PkgInfo: &p4ConfigV1.PkgInfo{Name: "P4Program"},
|
PkgInfo: &p4_config.PkgInfo{Name: "P4Program"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
|
|
@ -595,11 +595,11 @@ func TestFailReadAllEntries(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterCounterNamesInclude(t *testing.T) {
|
func TestFilterCounterNamesInclude(t *testing.T) {
|
||||||
counters := []*p4ConfigV1.Counter{
|
counters := []*p4_config.Counter{
|
||||||
createCounter("foo", 1, p4ConfigV1.CounterSpec_BOTH),
|
createCounter("foo", 1, p4_config.CounterSpec_BOTH),
|
||||||
createCounter("bar", 2, p4ConfigV1.CounterSpec_BOTH),
|
createCounter("bar", 2, p4_config.CounterSpec_BOTH),
|
||||||
nil,
|
nil,
|
||||||
createCounter("", 3, p4ConfigV1.CounterSpec_BOTH),
|
createCounter("", 3, p4_config.CounterSpec_BOTH),
|
||||||
}
|
}
|
||||||
|
|
||||||
counterNamesInclude := []string{"bar"}
|
counterNamesInclude := []string{"bar"}
|
||||||
|
|
@ -607,8 +607,8 @@ func TestFilterCounterNamesInclude(t *testing.T) {
|
||||||
filteredCounters := filterCounters(counters, counterNamesInclude)
|
filteredCounters := filterCounters(counters, counterNamesInclude)
|
||||||
require.Equal(
|
require.Equal(
|
||||||
t,
|
t,
|
||||||
[]*p4ConfigV1.Counter{
|
[]*p4_config.Counter{
|
||||||
createCounter("bar", 2, p4ConfigV1.CounterSpec_BOTH),
|
createCounter("bar", 2, p4_config.CounterSpec_BOTH),
|
||||||
}, filteredCounters,
|
}, filteredCounters,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@ import (
|
||||||
"github.com/influxdata/telegraf/filter"
|
"github.com/influxdata/telegraf/filter"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/models"
|
"github.com/influxdata/telegraf/models"
|
||||||
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/openmetrics"
|
"github.com/influxdata/telegraf/plugins/parsers/openmetrics"
|
||||||
parser "github.com/influxdata/telegraf/plugins/parsers/prometheus"
|
parsers_prometheus "github.com/influxdata/telegraf/plugins/parsers/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed sample.conf
|
//go:embed sample.conf
|
||||||
|
|
@ -88,7 +88,7 @@ type Prometheus struct {
|
||||||
ConsulConfig ConsulConfig `toml:"consul"`
|
ConsulConfig ConsulConfig `toml:"consul"`
|
||||||
|
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
httpconfig.HTTPClientConfig
|
common_http.HTTPClientConfig
|
||||||
|
|
||||||
client *http.Client
|
client *http.Client
|
||||||
headers map[string]string
|
headers map[string]string
|
||||||
|
|
@ -525,7 +525,7 @@ func (p *Prometheus) gatherURL(u URLAndAddress, acc telegraf.Accumulator) (map[s
|
||||||
Log: p.Log,
|
Log: p.Log,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
metricParser = &parser.Parser{
|
metricParser = &parsers_prometheus.Parser{
|
||||||
Header: resp.Header,
|
Header: resp.Header,
|
||||||
MetricVersion: p.MetricVersion,
|
MetricVersion: p.MetricVersion,
|
||||||
IgnoreTimestamp: p.IgnoreTimestamp,
|
IgnoreTimestamp: p.IgnoreTimestamp,
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,14 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
riemanngo "github.com/riemann/riemann-go-client"
|
riemann "github.com/riemann/riemann-go-client"
|
||||||
riemangoProto "github.com/riemann/riemann-go-client/proto"
|
rieman_proto "github.com/riemann/riemann-go-client/proto"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ type RiemannSocketListener struct {
|
||||||
ReadTimeout *config.Duration `toml:"read_timeout"`
|
ReadTimeout *config.Duration `toml:"read_timeout"`
|
||||||
KeepAlivePeriod *config.Duration `toml:"keep_alive_period"`
|
KeepAlivePeriod *config.Duration `toml:"keep_alive_period"`
|
||||||
SocketMode string `toml:"socket_mode"`
|
SocketMode string `toml:"socket_mode"`
|
||||||
tlsint.ServerConfig
|
common_tls.ServerConfig
|
||||||
|
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
|
|
@ -178,7 +178,7 @@ func (rsl *riemannListener) read(conn net.Conn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
messagePb := &riemangoProto.Msg{}
|
messagePb := &rieman_proto.Msg{}
|
||||||
var header uint32
|
var header uint32
|
||||||
// First obtain the size of the riemann event from client and acknowledge
|
// First obtain the size of the riemann event from client and acknowledge
|
||||||
if err = binary.Read(conn, binary.BigEndian, &header); err != nil {
|
if err = binary.Read(conn, binary.BigEndian, &header); err != nil {
|
||||||
|
|
@ -201,7 +201,7 @@ func (rsl *riemannListener) read(conn net.Conn) {
|
||||||
rsl.riemannReturnErrorResponse(conn, "Failed to unmarshal")
|
rsl.riemannReturnErrorResponse(conn, "Failed to unmarshal")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
riemannEvents := riemanngo.ProtocolBuffersToEvents(messagePb.Events)
|
riemannEvents := riemann.ProtocolBuffersToEvents(messagePb.Events)
|
||||||
|
|
||||||
for _, m := range riemannEvents {
|
for _, m := range riemannEvents {
|
||||||
if m.Service == "" {
|
if m.Service == "" {
|
||||||
|
|
@ -227,7 +227,7 @@ func (rsl *riemannListener) read(conn net.Conn) {
|
||||||
|
|
||||||
func (rsl *riemannListener) riemannReturnResponse(conn net.Conn) {
|
func (rsl *riemannListener) riemannReturnResponse(conn net.Conn) {
|
||||||
t := true
|
t := true
|
||||||
message := new(riemangoProto.Msg)
|
message := new(rieman_proto.Msg)
|
||||||
message.Ok = &t
|
message.Ok = &t
|
||||||
returnData, err := proto.Marshal(message)
|
returnData, err := proto.Marshal(message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -249,7 +249,7 @@ func (rsl *riemannListener) riemannReturnResponse(conn net.Conn) {
|
||||||
|
|
||||||
func (rsl *riemannListener) riemannReturnErrorResponse(conn net.Conn, errorMessage string) {
|
func (rsl *riemannListener) riemannReturnErrorResponse(conn net.Conn, errorMessage string) {
|
||||||
t := false
|
t := false
|
||||||
message := new(riemangoProto.Msg)
|
message := new(rieman_proto.Msg)
|
||||||
message.Ok = &t
|
message.Ok = &t
|
||||||
message.Error = &errorMessage
|
message.Error = &errorMessage
|
||||||
returnData, err := proto.Marshal(message)
|
returnData, err := proto.Marshal(message)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import (
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
"github.com/influxdata/telegraf/plugins/common/socket"
|
"github.com/influxdata/telegraf/plugins/common/socket"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
influx "github.com/influxdata/telegraf/plugins/parsers/influx/influx_upstream"
|
parsers_influx_upstream "github.com/influxdata/telegraf/plugins/parsers/influx/influx_upstream"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
"github.com/leodido/go-syslog/v4/nontransparent"
|
"github.com/leodido/go-syslog/v4/nontransparent"
|
||||||
)
|
)
|
||||||
|
|
@ -179,7 +179,7 @@ func TestCases(t *testing.T) {
|
||||||
expectedErrorFilename := filepath.Join(testcasePath, "expected.err")
|
expectedErrorFilename := filepath.Join(testcasePath, "expected.err")
|
||||||
|
|
||||||
// Prepare the influx parser for expectations
|
// Prepare the influx parser for expectations
|
||||||
parser := &influx.Parser{}
|
parser := &parsers_influx_upstream.Parser{}
|
||||||
require.NoError(t, parser.Init())
|
require.NoError(t, parser.Init())
|
||||||
|
|
||||||
// Read the input data
|
// Read the input data
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
httpcommon "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ type Vault struct {
|
||||||
TokenFile string `toml:"token_file"`
|
TokenFile string `toml:"token_file"`
|
||||||
Token string `toml:"token"`
|
Token string `toml:"token"`
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
httpcommon.HTTPClientConfig
|
common_http.HTTPClientConfig
|
||||||
|
|
||||||
client *http.Client
|
client *http.Client
|
||||||
}
|
}
|
||||||
|
|
@ -192,7 +192,7 @@ func buildVaultMetrics(acc telegraf.Accumulator, sysMetrics *SysMetrics) error {
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("vault", func() telegraf.Input {
|
inputs.Add("vault", func() telegraf.Input {
|
||||||
return &Vault{
|
return &Vault{
|
||||||
HTTPClientConfig: httpcommon.HTTPClientConfig{
|
HTTPClientConfig: common_http.HTTPClientConfig{
|
||||||
ResponseHeaderTimeout: config.Duration(5 * time.Second),
|
ResponseHeaderTimeout: config.Duration(5 * time.Second),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
dockercontainer "github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
|
|
@ -183,13 +183,13 @@ func TestIntegration(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the docker container
|
// Start the docker container
|
||||||
container := testutil.Container{
|
cntnr := testutil.Container{
|
||||||
Image: "vault:1.13.3",
|
Image: "vault:1.13.3",
|
||||||
ExposedPorts: []string{"8200"},
|
ExposedPorts: []string{"8200"},
|
||||||
Env: map[string]string{
|
Env: map[string]string{
|
||||||
"VAULT_DEV_ROOT_TOKEN_ID": "root",
|
"VAULT_DEV_ROOT_TOKEN_ID": "root",
|
||||||
},
|
},
|
||||||
HostConfigModifier: func(hc *dockercontainer.HostConfig) {
|
HostConfigModifier: func(hc *container.HostConfig) {
|
||||||
hc.CapAdd = []string{"IPC_LOCK"}
|
hc.CapAdd = []string{"IPC_LOCK"}
|
||||||
},
|
},
|
||||||
WaitingFor: wait.ForAll(
|
WaitingFor: wait.ForAll(
|
||||||
|
|
@ -197,13 +197,13 @@ func TestIntegration(t *testing.T) {
|
||||||
wait.ForListeningPort(nat.Port("8200")),
|
wait.ForListeningPort(nat.Port("8200")),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
require.NoError(t, container.Start(), "failed to start container")
|
require.NoError(t, cntnr.Start(), "failed to start container")
|
||||||
defer container.Terminate()
|
defer cntnr.Terminate()
|
||||||
|
|
||||||
// Setup the plugin
|
// Setup the plugin
|
||||||
port := container.Ports["8200"]
|
port := cntnr.Ports["8200"]
|
||||||
plugin := &Vault{
|
plugin := &Vault{
|
||||||
URL: "http://" + container.Address + ":" + port,
|
URL: "http://" + cntnr.Address + ":" + port,
|
||||||
Token: "root",
|
Token: "root",
|
||||||
}
|
}
|
||||||
require.NoError(t, plugin.Init())
|
require.NoError(t, plugin.Init())
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/vmware/govmomi/vim25/types"
|
"github.com/vmware/govmomi/vim25/types"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
itls "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -130,7 +130,7 @@ func defaultVSphere() *VSphere {
|
||||||
DatacenterMetricInclude: nil,
|
DatacenterMetricInclude: nil,
|
||||||
DatacenterMetricExclude: nil,
|
DatacenterMetricExclude: nil,
|
||||||
DatacenterInclude: []string{"/**"},
|
DatacenterInclude: []string{"/**"},
|
||||||
ClientConfig: itls.ClientConfig{InsecureSkipVerify: true},
|
ClientConfig: common_tls.ClientConfig{InsecureSkipVerify: true},
|
||||||
|
|
||||||
MaxQueryObjects: 256,
|
MaxQueryObjects: 256,
|
||||||
MaxQueryMetrics: 256,
|
MaxQueryMetrics: 256,
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import (
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/internal/globpath"
|
"github.com/influxdata/telegraf/internal/globpath"
|
||||||
"github.com/influxdata/telegraf/plugins/common/proxy"
|
"github.com/influxdata/telegraf/plugins/common/proxy"
|
||||||
commontls "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ type X509Cert struct {
|
||||||
ServerName string `toml:"server_name"`
|
ServerName string `toml:"server_name"`
|
||||||
ExcludeRootCerts bool `toml:"exclude_root_certs"`
|
ExcludeRootCerts bool `toml:"exclude_root_certs"`
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
commontls.ClientConfig
|
common_tls.ClientConfig
|
||||||
proxy.TCPProxy
|
proxy.TCPProxy
|
||||||
|
|
||||||
tlsCfg *tls.Config
|
tlsCfg *tls.Config
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -457,7 +457,7 @@ func TestServerName(t *testing.T) {
|
||||||
sc := &X509Cert{
|
sc := &X509Cert{
|
||||||
Sources: []string{test.url},
|
Sources: []string{test.url},
|
||||||
ServerName: test.fromCfg,
|
ServerName: test.fromCfg,
|
||||||
ClientConfig: _tls.ClientConfig{ServerName: test.fromTLS},
|
ClientConfig: common_tls.ClientConfig{ServerName: test.fromTLS},
|
||||||
Log: testutil.Logger{},
|
Log: testutil.Logger{},
|
||||||
}
|
}
|
||||||
err := sc.Init()
|
err := sc.Init()
|
||||||
|
|
@ -569,7 +569,7 @@ func TestClassification(t *testing.T) {
|
||||||
certURI := "file://" + filepath.Join(tmpDir, "cert.pem")
|
certURI := "file://" + filepath.Join(tmpDir, "cert.pem")
|
||||||
plugin := &X509Cert{
|
plugin := &X509Cert{
|
||||||
Sources: []string{certURI},
|
Sources: []string{certURI},
|
||||||
ClientConfig: _tls.ClientConfig{
|
ClientConfig: common_tls.ClientConfig{
|
||||||
TLSCA: filepath.Join(tmpDir, "ca.pem"),
|
TLSCA: filepath.Join(tmpDir, "ca.pem"),
|
||||||
},
|
},
|
||||||
Log: testutil.Logger{},
|
Log: testutil.Logger{},
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,9 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/apache/thrift/lib/go/thrift"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/apache/thrift/lib/go/thrift"
|
||||||
)
|
)
|
||||||
|
|
||||||
// (needed to ensure safety because of naive import list construction.)
|
// (needed to ensure safety because of naive import list construction.)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
tlsint "github.com/influxdata/telegraf/plugins/common/tls"
|
common_tls "github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ type Zookeeper struct {
|
||||||
|
|
||||||
EnableTLS bool `toml:"enable_tls"`
|
EnableTLS bool `toml:"enable_tls"`
|
||||||
EnableSSL bool `toml:"enable_ssl" deprecated:"1.7.0;1.35.0;use 'enable_tls' instead"`
|
EnableSSL bool `toml:"enable_ssl" deprecated:"1.7.0;1.35.0;use 'enable_tls' instead"`
|
||||||
tlsint.ClientConfig
|
common_tls.ClientConfig
|
||||||
|
|
||||||
initialized bool
|
initialized bool
|
||||||
tlsConfig *tls.Config
|
tlsConfig *tls.Config
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package mocks
|
package mocks
|
||||||
|
|
||||||
import mock "github.com/stretchr/testify/mock"
|
import "github.com/stretchr/testify/mock"
|
||||||
|
|
||||||
// DiagnosticsMessageSubscriber is an autogenerated mock type for the DiagnosticsMessageSubscriber type
|
// DiagnosticsMessageSubscriber is an autogenerated mock type for the DiagnosticsMessageSubscriber type
|
||||||
type DiagnosticsMessageListener struct {
|
type DiagnosticsMessageListener struct {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
telegrafJson "github.com/influxdata/telegraf/plugins/serializers/json"
|
serializers_json "github.com/influxdata/telegraf/plugins/serializers/json"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -105,7 +105,7 @@ func TestWrite(t *testing.T) {
|
||||||
|
|
||||||
for _, tC := range testCases {
|
for _, tC := range testCases {
|
||||||
t.Run(tC.name, func(t *testing.T) {
|
t.Run(tC.name, func(t *testing.T) {
|
||||||
serializer := &telegrafJson.Serializer{}
|
serializer := &serializers_json.Serializer{}
|
||||||
require.NoError(t, serializer.Init())
|
require.NoError(t, serializer.Init())
|
||||||
|
|
||||||
ingestionType := "queued"
|
ingestionType := "queued"
|
||||||
|
|
@ -156,7 +156,7 @@ func TestWrite(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateAzureDataExplorerTable(t *testing.T) {
|
func TestCreateAzureDataExplorerTable(t *testing.T) {
|
||||||
serializer := &telegrafJson.Serializer{}
|
serializer := &serializers_json.Serializer{}
|
||||||
require.NoError(t, serializer.Init())
|
require.NoError(t, serializer.Init())
|
||||||
plugin := AzureDataExplorer{
|
plugin := AzureDataExplorer{
|
||||||
Endpoint: "someendpoint",
|
Endpoint: "someendpoint",
|
||||||
|
|
@ -251,7 +251,7 @@ func TestWriteWithType(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
t.Run(testCase.name, func(t *testing.T) {
|
t.Run(testCase.name, func(t *testing.T) {
|
||||||
serializer := &telegrafJson.Serializer{}
|
serializer := &serializers_json.Serializer{}
|
||||||
require.NoError(t, serializer.Init())
|
require.NoError(t, serializer.Init())
|
||||||
for tableName, jsonValue := range testCase.tableNameToExpectedResult {
|
for tableName, jsonValue := range testCase.tableNameToExpectedResult {
|
||||||
ingestionType := "queued"
|
ingestionType := "queued"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
package cloud_pubsub
|
package cloud_pubsub
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cloud.google.com/go/pubsub"
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"cloud.google.com/go/pubsub"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/influxdata/telegraf/config"
|
"github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
"github.com/influxdata/telegraf/plugins/parsers/influx"
|
||||||
serializer "github.com/influxdata/telegraf/plugins/serializers/influx"
|
serializers_influx "github.com/influxdata/telegraf/plugins/serializers/influx"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -64,7 +64,7 @@ type (
|
||||||
|
|
||||||
func getTestResources(tT *testing.T, settings pubsub.PublishSettings, testM []testMetric) (*PubSub, *stubTopic, []telegraf.Metric) {
|
func getTestResources(tT *testing.T, settings pubsub.PublishSettings, testM []testMetric) (*PubSub, *stubTopic, []telegraf.Metric) {
|
||||||
// Instantiate a Influx line-protocol serializer
|
// Instantiate a Influx line-protocol serializer
|
||||||
s := &serializer.Serializer{}
|
s := &serializers_influx.Serializer{}
|
||||||
require.NoError(tT, s.Init())
|
require.NoError(tT, s.Init())
|
||||||
|
|
||||||
metrics := make([]telegraf.Metric, 0, len(testM))
|
metrics := make([]telegraf.Metric, 0, len(testM))
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ import (
|
||||||
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
|
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
internalaws "github.com/influxdata/telegraf/plugins/common/aws"
|
common_aws "github.com/influxdata/telegraf/plugins/common/aws"
|
||||||
httpconfig "github.com/influxdata/telegraf/plugins/common/http"
|
common_http "github.com/influxdata/telegraf/plugins/common/http"
|
||||||
"github.com/influxdata/telegraf/plugins/outputs"
|
"github.com/influxdata/telegraf/plugins/outputs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -29,8 +29,8 @@ type CloudWatch struct {
|
||||||
svc *cloudwatch.Client
|
svc *cloudwatch.Client
|
||||||
WriteStatistics bool `toml:"write_statistics"`
|
WriteStatistics bool `toml:"write_statistics"`
|
||||||
Log telegraf.Logger `toml:"-"`
|
Log telegraf.Logger `toml:"-"`
|
||||||
internalaws.CredentialConfig
|
common_aws.CredentialConfig
|
||||||
httpconfig.HTTPClientConfig
|
common_http.HTTPClientConfig
|
||||||
client *http.Client
|
client *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue