If else for HOST

View thread

aaronsssya

Hi, Deu to we have multiple collector of GrayLog in multiple locations. I was thinking could I use if else to send log? for example:

<Output out_wineventlog>
  Module      om_udp
  EXEC   if      $location =~ /^(us)/\
                 {\
                   $collector = 'collector.test.us';\
                 }\
         else\
                 {\
                   $collector = 'collector.test.eu';\
                 }
  Host        $collector
  Port        15001
  OutputType  GELF
</Output>

I have tried many statement, but all failure. E.g. string($collector), "$collector", {$collector}, (EXEC $collector;)..etc.

I always got the following error. ERROR apr_sockaddr_info failed for [$GLogCollector]:15001; No such host is known.

If I config the 'collector.test.us' for Host of output, I can see the $collector is working.