how to control streams with tags

28 views
Skip to first unread message

Nickolaos Kas

unread,
May 13, 2022, 11:35:00 AM5/13/22
to Riemann Users

Hello everyone,
There is something driving me insane, and most probably its my lack of understanding of streams or clojure (or both). I have the following code in riemann.config
(where (tagged-all? "dmz" event)
   #(info "dmz" %)
   (else #(info "non-dmz" %)))
which seems to always opt for the 'else' clause independent of the presence of the "dmz" tag in the event. I am pasting a sample line which contains the string 'non-dmz', and the 'dmz' tag
INFO [2022-05-13 08:22:27,755] defaultEventExecutorGroup-2-4 - riemann.config - non-dmz #riemann.codec.Event{:host synapse01, :service load/load/longterm, :state ok, :description nil, :metric 0.05, :tags [collectd dmz], :time 1652455348, :ttl 120.0, :plugin load, :type load, :ds_name longterm, :ds_type gauge, :ds_index 2}

I also tried tagged-any? just in case but it made no difference. Can anyone explain why I do not get the "dmz" string when the dmz tag is present?

Thanks

Toby McLaughlin

unread,
May 13, 2022, 11:37:39 PM5/13/22
to Riemann Users
Hi!

This is a bit of a subtle type error with the input to tagged-*. Those function take a collection of tags.

Internally they call (set tags):


Look what happens when you call set on a single string:

user=> (set "dmz")
#{\d \m \z}


Compare that to calling it with a one-element vector of strings:

user=> (set ["dmz"])
#{"dmz"}

Much better! So, this will work:

(streams
 (where (tagged-any? ["dmz"] event) #(info "dmz" %)
        (else #(info "non-dmz" %))))

The documentation for tagged-all demonstrates passing a single string, but I don't see how that can work.

Cheers,
Jarpy.

Toby McLaughlin

unread,
May 14, 2022, 12:14:54 AM5/14/22
to Riemann Users
Raised https://github.com/riemann/riemann/pull/1014 to fix the docs. <3

Nickolaos Kas

unread,
May 16, 2022, 10:00:21 AM5/16/22
to Riemann Users
That definitely did the trick, thank you for the insight.
Reply all
Reply to author
Forward
0 new messages