Interface StatsClient


public interface StatsClient
Centrifugo stats API client for retrieving server and channel statistics.

This client provides access to Centrifugo's statistics and information endpoints, allowing you to monitor server state, active channels, and connection information.

Key features:

  • Server node information and cluster status
  • Active channels listing and filtering
  • Connection information and user sessions
  • Performance metrics and uptime data
Since:
1.0.0
See Also:
  • Method Details

    • channels

      ChannelsResponse channels(ChannelsRequest request)
      Get active channels information.

      Returns information about all currently active channels (channels with one or more active subscribers). Can be filtered using glob patterns to match specific channel names.

      Channel information includes:

      • Channel name
      • Number of currently connected clients

      Use cases:

      • Monitoring active channels
      • Building channel browsers
      • Administrative dashboards
      • Debugging subscription issues

      Warning: For large deployments with many active channels (>10k), this operation can be expensive. Consider using real-time analytics approaches for massive setups.

      Example - get all channels:

      
       ChannelsRequest request = ChannelsRequest.builder().build();
       ChannelsResponse response = client.channels(request);
       

      Example - filter channels by pattern:

      
       ChannelsRequest request = ChannelsRequest.builder().pattern("chat:*") // Only
       																		// channels
       																		// starting
       																		// with
       																		// "chat:"
       		.build();
       ChannelsResponse response = client.channels(request);
       
      Parameters:
      request - the channels request containing optional pattern filter
      Returns:
      the channels response containing active channels and their client counts
      See Also:
    • channels

      default ChannelsResponse channels(String pattern)
      Get active channels information.

      Returns information about all currently active channels (channels with one or more active subscribers). Can be filtered using glob patterns to match specific channel names.

      Channel information includes:

      • Channel name
      • Number of currently connected clients

      Use cases:

      • Monitoring active channels
      • Building channel browsers
      • Administrative dashboards
      • Debugging subscription issues

      Warning: For large deployments with many active channels (>10k), this operation can be expensive. Consider using real-time analytics approaches for massive setups.

      Example - get all channels:

      
       ChannelsRequest request = ChannelsRequest.builder().build();
       ChannelsResponse response = client.channels(request);
       

      Example - filter channels by pattern:

      
       ChannelsRequest request = ChannelsRequest.builder().pattern("chat:*") // Only
       																		// channels
       																		// starting
       																		// with
       																		// "chat:"
       		.build();
       ChannelsResponse response = client.channels(request);
       
      Parameters:
      pattern - the pattern to filter channels
      Returns:
      the channels response containing active channels and their client counts
      See Also:
    • connections

      Get connections information.

      Returns information about currently connected clients. Can filter connections by user ID or use expressions for more complex filtering.

      Connection information includes:

      • Client ID and user ID
      • Connection metadata and state
      • Subscribed channels
      • Connection and subscription tokens
      • Application name and version
      • Transport and protocol information

      Use cases:

      • Monitoring user connections
      • Debugging connection issues
      • Administrative user management
      • Session auditing and analysis

      Example - get all connections:

      
       ConnectionsRequest request = ConnectionsRequest.builder().build();
       ConnectionsResponse response = client.connections(request);
       

      Example - get connections for specific user:

      
       ConnectionsRequest request = ConnectionsRequest.builder().user("user123").build();
       ConnectionsResponse response = client.connections(request);
       
      Parameters:
      request - the connections request containing optional user or expression filters
      Returns:
      the connections response containing matching connection information
      See Also:
    • connections

      Get connections information.

      Returns information about currently connected clients. Can filter connections by user ID or use expressions for more complex filtering.

      Connection information includes:

      • Client ID and user ID
      • Connection metadata and state
      • Subscribed channels
      • Connection and subscription tokens
      • Application name and version
      • Transport and protocol information

      Use cases:

      • Monitoring user connections
      • Debugging connection issues
      • Administrative user management
      • Session auditing and analysis

      Example - get all connections:

      
       ConnectionsRequest request = ConnectionsRequest.builder().build();
       ConnectionsResponse response = client.connections(request);
       

      Example - get connections for specific user:

      
       ConnectionsRequest request = ConnectionsRequest.builder().user("user123").build();
       ConnectionsResponse response = client.connections(request);
       
      Parameters:
      fn - the function to configure the connections request
      Returns:
      the connections response containing matching connection information
      See Also:
    • info

      InfoResponse info(InfoRequest request)
      Get server information.

      Returns detailed information about all Centrifugo nodes in the cluster, including performance metrics, version information, and runtime statistics.

      Node information includes:

      • Node ID, name, and version
      • Uptime and process information
      • Number of clients, users, and channels
      • Number of subscriptions
      • Performance metrics (CPU, memory)
      • Custom metrics if configured

      Use cases:

      • Health monitoring and alerting
      • Performance analysis
      • Cluster management
      • Capacity planning
      • Administrative dashboards

      Example:

      
       InfoRequest request = InfoRequest.builder().build();
       InfoResponse response = client.info(request);
      
       for (NodeResult node : response.getResult().getNodes()) {
       	System.out.println("Node: " + node.getName() + ", Clients: "
       			+ node.getNumClients() + ", Uptime: " + node.getUptime());
       }
       
      Parameters:
      request - the info request (empty object)
      Returns:
      the info response containing information about all cluster nodes
      See Also:
    • info

      Get server information.

      Returns detailed information about all Centrifugo nodes in the cluster, including performance metrics, version information, and runtime statistics.

      Node information includes:

      • Node ID, name, and version
      • Uptime and process information
      • Number of clients, users, and channels
      • Number of subscriptions
      • Performance metrics (CPU, memory)
      • Custom metrics if configured

      Use cases:

      • Health monitoring and alerting
      • Performance analysis
      • Cluster management
      • Capacity planning
      • Administrative dashboards

      Example:

      
       InfoRequest request = InfoRequest.builder().build();
       InfoResponse response = client.info(request);
      
       for (NodeResult node : response.getResult().getNodes()) {
       	System.out.println("Node: " + node.getName() + ", Clients: "
       			+ node.getNumClients() + ", Uptime: " + node.getUptime());
       }
       
      Parameters:
      fn - the function to configure the info request
      Returns:
      the info response containing information about all cluster nodes
      See Also: