Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Collection offset implementation #10545

Merged
merged 10 commits into from
Feb 15, 2022
Merged

Conversation

srebhan
Copy link
Member

@srebhan srebhan commented Jan 28, 2022

resolves #1319
resolves #10406

related to #10530

This PR addresses a long standing feature-request to be able to define an offset from the collection interval. This can be helpful in order to manually schedule data collection between agents, if the global option is used with multiple agents, or, if the plugin option is used, between plugins. The new collection_offset allows to define a time offset from the (rounded and unaligned) collection time. The option is valid in either the agent section or in any input-plugin section (as other interval parameters).

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Jan 28, 2022
agent/tick.go Outdated Show resolved Hide resolved
@sjwang90
Copy link
Contributor

sjwang90 commented Feb 3, 2022

Tested the artifacts and everything works as expect. Awesome work @srebhan 😄

@poulhs
Copy link

poulhs commented Feb 9, 2022

I have tested a few different scenarios and it works exactly as expected. Very nice and very useful.

My only comment is about the comment... I think that "manually scheduling" may be a bit obfuscating - it does not require anyone to hit return to continue... ;-)

@sjwang90 sjwang90 added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Feb 10, 2022
@reimda
Copy link
Contributor

reimda commented Feb 10, 2022

Hi Sven, it seems like 1319 and 10406 are requesting exact timing based on the system clock, kind of like cron can trigger on x minute of the hour. In those issues the use case is to have telegraf instances on multiple machines have synchronized intervals. (for example machine 1 gathers on the first minute of every hour and machine 2 gathers on the 30th minute of every hour)

10530 and this PR add an offset to telegraf's current interval. This doesn't seem to be the same thing as synchronizing the interval to the clock. Am I missing something? Maybe you intend people to use external tools like cron or at to start telegraf at an exact time?

@poulhs
Copy link

poulhs commented Feb 11, 2022

I think you missed something, @reimda - To get exact timing you must control more configurations.
Assume you want to telegraf to perform a check every 10 seconds, at :05, :15, :25, ... you do:

  • interval = "10s" # every 10 seconds
  • collection_jitter = "0s" # "unrandom" - doing exact timing:
  • round_interval = true # relative to systemclock - not starttime:
  • collection_offset = "5s" ` # and changing from :00, :10, :20, etc, to 05, :15, :25, etc:

That will do the trick - having the servers with different collection_offsets makes it possible to control this (one server as above, another with `collection_offset = "0s"``)

On a single telegraf, this can be used to ensure that multiple checks are started at different times "don't step on my toes" - just apply same interval and different collection_offsets

And I guess there exist several other use-cases.... (time will show ☺)

@reimda
Copy link
Contributor

reimda commented Feb 11, 2022

Thanks @poulhs for the clarification. I misunderstood how round_interval works. This looks very useful to me now!

@powersj powersj merged commit 5479df2 into influxdata:master Feb 15, 2022
phemmer added a commit to phemmer/telegraf that referenced this pull request Feb 18, 2022
* origin/master: (211 commits)
  feat: update configs (influxdata#10676)
  feat[elastic output]: add elastic pipeline flags (influxdata#10505)
  Update changelog
  fix: ensure folders do not get loaded more than once (influxdata#10551)
  docs: update VMWare doc links (influxdata#10663)
  fix: prometheusremotewrite wrong timestamp unit (influxdata#10547)
  feat: update configs (influxdata#10662)
  fix: add graylog toml tags (influxdata#10660)
  feat: add socks5 proxy support for kafka output plugin (influxdata#8192)
  docs: override reported OpenSearch version (influxdata#10586)
  feat: update etc/telegraf.conf and etc/telegraf_windows.conf (influxdata#10659)
  fix: bump all go.opentelemetry.io dependencies (influxdata#10647)
  feat: collection offset implementation (influxdata#10545)
  chore: update go to 1.17.7 (influxdata#10658)
  fix: check for nil client before closing in amqp (influxdata#10635)
  fix: timestamp change during execution of json_v2 parser. (influxdata#10657)
  fix: bump github.com/signalfx/golib/v3 from 3.3.38 to 3.3.43 (influxdata#10652)
  fix: bump github.com/aliyun/alibaba-cloud-sdk-go (influxdata#10653)
  fix: incorrect handling of json_v2 timestamp_path (influxdata#10618)
  feat: gather additional stats from memcached (influxdata#10641)
  feat: update etc/telegraf.conf and etc/telegraf_windows.conf (influxdata#10649)
  fix: Revert deprecation of http_listener_v2 (influxdata#10648)
  fix: bump github.com/denisenkom/go-mssqldb from 0.10.0 to 0.12.0 (influxdata#10503)
  fix: bump github.com/gopcua/opcua from 0.2.3 to 0.3.1 (influxdata#10626)
  fix: use current time as ecs timestamp (influxdata#10636)
  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)
  ...
@kaunix
Copy link

kaunix commented Mar 28, 2023

so are these changes available in 1.26?

@powersj
Copy link
Contributor

powersj commented Mar 28, 2023

so are these changes available in 1.26?

Yes

@kaunix
Copy link

kaunix commented Mar 28, 2023

so I tried to use them in the conf file (see below) and telegraf wouldn't start:

[[inputs.exec]]
commands=["/usr/bin/iperf3 -O 7 -c 192.168.1.1 --json"]
#interval = "1783s"
interval = "1800s"
collection_jitter= "0s"
round_interval = true
collection_offset = "54s"
timeout = "40s"
data_format = "json"
json_query = "end"
name_override = "server.example.com-write"

[[inputs.exec]]
commands=["/usr/bin/iperf3 -O 7 -c 192.168.1.1 -R --json"]
#interval = "1801s"
interval = "1800s"
collection_jitter= "0s"
round_interval = true
collection_offset = "1"
timeout = "40s"
data_format = "json"
json_query = "end"
name_override = "server.example.com-read"

[[inputs.exec]]
commands=["/usr/bin/iperf3 -O 7 -c 192.168.1.2 --json"]
#interval = "1831s"
interval = "1800s"
collection_jitter= "0s"
round_interval = true
collection_offset = "15"
timeout = "40s"
data_format = "json"
json_query = "end"
name_override = "server2.example.com-write"

[[inputs.exec]]
commands=["/usr/bin/iperf3 -O 7 -c 192.168.1.2 -R --json"]
#interval = "1867s"
interval = "1800s"
collection_jitter= "0s"
round_interval = true
collection_offset = "35"
timeout = "40s"
data_format = "json"
json_query = "end"
name_override = "server2.example.com-read"

@powersj
Copy link
Contributor

powersj commented Mar 28, 2023

File a bug please, asking on a closed PR isn't the place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/agent feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
7 participants