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]>
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

Reply via email to