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

Feature request - expose environmental variables to configuration file #19

Closed
mhollick opened this issue Oct 2, 2014 · 8 comments
Closed

Comments

@mhollick
Copy link
Contributor

mhollick commented Oct 2, 2014

Hi,
we use carbon c relay on both graphite/carbon servers and on clients.
One of the things we want to do on clients is to aggregate cpu metrics as provided by collectd every 10 seconds.
To do this I understand that we shall need a configuration something like:

aggregate
  *.system.cpu-[0-9]+.cpu-idle
  every 10 seconds
    expire after 5 seconds
    compute average write to
      maxwell.vbox.cpu-all.average

for each of the processor states idle, interrupt, nice, softirq, steal, system, user, wait assuming that as this is a client server it will see metrics only from its self.

It would be really useful, from a configuration management point of view, if the configuration could be written as:

aggregate
  *.system.cpu-[0-9]+.cpu-idle
  every 10 seconds
    expire after 5 seconds
    compute average write to
      $HOSTNAME.cpu-all.average

I saw the previous feature request for back references and that would be the best of all. However, I understand that the amount of effort to do so would be great.

Another thing. It has been some time since I have done any C but I have looked at your code and I hope to be able to contribute a small patch to vary the time between statistic emission. Our carbon stack emits statistics every 10 seconds, it would be nice for carbon c relay to do likewise.

@mhollick
Copy link
Contributor Author

mhollick commented Oct 2, 2014

Just noticed your commit for capture groups (not production ready). The memory consideration will probably not be an issue on the clients in our environment - the flow of metrics will be a constant.

I shall give it a go and report back.

The variables thing would still be nice though.

@grobian
Copy link
Owner

grobian commented Oct 2, 2014

re: patches, beware that I'm very picky about code ;) For the statistics interval change it's a matter of passing on a (command line flag fed) value down to the main loop. It does second sleeps, so, it should be a matter of replacing the hardcoded 60 with the value passed on. Not a big change, feel free to open a separate feature request for it.

@grobian
Copy link
Owner

grobian commented Oct 2, 2014

Is it really necessary to read all environment environment variables? Hostname is already known to the relay (and can be overridden using -H) so that would be slightly easier to use.

@mhollick
Copy link
Contributor Author

mhollick commented Oct 2, 2014

no, I don't think that all environment variables are needed.How do I use
the variable Hostname set through -H?

I was trying to avoid a situation like:

Server maxwell

aggregate
    *.system.cpu-[0-9]+.cpu-idle
  every 10 seconds
  expire after 5 seconds
  compute average write to
    maxwell.vbox.cpu-all.average

Server edison

aggregate
    *.system.cpu-[0-9]+.cpu-idle
  every 10 seconds
  expire after 5 seconds
  compute average write to
    edison.vbox.cpu-all.average

Server beyonce

aggregate
    *.system.cpu-[0-9]+.cpu-idle
  every 10 seconds
  expire after 5 seconds
  compute average write to
    beyonce.vbox.cpu-all.average

and so on.

With the back references I don't need that and I can just do:

aggregate
     (.*).system.cpu.[0-9]+.cpu.([a-z]+)
   every 10 seconds
   expire after 5 seconds
   compute average write to
     \1.system.cpu.avg.\2
   ;

But I am wary that as you said, this is not well tested yet.I will
provide feedback after it has gone through our load test environment.

I also have the unhappy situation where I get a stream of metrics on
each client like:

127.0.0.1.memcached.metrics_cache.df.cache.used

Which is annoying as I want:

maxwell.vbox.memcached.metrics_cache.df.cache.used

Having the hostname (fqdn) available would save a considerable amount of
Puppet cleverness.

Regards and thanks, Carbon C Relay has made my day job easier.

@deniszh
Copy link

deniszh commented Oct 2, 2014

Sorry, gentlemen, for interrupting your conversation, but BTW - you can use built-in collectd aggregator plugin for aggregating CPU stats. Something like

LoadPlugin aggregation

<Plugin "aggregation">
  <Aggregation>
    Plugin "cpu"
    Type "cpu"

    GroupBy "Host"
    GroupBy "TypeInstance"

    CalculateSum true
    CalculateAverage true
  </Aggregation>
</Plugin>

works like a charm...
Just my 5 cents.

@mhollick
Copy link
Contributor Author

mhollick commented Oct 2, 2014

deniszh
5c well spent.
I did not notice the collectd aggregation plugin.
Ta.

@grobian
Copy link
Owner

grobian commented Oct 3, 2014

Would it be worth to implement something like \H in the replacement code, or can we sufficiently get away with group matches and different input here?

@grobian
Copy link
Owner

grobian commented Oct 23, 2014

assuming all is fine here, please reopen if I overlooked something

@grobian grobian closed this as completed Oct 23, 2014
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