How to test fluentd running inside the docker container

2,104 views
Skip to first unread message

Sam Khan

unread,
Dec 3, 2016, 2:16:49 AM12/3/16
to Fluentd Google Group
Hi, 
Newbie here!

I installed fluentd inside a container which in turn is running inside a vm on my mac. Here is a simple topology of the systems involved:
Mac > Ubuntu VM > Fluentd Container

Following is the run command I used:
$ docker run -d --name fluentd -p 24224:24224 -v ~/home/sam/fluentdlog fluent/fluentd fluentd

when I tried connecting to fluentd from the node.js app running on my mac (I am using the sample node.js code provided in the docs) I got this error:

Fluentd error { [Error: connect ECONNREFUSED 192.168.56.20:24224]

  code: 'ECONNREFUSED',

  errno: 'ECONNREFUSED',

  syscall: 'connect',

  address: '192.168.56.20',

  port: 24224 }

Fluentd will reconnect after 600 seconds



//Following is the sample code I used

var logger = require('fluent-logger')

// The 2nd argument can be omitted. Here is a default value for options.

logger.configure('tag_prefix', {

   host: '192.168.56.20',

   port: 24224,

   timeout: 3.0,

   reconnectInterval: 600000 // 10 minutes

});


// send an event record with 'tag.label'

logger.emit('label', {record: 'this is a log'});



Note: In the same VM I had already installed redis and mongodb containers which I am able to connect to successfully from a separate node.js app which is also running on my mac.


Could this be the VM binding issue (if so then why redis and mongodb connections are working fine). Can anyone please help in identifying what's missing here.


Another quick question: is there any way I can test the connection to Fluentd using any cli tool instead of using the code?


Thanks much!


Regards,

-Sam


Mr. Fiber

unread,
Dec 5, 2016, 2:22:17 AM12/5/16
to Fluentd Google Group
Another quick question: is there any way I can test the connection to Fluentd using any cli tool instead of using the code?

You can use fluent-cat command to send one event to fluentd in_forward.

echo '{"k1":"v1","k2":"v2",...}' | fluent-cat tag.value


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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sam Khan

unread,
Dec 5, 2016, 5:39:20 AM12/5/16
to Fluentd Google Group
Thanks Masahiro,

I managed to get fluentd working inside a docker container, after building my own image:

-----------------------------Start Dockerfile----------------------------------------
FROM fluent/fluentd:latest-onbuild
MAINTAINER Sam Khan <em...@email.com>
WORKDIR /home/fluent
ENV PATH /home/fluent/.gem/ruby/2.3.0/bin:$PATH

USER root
RUN apk --no-cache --update add sudo build-base ruby-dev && \

    sudo -u fluent gem install fluent-plugin-secure-forward && \

    rm -rf /home/fluent/.gem/ruby/2.3.0/cache/*.gem && sudo -u fluent gem sources -c && \
    apk del sudo build-base ruby-dev && rm -rf /var/cache/apk/*

EXPOSE 24224

USER fluent
CMD exec fluentd -c /fluentd/etc/$FLUENTD_CONF -p /fluentd/plugins $FLUENTD_OPT
-----------------------------End Dockerfile----------------------------------------

This is my fluent.conf
------------------------------------------------------------------
<source>
  @type forward
  port 24224
</source>
<match fluentd.test.**>
  @type stdout
</match>
------------------------------------------------------------------

I followed the instructions described under the section "How to build your own image" on fluentd's page on docker hub (https://hub.docker.com/r/fluent/fluentd/)

Following is the output I get after I run my node program, actually its the output of this line:
logger.emit('Debug',
  {
    message: 'this is a log',
    notif: false,
    caller: 'logger.js'
  });





Regards, -Sam



To unsubscribe from this group and stop receiving emails from it, send an email to fluentd+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages