diagnostics.proto 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. syntax = "proto3";
  2. package chatto.admin.v1;
  3. import "google/protobuf/timestamp.proto";
  4. // Request to read owner-only server diagnostics.
  5. message GetSystemInfoRequest {}
  6. // Owner-only operational diagnostics for the Chatto server.
  7. message GetSystemInfoResponse {
  8. // Broker connection, account, and JetStream state.
  9. AdminSystemInfo system_info = 1;
  10. // Event-sourced projection health and memory estimates.
  11. repeated AdminProjectionState projections = 2;
  12. // Recoverable physical deletion worker health.
  13. AdminAssetCleanupStatus asset_cleanup = 3;
  14. // Known durable worker queues and their current broker-derived health.
  15. repeated AdminDurableWorkerStatus durable_workers = 4;
  16. // Whether projection diagnostics were collected successfully.
  17. optional bool projections_available = 5;
  18. // LiveKit voice and video call setup diagnostics.
  19. AdminLiveKitStatus livekit = 6;
  20. }
  21. // LiveKit voice and video call setup as seen by the Chatto server that
  22. // handled the request. The response never includes the API secret or the
  23. // webhook signing secret.
  24. //
  25. // Chatto calls the LiveKit server API once for each request to check
  26. // reachability and credentials. Webhook times come from the memory of the
  27. // Chatto server that handled the request. They reset when that server
  28. // restarts, and other servers in a cluster keep their own times.
  29. message AdminLiveKitStatus {
  30. // Whether `livekit.enabled` is set.
  31. bool enabled = 1;
  32. // Whether LiveKit is enabled and the URL, API key, and API secret are all set.
  33. bool configured = 2;
  34. // Configured LiveKit server URL that clients connect to.
  35. string url = 3;
  36. // Configured LiveKit API key. This is an identifier, not a secret.
  37. string api_key = 4;
  38. // Whether webhooks use a signing key that differs from `api_key`.
  39. bool separate_webhook_key = 5;
  40. // URL that LiveKit must send webhooks to. Empty when the public server URL is not set.
  41. string webhook_url = 6;
  42. // Result of the LiveKit server API check.
  43. AdminLiveKitConnectionState connection_state = 7;
  44. // Error detail when the check fails. Never contains secrets.
  45. string connection_error = 8;
  46. // True when `url` uses unencrypted `ws://` or `http://` and the public server URL host is not a loopback address or a `.localhost` name.
  47. bool insecure_url = 9;
  48. // Time of the last webhook with a valid signature that this server received.
  49. google.protobuf.Timestamp last_webhook_at = 10;
  50. // Time of the last webhook that this server rejected because of an invalid signature.
  51. google.protobuf.Timestamp last_rejected_webhook_at = 11;
  52. }
  53. // Result of the LiveKit server API check.
  54. enum AdminLiveKitConnectionState {
  55. // Unknown state.
  56. ADMIN_LIVE_KIT_CONNECTION_STATE_UNSPECIFIED = 0;
  57. // LiveKit is not configured, so Chatto did not do the check.
  58. ADMIN_LIVE_KIT_CONNECTION_STATE_NOT_CONFIGURED = 1;
  59. // LiveKit accepted the API call with the configured key and secret.
  60. ADMIN_LIVE_KIT_CONNECTION_STATE_OK = 2;
  61. // Chatto could not connect to the LiveKit server URL.
  62. ADMIN_LIVE_KIT_CONNECTION_STATE_UNREACHABLE = 3;
  63. // LiveKit rejected the configured API key or secret.
  64. ADMIN_LIVE_KIT_CONNECTION_STATE_UNAUTHORIZED = 4;
  65. // The server at the URL replied with an unexpected error.
  66. ADMIN_LIVE_KIT_CONNECTION_STATE_ERROR = 5;
  67. }
  68. // Broker-derived health for one known durable worker queue.
  69. message AdminDurableWorkerStatus {
  70. // Stable machine-readable worker key.
  71. string key = 1;
  72. // Current availability and work state.
  73. AdminDurableWorkerHealth health = 2;
  74. // Deliveries not yet handed to a handler.
  75. string pending_count = 3;
  76. // Deliveries awaiting acknowledgement; this does not prove handler liveness.
  77. string ack_pending_count = 4;
  78. // Pull requests currently waiting for work.
  79. string waiting_count = 5;
  80. // Redelivered messages that remain unacknowledged.
  81. string redelivered_count = 6;
  82. // Latest EVT stream sequence delivered to this queue.
  83. string last_delivered_sequence = 7;
  84. // Highest contiguous EVT stream sequence acknowledged by this queue.
  85. string ack_floor_sequence = 8;
  86. }
  87. // Operator-facing state derived from a durable consumer.
  88. enum AdminDurableWorkerHealth {
  89. ADMIN_DURABLE_WORKER_HEALTH_UNSPECIFIED = 0;
  90. // This optional worker is not required by current server configuration.
  91. ADMIN_DURABLE_WORKER_HEALTH_INACTIVE = 1;
  92. // A worker is waiting and all known work is acknowledged.
  93. ADMIN_DURABLE_WORKER_HEALTH_HEALTHY = 2;
  94. // A worker is available and unacknowledged work remains.
  95. ADMIN_DURABLE_WORKER_HEALTH_WORKING = 3;
  96. // An acknowledgement is pending, but broker state cannot prove whether a
  97. // handler is active or the delivery is awaiting recovery after a crash.
  98. ADMIN_DURABLE_WORKER_HEALTH_UNCONFIRMED = 4;
  99. // The consumer exists but has neither a waiting pull nor an ack-pending delivery.
  100. ADMIN_DURABLE_WORKER_HEALTH_STALLED = 5;
  101. // The required consumer is unavailable.
  102. ADMIN_DURABLE_WORKER_HEALTH_UNAVAILABLE = 6;
  103. }
  104. // Current health of recoverable message-owned asset deletion.
  105. message AdminAssetCleanupStatus {
  106. // Operator-facing state derived from the shared durable consumer.
  107. AdminAssetCleanupHealth health = 1;
  108. // Deletion effects currently waiting for a successful retry.
  109. int64 pending_count = 2;
  110. // Deprecated. Shared durable consumers do not expose this value.
  111. google.protobuf.Timestamp oldest_pending_at = 3 [deprecated = true];
  112. // Deprecated. Shared durable consumers run continuously rather than in passes.
  113. bool pass_in_progress = 4 [deprecated = true];
  114. // Deprecated. Shared durable consumers run continuously rather than in passes.
  115. google.protobuf.Timestamp last_pass_at = 5 [deprecated = true];
  116. // Deprecated. Shared durable consumers run continuously rather than in passes.
  117. google.protobuf.Timestamp last_successful_pass_at = 6 [deprecated = true];
  118. // Deprecated. Shared durable consumers do not publish a liveness heartbeat.
  119. google.protobuf.Timestamp updated_at = 7 [deprecated = true];
  120. // Deprecated. Use health and pending_count instead.
  121. bool last_pass_failed = 8 [deprecated = true];
  122. // Global EVT sequence of the most recently delivered deletion fact.
  123. string last_inspected_sequence = 9;
  124. // Current latest global EVT sequence matching asset deletion facts.
  125. string latest_deletion_sequence = 10;
  126. }
  127. // Operator-facing state for the shared durable asset cleanup queue.
  128. enum AdminAssetCleanupHealth {
  129. ADMIN_ASSET_CLEANUP_HEALTH_UNSPECIFIED = 0;
  130. ADMIN_ASSET_CLEANUP_HEALTH_INACTIVE = 1;
  131. ADMIN_ASSET_CLEANUP_HEALTH_INITIALIZING = 2;
  132. ADMIN_ASSET_CLEANUP_HEALTH_HEALTHY = 3;
  133. ADMIN_ASSET_CLEANUP_HEALTH_RETRYING = 4;
  134. ADMIN_ASSET_CLEANUP_HEALTH_STALLED = 5;
  135. // Cleanup diagnostics could not be read; other system diagnostics remain valid.
  136. ADMIN_ASSET_CLEANUP_HEALTH_UNAVAILABLE = 6;
  137. }
  138. // Broker and application diagnostics shown on the server admin system page.
  139. message AdminSystemInfo {
  140. // Current NATS server connection metadata.
  141. AdminConnectionInfo connection = 1;
  142. // JetStream account limits and usage.
  143. AdminAccountInfo account = 2;
  144. // JetStream stream and consumer diagnostics.
  145. AdminNatsStats nats = 3;
  146. // Aggregate Chatto object counts.
  147. AdminServerStats stats = 4;
  148. }
  149. // Current NATS server connection metadata.
  150. message AdminConnectionInfo {
  151. // Whether Chatto is currently connected to NATS.
  152. bool connected = 1;
  153. // Connected NATS server ID.
  154. string server_id = 2;
  155. // Connected NATS server name.
  156. string server_name = 3;
  157. // Connected NATS server version.
  158. string version = 4;
  159. // Maximum payload accepted by the connected NATS server.
  160. int64 max_payload = 5;
  161. // Round-trip latency to the connected NATS server.
  162. string rtt = 6;
  163. }
  164. // JetStream account limits and usage.
  165. message AdminAccountInfo {
  166. // Maximum memory storage in bytes. Values less than or equal to zero mean unlimited.
  167. int64 memory = 1;
  168. // Used memory storage in bytes.
  169. int64 memory_used = 2;
  170. // Maximum file storage in bytes. Values less than or equal to zero mean unlimited.
  171. int64 storage = 3;
  172. // Used file storage in bytes.
  173. int64 storage_used = 4;
  174. // Maximum number of streams. Values less than or equal to zero mean unlimited.
  175. int32 streams = 5;
  176. // Current number of streams.
  177. int32 streams_used = 6;
  178. // Maximum number of consumers. Values less than or equal to zero mean unlimited.
  179. int32 consumers = 7;
  180. // Current number of consumers.
  181. int32 consumers_used = 8;
  182. }
  183. // Aggregate Chatto object counts.
  184. message AdminServerStats {
  185. // Registered user count.
  186. int32 user_count = 1;
  187. // Channel room count.
  188. int32 channel_room_count = 2;
  189. // Direct-message room count.
  190. int32 dm_room_count = 3;
  191. }
  192. // JetStream stream and consumer diagnostics.
  193. message AdminNatsStats {
  194. // Total messages stored across all streams.
  195. int64 total_messages = 1;
  196. // Total bytes stored across all streams.
  197. int64 total_bytes = 2;
  198. // Total pending messages across all consumers.
  199. int64 total_consumer_pending = 3;
  200. // Total messages currently waiting for acknowledgement.
  201. int32 total_ack_pending = 4;
  202. // Streams sorted by name.
  203. repeated AdminNatsStreamInfo streams = 5;
  204. // Consumers sorted by stream and name.
  205. repeated AdminNatsConsumerInfo consumers = 6;
  206. }
  207. // JetStream stream state.
  208. message AdminNatsStreamInfo {
  209. // Stream name.
  210. string name = 1;
  211. // Stream description.
  212. string description = 2;
  213. // Subjects stored in the stream.
  214. repeated string subjects = 3;
  215. // Storage backend name.
  216. string storage = 4;
  217. // Number of messages in the stream.
  218. int64 messages = 5;
  219. // Number of bytes in the stream.
  220. int64 bytes = 6;
  221. // First stream sequence.
  222. string first_sequence = 7;
  223. // Last stream sequence.
  224. string last_sequence = 8;
  225. // Number of stream consumers.
  226. int32 consumer_count = 9;
  227. // Configured stream replica count.
  228. int32 replicas = 10;
  229. // Current cluster leader, when reported by NATS.
  230. string cluster_leader = 11;
  231. }
  232. // JetStream consumer state.
  233. message AdminNatsConsumerInfo {
  234. // Stream that owns the consumer.
  235. string stream = 1;
  236. // Consumer name.
  237. string name = 2;
  238. // Durable name, when the consumer is durable.
  239. string durable = 3;
  240. // Single filter subject, when configured.
  241. string filter_subject = 4;
  242. // Multiple filter subjects, when configured.
  243. repeated string filter_subjects = 5;
  244. // NATS acknowledgement policy.
  245. string ack_policy = 6;
  246. // Whether this is a pull consumer.
  247. bool pull_based = 7;
  248. // Whether this push consumer has an active subscription.
  249. bool push_bound = 8;
  250. // Pending messages for this consumer.
  251. int64 pending = 9;
  252. // Messages waiting for acknowledgement.
  253. int32 ack_pending = 10;
  254. // Redelivered message count.
  255. int32 redelivered = 11;
  256. // Pull requests waiting for messages.
  257. int32 waiting = 12;
  258. // Delivered consumer sequence.
  259. string delivered_consumer_sequence = 13;
  260. // Delivered stream sequence.
  261. string delivered_stream_sequence = 14;
  262. // Acknowledgement floor consumer sequence.
  263. string ack_floor_consumer_sequence = 15;
  264. // Acknowledgement floor stream sequence.
  265. string ack_floor_stream_sequence = 16;
  266. }
  267. // Event-sourced projection health and memory estimates.
  268. message AdminProjectionState {
  269. // Stable projection key.
  270. string key = 1;
  271. // Display name.
  272. string name = 2;
  273. // EVT subjects consumed by this projection.
  274. repeated string subjects = 3;
  275. // Whether the projection projector is running.
  276. bool started = 4;
  277. // Startup duration in seconds, set after startup completes.
  278. optional double startup_duration_seconds = 5;
  279. // Last event sequence applied by the projection.
  280. string last_applied_sequence = 6;
  281. // Target sequence among the projection's matching subjects.
  282. string matching_stream_sequence = 7;
  283. // Current last sequence of the EVT stream.
  284. string stream_last_sequence = 8;
  285. // Matching-subject lag between target and applied sequence.
  286. int64 lag = 9;
  287. // Whether the projection failed.
  288. bool failed = 10;
  289. // Sequence that failed, when failed is true.
  290. string failed_sequence = 11;
  291. // Failure message, when failed is true.
  292. string failure = 12;
  293. // Estimated number of entries held by the projection.
  294. int64 entry_count = 13;
  295. // Estimated memory used by the projection in bytes.
  296. int64 estimated_bytes = 14;
  297. // Estimated average memory per entry in bytes.
  298. int64 average_entry_bytes = 15;
  299. // Projection-specific diagnostic metrics.
  300. repeated AdminProjectionMetric metrics = 16;
  301. }
  302. // Projection-specific diagnostic metric.
  303. message AdminProjectionMetric {
  304. // Metric name.
  305. string name = 1;
  306. // Metric value.
  307. int64 value = 2;
  308. // Estimated memory represented by this metric in bytes.
  309. int64 bytes = 3;
  310. }
  311. // Provides server diagnostics for the admin system page.
  312. service AdminDiagnosticsService {
  313. // Returns broker, JetStream, projection, and LiveKit diagnostics. Requires
  314. // the server owner role. The call checks the LiveKit server API, so it can
  315. // take up to five seconds when LiveKit does not reply.
  316. rpc GetSystemInfo(GetSystemInfoRequest) returns (GetSystemInfoResponse);
  317. }