Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into mysql-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fxedel committed Nov 15, 2021
2 parents 5594d4d + b9c444b commit 72939ac
Show file tree
Hide file tree
Showing 120 changed files with 5,637 additions and 2,125 deletions.
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ executors:
go-1_17:
working_directory: '/go/src/github.com/influxdata/telegraf'
docker:
- image: 'quay.io/influxdb/telegraf-ci:1.17.2'
- image: 'quay.io/influxdb/telegraf-ci:1.17.3'
environment:
GOFLAGS: -p=8
mac:
Expand Down Expand Up @@ -399,6 +399,8 @@ jobs:
share-artifacts:
executor: aws-cli/default
steps:
- checkout
- check-changed-files-or-halt
- run:
command: |
PR=${CIRCLE_PULL_REQUEST##*/}
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
#################################
#################################
## Super Linter GitHub Actions ##
#################################
#################################
name: Lint Code Base

#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#

#############################
# Start the job on all push #
#############################
on:
push:
branches-ignore: [master, main]
# Remove the line above to run when pushing to master
pull_request:
branches: [master, main]

###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Lint Code Base
# Set the agent to run on
runs-on: ubuntu-latest

##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

################################
# Run Linter against code base #
################################
- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: '.'
MARKDOWN_CONFIG_FILE: .markdownlint.yml
VALIDATE_MARKDOWN: true
4 changes: 0 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ linters:
- varcheck

linters-settings:
# custom:
# telegraflinter:
# path: telegraflinter.so
# description: "Find Telegraf specific review criteria, more info: https://github.com/influxdata/telegraf/wiki/Review"
revive:
rules:
- name: argument-limit
Expand Down
3 changes: 3 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"MD013": false
}
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ vet:

.PHONY: lint-install
lint-install:

@echo "Installing golangci-lint"
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.42.1

@echo "Installing markdownlint"
npm install -g markdownlint-cli

.PHONY: lint
lint:
ifeq (, $(shell which golangci-lint))
Expand All @@ -152,6 +155,13 @@ endif

golangci-lint run

ifeq (, $(shell which markdownlint-cli))
$(info markdownlint-cli can't be found, please run: make lint-install)
exit 1
endif

markdownlint-cli

.PHONY: lint-branch
lint-branch:
ifeq (, $(shell which golangci-lint))
Expand Down Expand Up @@ -201,8 +211,8 @@ plugin-%:

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

.PHONY: install
install: $(buildbin)
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ Telegraf requires Go version 1.17 or newer, the Makefile requires GNU make.

1. [Install Go](https://golang.org/doc/install) >=1.17 (1.17.2 recommended)
2. Clone the Telegraf repository:
```

```shell
git clone https://github.com/influxdata/telegraf.git
```

3. Run `make` from the source directory
```

```shell
cd telegraf
make
```
Expand Down Expand Up @@ -106,39 +109,39 @@ See usage with:
telegraf --help
```

#### Generate a telegraf config file:
### Generate a telegraf config file

```shell
telegraf config > telegraf.conf
```

#### Generate config with only cpu input & influxdb output plugins defined:
### Generate config with only cpu input & influxdb output plugins defined

```shell
telegraf --section-filter agent:inputs:outputs --input-filter cpu --output-filter influxdb config
```

#### Run a single telegraf collection, outputting metrics to stdout:
### Run a single telegraf collection, outputting metrics to stdout

```shell
telegraf --config telegraf.conf --test
```

#### Run telegraf with all plugins defined in config file:
### Run telegraf with all plugins defined in config file

```shell
telegraf --config telegraf.conf
```

#### Run telegraf, enabling the cpu & memory input, and influxdb output plugins:
### Run telegraf, enabling the cpu & memory input, and influxdb output plugins

```shell
telegraf --config telegraf.conf --input-filter cpu:mem --output-filter influxdb
```

## Documentation

[Latest Release Documentation](https://docs.influxdata.com/telegraf)
[Latest Release Documentation](https://docs.influxdata.com/telegraf/latest/)

For documentation on the latest development code see the [documentation index](/docs).

Expand Down
5 changes: 4 additions & 1 deletion docs/LICENSE_OF_DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ following works:
- github.com/googleapis/gax-go [BSD 3-Clause "New" or "Revised" License](https://github.com/googleapis/gax-go/blob/master/LICENSE)
- github.com/googleapis/gnostic [Apache License 2.0](https://github.com/google/gnostic/blob/master/LICENSE)
- github.com/gopcua/opcua [MIT License](https://github.com/gopcua/opcua/blob/master/LICENSE)
- github.com/gophercloud/gophercloud [Apache License 2.0](https://github.com/gophercloud/gophercloud/blob/master/LICENSE)
- github.com/gorilla/mux [BSD 3-Clause "New" or "Revised" License](https://github.com/gorilla/mux/blob/master/LICENSE)
- github.com/gorilla/websocket [BSD 2-Clause "Simplified" License](https://github.com/gorilla/websocket/blob/master/LICENSE)
- github.com/gosnmp/gosnmp [BSD 2-Clause "Simplified" License](https://github.com/gosnmp/gosnmp/blob/master/LICENSE)
Expand Down Expand Up @@ -283,5 +284,7 @@ following works:
- modernc.org/sqlite [BSD 3-Clause "New" or "Revised" License](https://gitlab.com/cznic/sqlite/-/blob/master/LICENSE)
- sigs.k8s.io/structured-merge-diff [Apache License 2.0](https://github.com/kubernetes/client-go/blob/master/LICENSE)
- sigs.k8s.io/yaml [Apache License 2.0](https://github.com/kubernetes/client-go/blob/master/LICENSE)
## telegraf used and modified code from these projects

## Telegraf used and modified code from these projects

- github.com/DataDog/datadog-agent [Apache License 2.0](https://github.com/DataDog/datadog-agent/LICENSE)
17 changes: 15 additions & 2 deletions docs/developers/REVIEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ All pull requests should follow the style and best practices in the
document.

## Process

The review process is roughly structured as follows:

1. Submit a pull request.
Please check that you signed the [CLA](https://www.influxdata.com/legal/cla/) (and [Corporate CLA](https://www.influxdata.com/legal/ccla/) if you are contributing code on as an employee of your company). Provide a short description of your submission and reference issues that you potentially close. Make sure the CI tests are all green and there are no linter-issues.
1. Get feedback from a first reviewer and a `ready for final review` tag.
Expand All @@ -21,6 +23,7 @@ It might take some time until your PR gets merged, depending on the release cycl
your pull-request (bugfix, enhancement of existing code, new plugin, etc). Remember, it might be necessary to rebase your code before merge to resolve conflicts.

Please read the review comments carefully, fix the related part of the code and/or respond in case there is anything unclear. If there is no activity in a pull-request or the contributor does not respond, we apply the following scheme:

1. We send a first reminder after at least 2 weeks of inactivity.
1. After at least another two weeks of inactivity we send a second reminder and are setting the `waiting for response` tag.
1. Another two weeks later we will ask the community for help setting the `help wanted` reminder.
Expand All @@ -34,10 +37,13 @@ So in case you expect a longer period of inactivity or you want to abandon a pul
- SampleConfig must match the readme, but not include the plugin name.
- structs should include toml tags for fields that are expected to be editable from the config. eg `toml:"command"` (snake_case)
- plugins that want to log should declare the Telegraf logger, not use the log package. eg:

```Go
Log telegraf.Logger `toml:"-"`
```

(in tests, you can do `myPlugin.Log = testutil.Logger{}`)

- Initialization and config checking should be done on the `Init() error` function, not in the Connect, Gather, or Start functions.
- `Init() error` should not contain connections to external services. If anything fails in Init, Telegraf will consider it a configuration error and refuse to start.
- plugins should avoid synchronization code if they are not starting goroutines. Plugin functions are never called in parallel.
Expand Down Expand Up @@ -67,6 +73,9 @@ So in case you expect a longer period of inactivity or you want to abandon a pul
- changing the default value of a field can be okay, but will affect users who have not specified the field and should be approached cautiously.
- The general rule here is "don't surprise me": users should not be caught off-guard by unexpected or breaking changes.

## Linting

Each pull request will have the appriopriate linters checking the files for any common mistakes. The github action Super Linter is used: [super-pinter](https://github.com/github/super-linter). If it is failing you can click on the action and read the logs to figure out the issue. You can also run the github action locally by following these instructions: [run-linter-locally.md](https://github.com/github/super-linter/blob/main/docs/run-linter-locally.md). You can find more information on each of the linters in the super linter readme.

## Testing

Expand All @@ -82,6 +91,7 @@ used for assertions within the tests when possible, with preference towards
github.com/stretchr/testify/require.

Primarily use the require package to avoid cascading errors:

```go
assert.Equal(t, lhs, rhs) # avoid
require.Equal(t, lhs, rhs) # good
Expand All @@ -96,6 +106,7 @@ Ensure the [[SampleConfig]] and
match with the current standards.

READMEs should:

- be spaces, not tabs
- be indented consistently, matching other READMEs
- have two `#` for comments
Expand All @@ -121,15 +132,17 @@ Metrics use `snake_case` naming style.

Generally enumeration data should be encoded as a tag. In some cases it may
be desirable to also include the data as an integer field:
```

```shell
net_response,result=success result_code=0i
```

### Histograms

Use tags for each range with the `le` tag, and `+Inf` for the values out of
range. This format is inspired by the Prometheus project:
```

```shell
cpu,le=0.0 usage_idle_bucket=0i 1486998330000000000
cpu,le=50.0 usage_idle_bucket=2i 1486998330000000000
cpu,le=100.0 usage_idle_bucket=2i 1486998330000000000
Expand Down
Loading

0 comments on commit 72939ac

Please sign in to comment.