Routing a tag to multi destinations

158 views
Skip to first unread message

Rizal Muhammad Nur

unread,
Feb 12, 2015, 10:44:15 PM2/12/15
to flu...@googlegroups.com
Hi,

I am going to route source with tag a.b.c.d.e to some output file destinations. Messages will be route following rules below

- Tag and sub-tag 'a' will be store to out1
- Tag and sub-tag 'a.b' will be store to out2
- Only tag 'a.b' will be store to out2
- Only tag 'a.b.c' will be store to out3
- Tag and sub-tag 'a.b.c.d' will be store to out4

So i tried to create match filters 
==================
<match a.**>
  type file
  append true
  path /tmp/f/test/out1.log
</match>

<match a.b.**>
  type file
  append true
  path /tmp/f/test/out2.log
</match>

<match a.b>
  type file
  append true
  path /tmp/f/test/out3.log
</match>

<match a.b.c>
  type file
  append true
  path /tmp/f/test/out4.log
</match>

<match a.b.c.d.**>
  type file
  append true
  path /tmp/f/test/out5.log
</match>
==================

Unfortunately, it didn't work as expected. Message just store on file /tmp/f/test/out1.log
I read about out_copy type, but I don't know how to impement for my case.  
Is any idea how to solve it?

--Rizal

Mr. Fiber

unread,
Feb 13, 2015, 12:58:18 AM2/13/15
to flu...@googlegroups.com
Hi,

I don't understand your rule correctly.
What the expected behaviour for a.b.c.d.e?
a.b.c.d.e will be stored into out1, out2 and out5?


Masahiro

--
You received this message because you are subscribed to the Google Groups "Fluentd Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fluentd+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lance N.

unread,
Feb 13, 2015, 5:28:50 PM2/13/15
to flu...@googlegroups.com
Rizal- the rules should be in order of most specific to least specific. 
a.b
a.b.c
a.b.c.d.**
a.b.**
a.**

Rizal Muhammad Nur

unread,
Feb 20, 2015, 2:35:04 AM2/20/15
to flu...@googlegroups.com
Sorry, I was mistyping about output file. It should be
- Tag and sub-tag 'a' will be store to out1
- Tag and sub-tag 'a.b' will be store to out2
- Only tag 'a.b' will be store to out3
- Only tag 'a.b.c' will be store to out4
- Tag and sub-tag 'a.b.c.d' will be store to out5

By following the rules, source with tag a.b.c.d.e will be store in file out1, out2, and out5.

Rizal Muhammad Nur

unread,
Feb 20, 2015, 2:44:50 AM2/20/15
to flu...@googlegroups.com
Do you suggest to make 5 match rules with those order? 
Those match order just store source with tag a.b.c.d.e to file out5.log where match filter a.b.c.d.**. Source will not store in out1 and out2

--Rizal

Mr. Fiber

unread,
Feb 20, 2015, 5:20:05 AM2/20/15
to flu...@googlegroups.com
Maybe, using fluent-plugin-route resolve this pattern.


Could you try following configuration?

<match a.b>
  type file
  append true
  path /path/to/out3.log
</match>

<match a.b.c>
  type file
  append true
  path /path/to/out4.log
</match>

<match a.**>
  type route

  <route a.**>
    add_tag_prefix out1
    copy
  </route>
  <route a.b.**>
    add_tag_prefix out2
    copy
  </route>
  <route a.b.c.d.**>
    add_tag_prefix out5
    copy
  </route>
</match>

<match out1.a.**>
  type file
  append true
  path /path/to/out1.log
</match>
<match out2.a.b.**>
  type file
  append true
  path /path/to/out2.log
</match>
<match out5.a.b.c.d.**>
  type file
  append true
  path /path/to/out5.log
</match>


--

Lance Norskog

unread,
Feb 20, 2015, 4:40:45 PM2/20/15
to flu...@googlegroups.com
The first match "owns" the record. When a message is matched, it does not keep going. 

--
You received this message because you are subscribed to a topic in the Google Groups "Fluentd Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fluentd/BPJfSUn6JmI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fluentd+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Lance Norskog
lance....@gmail.com
Redwood City, CA

Rizal Muhammad Nur

unread,
Feb 25, 2015, 2:14:40 AM2/25/15
to flu...@googlegroups.com
Great,

Thanks for suggesting this plugin
It works as expected. 
Just like your config, I modify so it looks like

<match a.**>
  type route
  <route a.**>
    add_tag_prefix out1
    copy
  </route>
  <route a.b.**>
    add_tag_prefix out2
    copy
  </route>
  <route a.b>
    add_tag_prefix out3
    copy
  </route>
  <route a.b.c>
    add_tag_prefix out4
    copy
  </route>
  <route a.b.c.d.**>
    add_tag_prefix out5
    copy
  </route>
</match>

<match out1.**>
  type file
  append true
  path /path/to/out1.log
  flush_interval 0s
</match>

<match out2.**>
  type file
  append true
  path /path/toout2.log
  flush_interval 0s
</match>

<match out3.**>
  type file
  append true
  path /path/to/out3.log
  flush_interval 0s
</match>

<match out4.**>
  type file
  append true
  path /path/to/out4.log
  flush_interval 0s
</match>

<match out5.**>
  type file
  append true
  path /path/to/out5.log
  flush_interval 0s
</match>


Pada Jumat, 20 Februari 2015 17.20.05 UTC+7, repeatedly menulis:
Maybe, using fluent-plugin-route resolve this pattern.


Could you try following configuration?

Reply all
Reply to author
Forward
0 new messages