On 04/10/2015 12:45 PM, Erki Esken wrote:
Hi,

Is there any way to do DropStat into an StatAccumInput from a custom
Lua-based filter? Something like what StatFilter does internally, and
what StatsdInput does too.
No, unfortunately, there's no way to drop stats into the accumulator from 
within a sandbox plugin right now.
I have a decoder that takes apart logfmt ([1]) formatted loglines
already. And now I would like to have a custom filter that reads message
fields and finds Heroku-suggested "measure#something=x" and
"sample#something=y" style (see [2]) fields and injects them into
StatAccumInput.
I'm guessing that your requirement is less "injects them into a StatAccumInput" and more 
"periodically generates aggregated stat info in graphite text format", since that's what 
the StatAccumInput accomplishes.
Or should my filter just inject new messages for any found
"measure#/sample#" fields one by one and have a generic StatFilter rule
pick them up? Though this sounds like a bit too much overhead.
This would work, but you're right in that it wouldn't likely perform very well.

What I would do is just have the same filter that's extracting the "measure#something=x" 
and "sample#something=y" fields actually do the aggregation, periodically emitting the 
graphite formatted output directly. I recently wrote some sample filter code that does something 
similar, extracting HTTP request data and generating graphite formatted output: 
https://gist.github.com/rafrombrc/3858a7885e766fbefa61

I've also opened an issue, which is actively being worked on, to tease out the 
math code that converts a set of timer and/or counter values into the various 
graphite stats into a reusable Lua module. This would greatly reduce the amount 
of code in the filter.

If you're feeling brave you can copy the code from my example and use that as a 
starting point for doing something similar in your own filter, or you can hold 
off for a few days until the lua module has been extracted and then use that to 
accomplish the same result.

Hope this helps,

-r


[1] https://github.com/kr/logfmt
[2]
https://devcenter.heroku.com/articles/add-on-provider-log-integration#format

--
Erki


_______________________________________________
Heka mailing list
[email protected]
https://mail.mozilla.org/listinfo/heka


_______________________________________________
Heka mailing list
[email protected]
https://mail.mozilla.org/listinfo/heka

Reply via email to