Skip to content

Commit

Permalink
Merge branch 'master' into feature/opensearch-support
Browse files Browse the repository at this point in the history
* master: (117 commits)
  fix: bump github.com/nats-io/nats-server/v2 from 2.6.5 to 2.7.2 (influxdata#10638)
  chore: add -race flag to go tests (influxdata#10629)
  feat: update etc/telegraf.conf and etc/telegraf_windows.conf (influxdata#10631)
  fix: license doc outdated causing CI failure (influxdata#10630)
  fix: bump k8s.io/client-go from 0.22.2 to 0.23.3 (influxdata#10589)
  feat: Implemented support for reading raw values, added tests and doc (influxdata#6501)
  fix: Improve parser tests by using go-cmp/cmp (influxdata#10497)
  feat(mongodb): add FsTotalSize and FsUsedSize informations (influxdata#10625)
  docs: update quay docs for auth (influxdata#10612)
  chore: allow downgrade of go version in windows script (influxdata#10614)
  chore: update CI go to 1.17.6 (influxdata#10611)
  feat: update etc/telegraf.conf and etc/telegraf_windows.conf (influxdata#10600)
  fix(inputs.opcua): add more data to error log (influxdata#10465)
  fix: bump github.com/aws/aws-sdk-go-v2/service/kinesis from 1.6.0 to 1.13.0 (influxdata#10601)
  refactor: use early return pattern (influxdata#10591)
  fix: bump github.com/benbjohnson/clock from 1.1.0 to 1.3.0 (influxdata#10588)
  feat: add dynamic tagging to gnmi plugin (influxdata#7484)
  fix: bump github.com/Azure/azure-kusto-go from 0.5.0 to 0.5.2 (influxdata#10598)
  feat: update etc/telegraf.conf and etc/telegraf_windows.conf (influxdata#10584)
  fix(parsers.json_v2): allow optional paths and handle wrong paths correctly (influxdata#10468)
  ...

# Conflicts:
#	plugins/outputs/elasticsearch/elasticsearch.go
#	plugins/outputs/elasticsearch/elasticsearch_test.go
  • Loading branch information
pteich committed Feb 13, 2022
2 parents 30fa23b + 3b980ee commit 0afaf35
Show file tree
Hide file tree
Showing 169 changed files with 7,293 additions and 1,850 deletions.
43 changes: 39 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ executors:
working_directory: '/go/src/github.com/influxdata/telegraf'
resource_class: large
docker:
- image: 'quay.io/influxdb/telegraf-ci:1.17.5'
- image: 'quay.io/influxdb/telegraf-ci:1.17.6'
environment:
GOFLAGS: -p=4
mac:
Expand Down Expand Up @@ -42,6 +42,9 @@ commands:
os:
type: string
default: "linux"
arch:
type: string
default: "amd64"
gotestsum:
type: string
default: "gotestsum"
Expand Down Expand Up @@ -74,11 +77,17 @@ commands:
- restore_cache:
key: windows-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
- run: 'sh ./scripts/installgo_windows.sh'
- run: choco install mingw
- run: mkdir -p test-results
- run: ./scripts/install_gotestsum.sh << parameters.os >> << parameters.gotestsum >>
- unless:
condition:
equal: [ "386", << parameters.arch >> ]
steps:
- run: echo 'export RACE="-race"' >> $BASH_ENV
- run: |
PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname)
./<< parameters.gotestsum >> --junitfile test-results/gotestsum-report.xml -- -short $PACKAGE_NAMES
GOARCH=<< parameters.arch >> ./<< parameters.gotestsum >> --junitfile test-results/gotestsum-report.xml -- ${RACE} -short $PACKAGE_NAMES
- store_test_results:
path: test-results
- when:
Expand Down Expand Up @@ -126,6 +135,11 @@ commands:
- check-changed-files-or-halt
- attach_workspace:
at: '/go'
- when:
condition:
equal: [ windows, << parameters.type >> ]
steps:
- run: make versioninfo
- when:
condition: << parameters.nightly >>
steps:
Expand Down Expand Up @@ -166,6 +180,19 @@ jobs:
root: '/go'
paths:
- '*'
test-go-linux-386:
executor: go-1_17
parallelism: 4
steps:
- checkout
- restore_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
- check-changed-files-or-halt
- run: 'GOARCH=386 make deps'
- run: 'GOARCH=386 make tidy'
- run: 'GOARCH=386 make check'
- test-go:
arch: "386"
test-go-mac:
executor: mac
steps:
Expand Down Expand Up @@ -379,6 +406,9 @@ jobs:
steps:
- attach_workspace:
at: '.'
- run:
command: |
cd dist && find . -type f -name '._*' -delete
- store_artifacts:
path: './dist'
destination: 'build/dist'
Expand Down Expand Up @@ -415,6 +445,10 @@ workflows:
filters:
tags:
only: /.*/
- 'test-go-linux-386':
filters:
tags:
only: /.*/
- 'test-go-mac':
filters:
tags: # only runs on tags if you specify this filter
Expand Down Expand Up @@ -443,7 +477,7 @@ workflows:
only: /.*/
- 'i386-package':
requires:
- 'test-go-linux'
- 'test-go-linux-386'
filters:
tags:
only: /.*/
Expand Down Expand Up @@ -585,6 +619,7 @@ workflows:
nightly:
jobs:
- 'test-go-linux'
- 'test-go-linux-386'
- 'test-go-mac'
- 'test-go-windows'
- 'windows-package':
Expand All @@ -606,7 +641,7 @@ workflows:
name: 'i386-package-nightly'
nightly: true
requires:
- 'test-go-linux'
- 'test-go-linux-386'
- 'ppc64le-package':
name: 'ppc64le-package-nightly'
nightly: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ body:
- type: textarea
id: config
attributes:
label: Relevent telegraf.conf
label: Relevant telegraf.conf
description: Place config in the toml code section. This will be automatically formatted into toml, so no need for backticks.
render: toml
validations:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ process.yml
/.vscode
/*.toml
/*.conf
resource.syso
versioninfo.json
41 changes: 40 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
<!-- markdownlint-disable MD024 -->

# Change Log
# Changelog

## v1.21.3 [2022-01-27]

### Bugfixes

- [#10430](https://github.com/influxdata/telegraf/pull/10430) `inputs.snmp_trap` Fix translation of partially resolved OIDs
- [#10529](https://github.com/influxdata/telegraf/pull/10529) Update deprecation notices
- [#10525](https://github.com/influxdata/telegraf/pull/10525) Update grpc module to v1.44.0
- [#10434](https://github.com/influxdata/telegraf/pull/10434) Update google.golang.org/api module from 0.54.0 to 0.65.0
- [#10507](https://github.com/influxdata/telegraf/pull/10507) Update antchfx/xmlquery module from 1.3.6 to 1.3.9
- [#10521](https://github.com/influxdata/telegraf/pull/10521) Update nsqio/go-nsq module from 1.0.8 to 1.1.0
- [#10506](https://github.com/influxdata/telegraf/pull/10506) Update prometheus/common module from 0.31.1 to 0.32.1
- [#10474](https://github.com/influxdata/telegraf/pull/10474) `inputs.ipset` Fix panic when command not found
- [#10504](https://github.com/influxdata/telegraf/pull/10504) Update cloud.google.com/go/pubsub module from 1.17.0 to 1.17.1
- [#10432](https://github.com/influxdata/telegraf/pull/10432) Update influxdata/influxdb-observability/influx2otel module from 0.2.8 to 0.2.10
- [#10478](https://github.com/influxdata/telegraf/pull/10478) `inputs.opcua` Remove duplicate fields
- [#10473](https://github.com/influxdata/telegraf/pull/10473) `parsers.nagios` Log correct errors when executing commands
- [#10463](https://github.com/influxdata/telegraf/pull/10463) `inputs.execd` Add newline in execd for prometheus parsing
- [#10451](https://github.com/influxdata/telegraf/pull/10451) Update shirou/gopsutil/v3 module from 3.21.10 to 3.21.12
- [#10453](https://github.com/influxdata/telegraf/pull/10453) Update jackc/pgx/v4 module from 4.6.0 to 4.14.1
- [#10449](https://github.com/influxdata/telegraf/pull/10449) Update Azure/azure-event-hubs-go/v3 module from 3.3.13 to 3.3.17
- [#10450](https://github.com/influxdata/telegraf/pull/10450) Update gosnmp/gosnmp module from 1.33.0 to 1.34.0
- [#10442](https://github.com/influxdata/telegraf/pull/10442) `parsers.wavefront` Add missing setting wavefront_disable_prefix_conversion
- [#10435](https://github.com/influxdata/telegraf/pull/10435) Update hashicorp/consul/api module from 1.9.1 to 1.12.0
- [#10436](https://github.com/influxdata/telegraf/pull/10436) Update antchfx/xpath module from 1.1.11 to 1.2.0
- [#10433](https://github.com/influxdata/telegraf/pull/10433) Update antchfx/jsonquery module from 1.1.4 to 1.1.5
- [#10414](https://github.com/influxdata/telegraf/pull/10414) Update prometheus/procfs module from 0.6.0 to 0.7.3
- [#10354](https://github.com/influxdata/telegraf/pull/10354) `inputs.snmp` Fix panic when mibs folder doesn't exist (#10346)
- [#10393](https://github.com/influxdata/telegraf/pull/10393) `outputs.syslog` Correctly set ASCII trailer for syslog output
- [#10415](https://github.com/influxdata/telegraf/pull/10415) Update aws/aws-sdk-go-v2/service/cloudwatchlogs module from 1.5.2 to 1.12.0
- [#10416](https://github.com/influxdata/telegraf/pull/10416) Update kardianos/service module from 1.0.0 to 1.2.1
- [#10396](https://github.com/influxdata/telegraf/pull/10396) `inputs.http` Allow empty http body
- [#10417](https://github.com/influxdata/telegraf/pull/10417) Update couchbase/go-couchbase module from 0.1.0 to 0.1.1
- [#10413](https://github.com/influxdata/telegraf/pull/10413) `parsers.json_v2` Fix timestamp precision when using unix_ns format
- [#10418](https://github.com/influxdata/telegraf/pull/10418) Update pion/dtls/v2 module from 2.0.9 to 2.0.13
- [#10402](https://github.com/influxdata/telegraf/pull/10402) Update containerd/containerd module to 1.5.9
- [#8947](https://github.com/influxdata/telegraf/pull/8947) `outputs.timestream` Fix batching logic with write records and introduce concurrent requests
- [#10360](https://github.com/influxdata/telegraf/pull/10360) `outputs.amqp` Avoid connection leak when writing error
- [#10097](https://github.com/influxdata/telegraf/pull/10097) `outputs.stackdriver` Send correct interval start times for counters

## v1.21.2 [2022-01-05]

Expand Down
2 changes: 2 additions & 0 deletions EXTERNAL_PLUGINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Pull requests welcome.
- [dht_sensor](https://github.com/iAnatoly/telegraf-input-dht_sensor) - Gather temperature and humidity from DHTXX sensors
- [oracle](https://github.com/bonitoo-io/telegraf-input-oracle) - Gather the statistic data from Oracle RDBMS
- [db2](https://github.com/bonitoo-io/telegraf-input-db2) - Gather the statistic data from DB2 RDBMS
- [apt](https://github.com/x70b1/telegraf-apt) - Check Debian for package updates.
- [knot](https://github.com/x70b1/telegraf-knot) - Collect stats from Knot DNS.

## Outputs

Expand Down
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ help:
deps:
go mod download -x

.PHONY: version
version:
@echo $(version)-$(commit)

.PHONY: versioninfo
versioninfo:
go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.4.0; \
go run scripts/generate_versioninfo/main.go; \
go generate cmd/telegraf/telegraf_windows.go; \

.PHONY: telegraf
telegraf:
go build -ldflags "$(LDFLAGS)" ./cmd/telegraf
Expand Down Expand Up @@ -211,8 +221,8 @@ plugin-%:

.PHONY: ci-1.17
ci-1.17:
docker build -t quay.io/influxdb/telegraf-ci:1.17.5 - < scripts/ci-1.17.docker
docker push quay.io/influxdb/telegraf-ci:1.17.5
docker build -t quay.io/influxdb/telegraf-ci:1.17.6 - < scripts/ci-1.17.docker
docker push quay.io/influxdb/telegraf-ci:1.17.6

.PHONY: install
install: $(buildbin)
Expand All @@ -235,6 +245,7 @@ install: $(buildbin)
# the bin between deb/rpm/tar packages over building directly into the package
# directory.
$(buildbin):
echo $(GOOS)
@mkdir -pv $(dir $@)
go build -o $(dir $@) -ldflags "$(LDFLAGS)" ./cmd/telegraf

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ file and install telegraf:
cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL $releasever
baseurl = https://repos.influxdata.com/rhel/$releasever/$basearch/stable
baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
Expand Down
7 changes: 7 additions & 0 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ func (a *Agent) initPlugins() error {
input.LogName(), err)
}
}
for _, parser := range a.Config.Parsers {
err := parser.Init()
if err != nil {
return fmt.Errorf("could not initialize parser %s::%s: %v",
parser.Config.DataFormat, parser.Config.Parent, err)
}
}
for _, processor := range a.Config.Processors {
err := processor.Init()
if err != nil {
Expand Down
Binary file added assets/tiger.ico
Binary file not shown.
38 changes: 23 additions & 15 deletions cmd/telegraf/telegraf.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
_ "github.com/influxdata/telegraf/plugins/inputs/all"
"github.com/influxdata/telegraf/plugins/outputs"
_ "github.com/influxdata/telegraf/plugins/outputs/all"
_ "github.com/influxdata/telegraf/plugins/parsers/all"
_ "github.com/influxdata/telegraf/plugins/processors/all"
"gopkg.in/tomb.v1"
)
Expand Down Expand Up @@ -95,6 +96,14 @@ var fServiceName = flag.String("service-name", "telegraf",
var fServiceDisplayName = flag.String("service-display-name", "Telegraf Data Collector Service",
"service display name (windows only)")

//nolint:varcheck,unused // False positive - this var is used for non-default build tag: windows
var fServiceAutoRestart = flag.Bool("service-auto-restart", false,
"auto restart service on failure (windows only)")

//nolint:varcheck,unused // False positive - this var is used for non-default build tag: windows
var fServiceRestartDelay = flag.String("service-restart-delay", "5m",
"delay before service auto restart, default is 5m (windows only)")

//nolint:varcheck,unused // False positive - this var is used for non-default build tag: windows
var fRunAsConsole = flag.Bool("console", false,
"run as console application (windows only)")
Expand Down Expand Up @@ -197,8 +206,6 @@ func runAgent(ctx context.Context,
inputFilters []string,
outputFilters []string,
) error {
log.Printf("I! Starting Telegraf %s", version)

// If no other options are specified, load the config file and run.
c := config.NewConfig()
c.OutputFilters = outputFilters
Expand Down Expand Up @@ -240,26 +247,22 @@ func runAgent(ctx context.Context,
return fmt.Errorf("Agent flush_interval must be positive; found %v", c.Agent.Interval)
}

ag, err := agent.NewAgent(c)
if err != nil {
return err
}

// Setup logging as configured.
telegraf.Debug = ag.Config.Agent.Debug || *fDebug
telegraf.Debug = c.Agent.Debug || *fDebug
logConfig := logger.LogConfig{
Debug: telegraf.Debug,
Quiet: ag.Config.Agent.Quiet || *fQuiet,
LogTarget: ag.Config.Agent.LogTarget,
Logfile: ag.Config.Agent.Logfile,
RotationInterval: ag.Config.Agent.LogfileRotationInterval,
RotationMaxSize: ag.Config.Agent.LogfileRotationMaxSize,
RotationMaxArchives: ag.Config.Agent.LogfileRotationMaxArchives,
LogWithTimezone: ag.Config.Agent.LogWithTimezone,
Quiet: c.Agent.Quiet || *fQuiet,
LogTarget: c.Agent.LogTarget,
Logfile: c.Agent.Logfile,
RotationInterval: c.Agent.LogfileRotationInterval,
RotationMaxSize: c.Agent.LogfileRotationMaxSize,
RotationMaxArchives: c.Agent.LogfileRotationMaxArchives,
LogWithTimezone: c.Agent.LogWithTimezone,
}

logger.SetupLogging(logConfig)

log.Printf("I! Starting Telegraf %s", version)
log.Printf("I! Loaded inputs: %s", strings.Join(c.InputNames(), " "))
log.Printf("I! Loaded aggregators: %s", strings.Join(c.AggregatorNames(), " "))
log.Printf("I! Loaded processors: %s", strings.Join(c.ProcessorNames(), " "))
Expand All @@ -283,6 +286,11 @@ func runAgent(ctx context.Context,
log.Printf("W! Deprecated outputs: %d and %d options", count[0], count[1])
}

ag, err := agent.NewAgent(c)
if err != nil {
return err
}

// Notify systemd that telegraf is ready
// SdNotify() only tries to notify if the NOTIFY_SOCKET environment is set, so it's safe to call when systemd isn't present.
// Ignore the return values here because they're not valid for platforms that don't use systemd.
Expand Down
6 changes: 6 additions & 0 deletions cmd/telegraf/telegraf_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//go:build windows
// +build windows

//go:generate goversioninfo -icon=../../assets/tiger.ico

package main

import (
Expand Down Expand Up @@ -92,6 +94,10 @@ func runAsWindowsService(inputFilters, outputFilters []string) {
//set servicename to service cmd line, to have a custom name after relaunch as a service
svcConfig.Arguments = append(svcConfig.Arguments, "--service-name", *fServiceName)

if *fServiceAutoRestart {
svcConfig.Option = service.KeyValue{"OnFailure": "restart", "OnFailureDelayDuration": *fServiceRestartDelay}
}

err := service.Control(s, *fService)
if err != nil {
log.Fatal("E! " + err.Error())
Expand Down
Loading

0 comments on commit 0afaf35

Please sign in to comment.