BetterStack provides comprehensive monitoring, logging, and uptime tracking for your applications. This guide will show you how to integrate BetterStack with your Rivet Actor to monitor performance and collect logs.
The integration uses Vector as a log collector and metrics shipper. Logs from your actor are piped to Vector, then forwarded to BetterStack. Vector also automatically collects system metrics to upload to BetterStack.
Here's an example SQL query to chart CPU usage by lobby ID:
-- CPU Usage by Lobby ID SELECT {{time}} AS time, metricTag('lobby_id') AS series, -- Calculate rate of CPU seconds consumption per second avgMerge(rate_avg) AS "CPU Usage (cores)" FROM {{source}} WHERE name = 'cpu_seconds_total' AND time BETWEEN {{start_time}} AND {{end_time}} GROUP BY time, series, series_id ORDER BY time, series
Here's an example SQL query to chart memory usage by lobby ID:
-- Memory usage comparison between lobbiesWITH memory_data AS ( SELECT {{time}} AS time, metricTag('lobby_id') AS lobby_id, avgMerge(value_avg) AS memory_bytes FROM {{source}} WHERE name = 'memory_total_bytes' AND time BETWEEN {{start_time}} AND {{end_time}} GROUP BY time, lobby_id, series_id),-- Calculate total memory across all lobbies for each time periodtotal_per_time AS ( SELECT time, SUM(memory_bytes) AS total_memory FROM memory_data GROUP BY time)SELECT m.time, m.lobby_id AS series, -- Show each lobby's percentage of total memory usage (m.memory_bytes / t.total_memory) * 100 AS "% of Total Memory"FROM memory_data mJOIN total_per_time t ON m.time = t.timeORDER BY m.time, series