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

access global config in plugins #478

Closed
yuankui opened this issue Jan 4, 2016 · 12 comments
Closed

access global config in plugins #478

yuankui opened this issue Jan 4, 2016 · 12 comments

Comments

@yuankui
Copy link

yuankui commented Jan 4, 2016

Is any way to access global config like interval in plugins?

@sparrc
Copy link
Contributor

sparrc commented Jan 5, 2016

@sparrc sparrc closed this as completed Jan 5, 2016
@zstyblik
Copy link
Contributor

zstyblik commented Jan 5, 2016

The way I understood the question is whether it's possible to access:

[agent]
  interval = 10s

from the plugin and not whether it's possible to configure different interval per plugin.

@sparrc
Copy link
Contributor

sparrc commented Jan 5, 2016

@zstyblik please read the link above, it describes how to set the interval per-plugin

@zstyblik
Copy link
Contributor

zstyblik commented Jan 5, 2016

@sparrc - I understand your reply. I know you can set interval per plugin. And I'm telling you that's not how I understood the question. But I'm not the one whom asked and perhaps it's me who misunderstood the question. Still, if you have time, please, read again what I've written, resp. compare the last sentence and your reply. :)

@sparrc
Copy link
Contributor

sparrc commented Jan 5, 2016

I don't see any reason plugins need access to the global interval parameter. Asking for a feature without giving the use-case usually leads to confusion ;-)

@zstyblik
Copy link
Contributor

zstyblik commented Jan 5, 2016

Sure. Use-case that comes to my mind could be choosing retention policy, resp. embedding interval into metric name in order to choose retention policy later up in the chain. And what not. I don't know. Anyway ...

@sparrc
Copy link
Contributor

sparrc commented Jan 5, 2016

Why not just add a tag then? This would be a pretty minor duplication...

[agent]
  interval = "10s"

[tags]
  interval = "10s"

@zstyblik
Copy link
Contributor

zstyblik commented Jan 6, 2016

@sparrc sure, that could work, although it's hard to say what @yuankui 's use case is. Such thing wouldn't work for me. I would need per plugin tag rather than a global one :)

@sparrc
Copy link
Contributor

sparrc commented Jan 6, 2016

@zstyblik per-plugin tags are coming in 0.3.0, see #437 and https://github.com/influxdata/telegraf#version-030-beta

@yuankui
Copy link
Author

yuankui commented Jan 6, 2016

thank @zstyblik for reply.
here is my use case.

I want to monitor the network flow rate(Bytes per second) of every network interface.

but the provided network provide only the accumulated network bytes.

It's suggested to use derivative in SQL, bug I failed to get it to work. (maybe there is some issue in the function)

So I decided to calculate my self.

so I need to get the current bytes and the last updated bytes, and calculate the data rate with

(now - last) / interval?

So I need to get the global interval setting.

Is the request reasonable?

Or is there any other elegant way?

@sparrc
Copy link
Contributor

sparrc commented Jan 6, 2016

I wouldn't rely on interval for that, you should store the timestamp of the last gather.

@zstyblik
Copy link
Contributor

zstyblik commented Jan 7, 2016

@sparrc great!

@yuankui have you reported the bug with InfluxDB? As far as I can tell, the query works for me. Whether reported values are correct, that's another story(I haven't invested time into this). But I'd try to solve it outside of Telegraf.

SELECT DERIVATIVE(value, 10s) FROM testdb2."1s".wave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants