Writing stats to the log

20 views
Skip to first unread message

John Bachir

unread,
Jun 13, 2015, 3:38:30 AM6/13/15
to sid...@googlegroups.com
I'd like to write sidekiq stats (https://github.com/mperham/sidekiq/wiki/Monitoring#monitoring-queue-backlog) to my application's log at a given interval, so that I can monitor it with librato (https://librato.com/). My first possibly misguided idea for doing this is to stick this in an initializer:

Thread.new do
  while true
    STDERR.puts "sidekiq queue size: Sidekiq::Queue.new.size"
    sleep 60
  end
end

Anyone have a better idea?

Thanks,
John

John Bachir

unread,
Jun 13, 2015, 3:40:02 AM6/13/15
to sid...@googlegroups.com
(and of course I meant STDERR.puts "sidekiq queue size: #{Sidekiq::Queue.new.size"})

Mike Perham

unread,
Jun 13, 2015, 11:00:12 AM6/13/15
to sid...@googlegroups.com
That's the basic idea and easiest thing to do.

--
You received this message because you are subscribed to the Google Groups "Sidekiq" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sidekiq+u...@googlegroups.com.
To post to this group, send email to sid...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sidekiq/562d96d3-51c3-4c78-8663-67c99c29fd63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mike Perham – CEO, Contributed Systems
Smart, effective open source infrastructure for your apps.

Thibaut Barrère

unread,
Jun 16, 2015, 4:04:16 AM6/16/15
to sid...@googlegroups.com
Hello,

here is a different idea (although not necessarily better!): we are using a rack endpoint which is monitored by pingdom (every minute).

The call is protected, outputs some text with the stats for us to quick-check, but can also push to statsd then to librato.

Hope this helps,

-- Thibaut

John Bachir

unread,
Jun 19, 2015, 9:12:13 PM6/19/15
to sid...@googlegroups.com


On Tuesday, June 16, 2015 at 4:04:16 AM UTC-4, Thibaut Barrère wrote:
here is a different idea (although not necessarily better!): we are using a rack endpoint which is monitored by pingdom (every minute).

The call is protected, outputs some text with the stats for us to quick-check, but can also push to statsd then to librato.



It's nice to have the option, but it doesn't fit in with how I do other monitoring so I don't really like it. I think a solution using logs/push is more appropriate than one using pull.

John Bachir

unread,
Jul 3, 2015, 10:06:58 PM7/3/15
to sid...@googlegroups.com
I remembered that that I already have a script which runs once per hour and reports various stats to another service. So I stuck this code at the bottom:

librato_queue = Librato::Metrics::Queue.new
%w[auth_mailer mailer default low].each do |queue|
  librato_queue.add "sidekiq.queue_size" => {value: Sidekiq::Queue.new(queue).size, source: queue}
end
librato_queue.submit

Reply all
Reply to author
Forward
0 new messages