fluent / fluent-plugin-mongo

MongoDB input and output plugin for Fluentd
https://docs.fluentd.org/output/mongo
173 stars 61 forks source link

Can't get log data #75

Closed anhldbk closed 8 years ago

anhldbk commented 8 years ago

Hey guys, would you please let me know what wrong with the following configuration? Thank you in advance.

Use case

I want to use fluentd to output log data into mongodb

Configuration

<source>
  @type forward
  port 24224
  bind 0.0.0.0
</source>

<match log.*>
  @type stdout
</match>

# Single MongoDB
<match log.**>
  @type mongo
  database logger
  collection label

  # Set 'tag_mapped' if you want to use tag mapped mode.
  tag_mapped

  # for capped collection
  capped
  capped_size 256m

  # key name of timestamp
  time_key timestamp

  # flush
  flush_interval 10s
</match>

Test

I used a script provided by fluent-logger-node:

'use strict'
var log4js = require('log4js');
log4js.addAppender(require('fluent-logger').support.log4jsAppender('log', {
   host: 'localhost',
   port: 24224,
   timeout: 3.0,
   levelTag: true
}));

var logger = log4js.getLogger('foo');

function emit(){
    logger.info('this log record is sent to fluent daemon');
}

setInterval(emit, 1000)

Expected result

Having log records in collection label of database logger

Actual result

> use logger
switched to db logger
> db.label.find()
repeatedly commented 8 years ago

See this article: http://docs.fluentd.org/articles/config-file#match-order

anhldbk commented 8 years ago

@repeatedly Thank you Masahiro! I've got it.