The error message is fairly clear here, I think:
"Plugin 'MemStatFilter' error: attempted to Inject a message to itself"
The issue is that the message that you're trying to inject will be matched by
the message_matcher of the filter doing the injecting. This is explicitly not
allowed because it likely leads to an infinite loop. Try constructing the
message you generate in such a way that it will not match the filter that is
doing the injecting and you'll have better luck.
Other notes on your implementation:
- You almost certainly don't want to use the separate `timer_event` version.
You might get thousands of messages between each ticker interval, so in that
version the count will be right but you'll only get the payload and other data
of the last message that came through before each tick.
- You'll get much less GC churn if you define the `local msg = {...}` table
outside of the process_message function, and only overwrite the individual
values you want to change each time, rather than creating a new table.
- This whole thing smells a bit weird to me, I suspect it's not the best
approach. What is the problem you're trying to solve?
-r
On 04/30/2015 01:38 PM, Adriano Santos wrote:
I also tried this code before and I got the same error:
--[[
--]]
require "math"
require "string"
require "table"
counter_msg = 0;
payload = nil
fields = nil
function process_message ()
local msg = {
Timestamp = nil,
Type = "counter.stats",
Payload = read_message("Payload"),
Fields = read_message("Fields")
}
counter_msg = counter_msg + 1
msg.Fields["Count_MemFree"] = counter_msg
inject_msg(msg)
return 0
end
On Thu, Apr 30, 2015 at 3:18 PM, Adriano Santos
<[email protected] <mailto:[email protected]>> wrote:
Hi Guys,
I wrote a lua sandbox filter plugin to count a field in the
message matcher. I'm trying also to include the content of the
message into the new message that is being injected.
--[[
--]]
require "math"
require "string"
require "table"
counter_msg = 0;
payload = nil
fields = nil
local floor = math.floor
function process_message ()
counter_msg = counter_msg + 1
payload = read_message("Payload")
fields = read_message("Fields")
return 0
end
function timer_event(ns)
local msg = {
Timestamp = nil,
Type = "counter.stats",
Payload = nil,
Fields = nil
}
msg.Payload = payload
msg.Fields = fields
msg.Fields["Count_MemFree"] = counter_msg
inject_msg(msg)
end
When the timer event is triggered I got the following error:
2015/04/30 13:01:45 Plugin 'MemStatFilter' error: attempted to
Inject a message to itself
2015/04/30 13:01:45 Plugin 'MemStatFilter': stopped
2015/04/30 13:01:45 Plugin 'MemStatFilter': has stopped, exiting
plugin without shutting down.
2015/04/30 13:01:45
:Timestamp: 2015-04-30 20:01:45.283326565 +0000 UTC
:Type: heka.terminated
:Hostname: slc01hza
:Pid: 26170
:Uuid: cc72c845-93b5-428f-a186-a2f186981efb
:Logger: hekad
:Payload: MemStatFilter (type SandboxFilter) terminated. Error:
Filter unloaded.
:EnvVersion:
:Severity: 7
:Fields:
| name:"plugin" type:string value:"MemStatFilter"
2015/04/30 13:01:45 Plugin 'MemStatFilter' error: Lost/Droppe
I know that modify the message inside a filter is not allowed. I
thought create a new message using inject_message or inject_payload
was available. I tried both.
Am I doing something wrong?
Best,
Adriano
_______________________________________________
Heka mailing list
[email protected]
https://mail.mozilla.org/listinfo/heka
_______________________________________________
Heka mailing list
[email protected]
https://mail.mozilla.org/listinfo/heka