Aggiunge monitoraggio ops: health check, log scanner, dashboard e notifiche.
Introduce incidenti con dedup, job Sidekiq ogni 3 min, scan log cron, /up/deep, dashboard /admin/ops e push ntfy; include Sentry opzionale e fix test suite. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
41
backend/lib/tasks/ops.rake
Normal file
41
backend/lib/tasks/ops.rake
Normal file
@@ -0,0 +1,41 @@
|
||||
namespace :ops do
|
||||
desc "Esegue health check ops e registra incidenti"
|
||||
task health_check: :environment do
|
||||
findings = Ops::HealthChecks.new.call
|
||||
unhealthy = findings.reject(&:healthy)
|
||||
puts "Health check completato: #{findings.size} controlli, #{unhealthy.size} problemi"
|
||||
unhealthy.each do |f|
|
||||
puts " [#{f.severity}] #{f.title}: #{f.message}"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Ingestione log da stdin o file (rails ops:ingest_logs[path])"
|
||||
task :ingest_logs, [:path] => :environment do |_t, args|
|
||||
text = if args[:path].present?
|
||||
File.read(args[:path])
|
||||
else
|
||||
$stdin.read
|
||||
end
|
||||
count = Ops::LogScanner.new.ingest(text)
|
||||
puts "Log scanner: #{count} match trovati"
|
||||
end
|
||||
|
||||
desc "Invia notifica di test (ntfy/email)"
|
||||
task test_notify: :environment do
|
||||
incident = Ops::Incident.create!(
|
||||
kind: "test",
|
||||
severity: "critical",
|
||||
status: "open",
|
||||
title: "Test notifica ops",
|
||||
message: "Verifica canale notifiche Match Live TV — #{Time.current}",
|
||||
metadata: {},
|
||||
fingerprint: "test:#{SecureRandom.hex(4)}",
|
||||
occurrence_count: 1,
|
||||
first_seen_at: Time.current,
|
||||
last_seen_at: Time.current
|
||||
)
|
||||
Ops::Notifier.new.notify(incident)
|
||||
incident.resolve!
|
||||
puts "Notifica di test inviata"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user