python-librato icon indicating copy to clipboard operation
python-librato copied to clipboard

Aggregator and Auto-Submit?

Open seichner opened this issue 10 years ago • 10 comments

Hello! If i read the code (Aggregator, Queue) correctly, i cannot have Aggregators submit their data automatically, right?

So either i use an auto-submitting queue OR i use an aggregator?

The Ruby-Lib seems to handle this differently, Aggregator supports an autosubmit_interval-option.

seichner avatar Aug 27 '15 10:08 seichner

Hi @seichner,

They do: (https://github.com/librato/python-librato/blob/master/librato/queue.py#L47).

Doc: https://github.com/librato/python-librato#client-side-aggregation and https://github.com/librato/python-librato#sending-measurements-in-batch-mode.

Let me know if that is not what you were looking for.

drio avatar Aug 28 '15 13:08 drio

@drio if i understand the python code correctly, the only way to use the aggregator and the queue together is by calling queue.add_aggregator() with an aggregator as an argument.

within add_aggregator the events are added to the queue and the autosubmit option will submit them when the limit is reached. this assumes, that the aggregators need to be added to a queue on a regular basis, right?

please have a look at our thumbor addon, that is going to provide librato-metrics support. within that code, how would you implement the auto-submission?

phoet avatar Aug 28 '15 14:08 phoet

@phoet Yes, you are right. We'll have to make some tweaks to accommodate what you are trying to do. I'll take a look to the addon and get back to you with solutions.

drio avatar Aug 28 '15 16:08 drio

awesome, thx!

phoet avatar Aug 28 '15 17:08 phoet

please have a look at our thumbor addon, that is going to provide librato-metrics support. within that code, how would you implement the auto-submission?

Here is what we can do. You want to have a timer within your system that periodically wakes up and:

  • creates an aggregator
  • adds all the measurements available in your metrics/queue to the aggregator
  • submits the aggregation
  • flushes your metrics/queue
  • sleeps

Something similar to what we are doing in this ruby example.

drio avatar Sep 08 '15 21:09 drio

I think what we want is this https://github.com/librato/librato-metrics/blob/master/lib/librato/metrics/aggregator.rb#L32

phoet avatar Sep 09 '15 06:09 phoet

I am working on porting that over. Stay tuned.

drio avatar Sep 09 '15 13:09 drio

Cool, Thanks a lot @drio !

seichner avatar Sep 09 '15 15:09 seichner

@chancefeick @phoet @seichner

We have to put this on hold until we finish the process of consolidating features across the librato bindings.

I was looking at the option in the ruby bindings that you suggested and I don't think that is what you need. The flushing happens only when the # of seconds have passed and a new measurement is .added to the aggregator. You want to automatically flush the aggregator periodically.

In the meantime we work on all this, here is an example (in ruby) that you can use as a reference to implement what you need at user level.

drio avatar Sep 10 '15 18:09 drio

@drio Thanks for your investigation - just to clarify our use case: checking the interval on every .add, like the Ruby version does, is completely fine for us. We are running Thumbor with quite a huge amount of requests.

I think this will always be the case for people using the Aggregator, as it's purpose is to reduce the number of requests to Librato. It usually will not be used on a low-traffic site where the .add dependency would be a problem.

seichner avatar Sep 11 '15 10:09 seichner