harukasan / fluent-plugin-rss

Fluent plugin to fetch RSS feed
MIT License
8 stars 3 forks source link

Noob configuration guidance please #1

Open DazWilkin opened 8 years ago

DazWilkin commented 8 years ago

I found your plugin but am struggling (I think) to configure it correctly.

Installed (successfully?)

fluent-gem install fluentd-plugin-rss
Fetching: fluent-plugin-rss-0.0.1.gem (100%)
Successfully installed fluent-plugin-rss-0.0.1
Parsing documentation for fluent-plugin-rss-0.0.1
Installing ri documentation for fluent-plugin-rss-0.0.1
Done installing documentation for fluent-plugin-rss after 0 seconds
1 gem installed
fluent-gem list
*** LOCAL GEMS ***
...
fluent-plugin-rss (0.0.1)
...

Configured (unclear)

Currently have both rss.conf and fluent-plugin-rss.conf

The 'type' property was not referenced but I think it should be 'rss'? Looking at your source (not a Ruby developer), it appears the 'tag' is to identify the emitted data so could be anything. I've tried various permutations of this:

<source>
  type rss
  tag cnn
  url http://rss.cnn.com/rss/cnn_latest.rss
  attrs date, title
</source>

Reviewing your code, it appears the RSS feed must contain a 'date' element. And I suspected this was the problem with the 1st feed that I tried which contained no 'date'. I extracted the RSS parsing and enumeration from your plugin (below). I've tried 2 other feeds that both use 'pubDate' (http://lorem-rss.herokuapp.com/feed; http://rss.cnn.com/rss/cnn_latest.rss) and these both work; they're 'put' and I assume would be emitted too.

#!/usr/bin/env ruby
require 'rss'

@tag = 'test'
@current_time = Time.new(2016,6,15,0,0,0, "+09:00").utc
@url = 'http://rss.cnn.com/rss/cnn_latest.rss'

next_current_time = @current_time

rss = RSS::Parser.parse(@url)

rss.items.each do |item|
    time = Time.parse item.date.to_s
    if time > @current_time
        puts "#{@tag} --- #{Time.parse(item.date.to_s)} --- #{item.title}"
        next_current_time = time if time > next_current_time
    end
end

I see no evident output :-(

So I'm doing something wrong. Any help would be appreciated.

harukasan commented 8 years ago

Thank you for your reporting!

When the date attribute does not exist, this plugins seems to fail to set the time attribute of the record. I have plan to fix it and some known problems in this month.

DazWilkin commented 8 years ago

Thank you for your reply!

Does my config file look accurate?

<source>
  type rss
  tag cnn
  url http://rss.cnn.com/rss/cnn_latest.rss
  attrs date, title
</source>

Should it be named "rss.conf" or "fluent-plugin-rss.conf" or does it not matter?

azimut commented 7 years ago

@harukasan any chance to get a beta release of the changes? I am trying to fix a couple of issues but want to know if there is anything else there.