diagnostics.proto 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. }
  19. // Broker-derived health for one known durable worker queue.
  20. message AdminDurableWorkerStatus {
  21. // Stable machine-readable worker key.
  22. string key = 1;
  23. // Current availability and work state.
  24. AdminDurableWorkerHealth health = 2;
  25. // Deliveries not yet handed to a handler.
  26. string pending_count = 3;
  27. // Deliveries awaiting acknowledgement; this does not prove handler liveness.
  28. string ack_pending_count = 4;
  29. // Pull requests currently waiting for work.
  30. string waiting_count = 5;
  31. // Redelivered messages that remain unacknowledged.
  32. string redelivered_count = 6;
  33. // Latest EVT stream sequence delivered to this queue.
  34. string last_delivered_sequence = 7;
  35. // Highest contiguous EVT stream sequence acknowledged by this queue.
  36. string ack_floor_sequence = 8;
  37. }
  38. // Operator-facing state derived from a durable consumer.
  39. enum AdminDurableWorkerHealth {
  40. ADMIN_DURABLE_WORKER_HEALTH_UNSPECIFIED = 0;
  41. // This optional worker is not required by current server configuration.
  42. ADMIN_DURABLE_WORKER_HEALTH_INACTIVE = 1;
  43. // A worker is waiting and all known work is acknowledged.
  44. ADMIN_DURABLE_WORKER_HEALTH_HEALTHY = 2;
  45. // A worker is available and unacknowledged work remains.
  46. ADMIN_DURABLE_WORKER_HEALTH_WORKING = 3;
  47. // An acknowledgement is pending, but broker state cannot prove whether a
  48. // handler is active or the delivery is awaiting recovery after a crash.
  49. ADMIN_DURABLE_WORKER_HEALTH_UNCONFIRMED = 4;
  50. // The consumer exists but has neither a waiting pull nor an ack-pending delivery.
  51. ADMIN_DURABLE_WORKER_HEALTH_STALLED = 5;
  52. // The required consumer is unavailable.
  53. ADMIN_DURABLE_WORKER_HEALTH_UNAVAILABLE = 6;
  54. }
  55. // Current health of recoverable message-owned asset deletion.
  56. message AdminAssetCleanupStatus {
  57. // Operator-facing state derived from the shared durable consumer.
  58. AdminAssetCleanupHealth health = 1;
  59. // Deletion effects currently waiting for a successful retry.
  60. int64 pending_count = 2;
  61. // Deprecated. Shared durable consumers do not expose this value.
  62. google.protobuf.Timestamp oldest_pending_at = 3 [deprecated = true];
  63. // Deprecated. Shared durable consumers run continuously rather than in passes.
  64. bool pass_in_progress = 4 [deprecated = true];
  65. // Deprecated. Shared durable consumers run continuously rather than in passes.
  66. google.protobuf.Timestamp last_pass_at = 5 [deprecated = true];
  67. // Deprecated. Shared durable consumers run continuously rather than in passes.
  68. google.protobuf.Timestamp last_successful_pass_at = 6 [deprecated = true];
  69. // Deprecated. Shared durable consumers do not publish a liveness heartbeat.
  70. google.protobuf.Timestamp updated_at = 7 [deprecated = true];
  71. // Deprecated. Use health and pending_count instead.
  72. bool last_pass_failed = 8 [deprecated = true];
  73. // Global EVT sequence of the most recently delivered deletion fact.
  74. string last_inspected_sequence = 9;
  75. // Current latest global EVT sequence matching asset deletion facts.
  76. string latest_deletion_sequence = 10;
  77. }
  78. // Operator-facing state for the shared durable asset cleanup queue.
  79. enum AdminAssetCleanupHealth {
  80. ADMIN_ASSET_CLEANUP_HEALTH_UNSPECIFIED = 0;
  81. ADMIN_ASSET_CLEANUP_HEALTH_INACTIVE = 1;
  82. ADMIN_ASSET_CLEANUP_HEALTH_INITIALIZING = 2;
  83. ADMIN_ASSET_CLEANUP_HEALTH_HEALTHY = 3;
  84. ADMIN_ASSET_CLEANUP_HEALTH_RETRYING = 4;
  85. ADMIN_ASSET_CLEANUP_HEALTH_STALLED = 5;
  86. // Cleanup diagnostics could not be read; other system diagnostics remain valid.
  87. ADMIN_ASSET_CLEANUP_HEALTH_UNAVAILABLE = 6;
  88. }
  89. // Broker and application diagnostics shown on the server admin system page.
  90. message AdminSystemInfo {
  91. // Current NATS server connection metadata.
  92. AdminConnectionInfo connection = 1;
  93. // JetStream account limits and usage.
  94. AdminAccountInfo account = 2;
  95. // JetStream stream and consumer diagnostics.
  96. AdminNatsStats nats = 3;
  97. // Aggregate Chatto object counts.
  98. AdminServerStats stats = 4;
  99. }
  100. // Current NATS server connection metadata.
  101. message AdminConnectionInfo {
  102. // Whether Chatto is currently connected to NATS.
  103. bool connected = 1;
  104. // Connected NATS server ID.
  105. string server_id = 2;
  106. // Connected NATS server name.
  107. string server_name = 3;
  108. // Connected NATS server version.
  109. string version = 4;
  110. // Maximum payload accepted by the connected NATS server.
  111. int64 max_payload = 5;
  112. // Round-trip latency to the connected NATS server.
  113. string rtt = 6;
  114. }
  115. // JetStream account limits and usage.
  116. message AdminAccountInfo {
  117. // Maximum memory storage in bytes. Values less than or equal to zero mean unlimited.
  118. int64 memory = 1;
  119. // Used memory storage in bytes.
  120. int64 memory_used = 2;
  121. // Maximum file storage in bytes. Values less than or equal to zero mean unlimited.
  122. int64 storage = 3;
  123. // Used file storage in bytes.
  124. int64 storage_used = 4;
  125. // Maximum number of streams. Values less than or equal to zero mean unlimited.
  126. int32 streams = 5;
  127. // Current number of streams.
  128. int32 streams_used = 6;
  129. // Maximum number of consumers. Values less than or equal to zero mean unlimited.
  130. int32 consumers = 7;
  131. // Current number of consumers.
  132. int32 consumers_used = 8;
  133. }
  134. // Aggregate Chatto object counts.
  135. message AdminServerStats {
  136. // Registered user count.
  137. int32 user_count = 1;
  138. // Channel room count.
  139. int32 channel_room_count = 2;
  140. // Direct-message room count.
  141. int32 dm_room_count = 3;
  142. }
  143. // JetStream stream and consumer diagnostics.
  144. message AdminNatsStats {
  145. // Total messages stored across all streams.
  146. int64 total_messages = 1;
  147. // Total bytes stored across all streams.
  148. int64 total_bytes = 2;
  149. // Total pending messages across all consumers.
  150. int64 total_consumer_pending = 3;
  151. // Total messages currently waiting for acknowledgement.
  152. int32 total_ack_pending = 4;
  153. // Streams sorted by name.
  154. repeated AdminNatsStreamInfo streams = 5;
  155. // Consumers sorted by stream and name.
  156. repeated AdminNatsConsumerInfo consumers = 6;
  157. }
  158. // JetStream stream state.
  159. message AdminNatsStreamInfo {
  160. // Stream name.
  161. string name = 1;
  162. // Stream description.
  163. string description = 2;
  164. // Subjects stored in the stream.
  165. repeated string subjects = 3;
  166. // Storage backend name.
  167. string storage = 4;
  168. // Number of messages in the stream.
  169. int64 messages = 5;
  170. // Number of bytes in the stream.
  171. int64 bytes = 6;
  172. // First stream sequence.
  173. string first_sequence = 7;
  174. // Last stream sequence.
  175. string last_sequence = 8;
  176. // Number of stream consumers.
  177. int32 consumer_count = 9;
  178. // Configured stream replica count.
  179. int32 replicas = 10;
  180. // Current cluster leader, when reported by NATS.
  181. string cluster_leader = 11;
  182. }
  183. // JetStream consumer state.
  184. message AdminNatsConsumerInfo {
  185. // Stream that owns the consumer.
  186. string stream = 1;
  187. // Consumer name.
  188. string name = 2;
  189. // Durable name, when the consumer is durable.
  190. string durable = 3;
  191. // Single filter subject, when configured.
  192. string filter_subject = 4;
  193. // Multiple filter subjects, when configured.
  194. repeated string filter_subjects = 5;
  195. // NATS acknowledgement policy.
  196. string ack_policy = 6;
  197. // Whether this is a pull consumer.
  198. bool pull_based = 7;
  199. // Whether this push consumer has an active subscription.
  200. bool push_bound = 8;
  201. // Pending messages for this consumer.
  202. int64 pending = 9;
  203. // Messages waiting for acknowledgement.
  204. int32 ack_pending = 10;
  205. // Redelivered message count.
  206. int32 redelivered = 11;
  207. // Pull requests waiting for messages.
  208. int32 waiting = 12;
  209. // Delivered consumer sequence.
  210. string delivered_consumer_sequence = 13;
  211. // Delivered stream sequence.
  212. string delivered_stream_sequence = 14;
  213. // Acknowledgement floor consumer sequence.
  214. string ack_floor_consumer_sequence = 15;
  215. // Acknowledgement floor stream sequence.
  216. string ack_floor_stream_sequence = 16;
  217. }
  218. // Event-sourced projection health and memory estimates.
  219. message AdminProjectionState {
  220. // Stable projection key.
  221. string key = 1;
  222. // Display name.
  223. string name = 2;
  224. // EVT subjects consumed by this projection.
  225. repeated string subjects = 3;
  226. // Whether the projection projector is running.
  227. bool started = 4;
  228. // Startup duration in seconds, set after startup completes.
  229. optional double startup_duration_seconds = 5;
  230. // Last event sequence applied by the projection.
  231. string last_applied_sequence = 6;
  232. // Target sequence among the projection's matching subjects.
  233. string matching_stream_sequence = 7;
  234. // Current last sequence of the EVT stream.
  235. string stream_last_sequence = 8;
  236. // Matching-subject lag between target and applied sequence.
  237. int64 lag = 9;
  238. // Whether the projection failed.
  239. bool failed = 10;
  240. // Sequence that failed, when failed is true.
  241. string failed_sequence = 11;
  242. // Failure message, when failed is true.
  243. string failure = 12;
  244. // Estimated number of entries held by the projection.
  245. int64 entry_count = 13;
  246. // Estimated memory used by the projection in bytes.
  247. int64 estimated_bytes = 14;
  248. // Estimated average memory per entry in bytes.
  249. int64 average_entry_bytes = 15;
  250. // Projection-specific diagnostic metrics.
  251. repeated AdminProjectionMetric metrics = 16;
  252. }
  253. // Projection-specific diagnostic metric.
  254. message AdminProjectionMetric {
  255. // Metric name.
  256. string name = 1;
  257. // Metric value.
  258. int64 value = 2;
  259. // Estimated memory represented by this metric in bytes.
  260. int64 bytes = 3;
  261. }
  262. // Provides server diagnostics for the admin system page.
  263. service AdminDiagnosticsService {
  264. // Returns broker, JetStream, and projection diagnostics. Requires the
  265. // server owner role.
  266. rpc GetSystemInfo(GetSystemInfoRequest) returns (GetSystemInfoResponse);
  267. }