Tracking resources
GLIDE 1.2 introduces a new non-Valkey API: getStatistics which returns statistics with (currently) 2 properties (available for both GlideClient & GlideClusterClient):
total_connectionscontains the number of active connections across all clientstotal_clientscontains the number of active clients (regardless of its type)
from glide import ( NodeAddress, GlideClusterClientConfiguration, GlideClusterClient)
addresses = [NodeAddress(host="address.example.com", port=6379)]client_config = GlideClusterClientConfiguration(addresses, request_timeout=500)
client = await GlideClusterClient.create(client_config)
# Retrieve statisticsstats = await client.get_statistics()
# Example: Accessing and printing statisticsprint(f"Total Connections: {stats['total_connections']}")print(f"Total Clients: {stats['total_clients']}")import glide.api.GlideClusterClient;import glide.api.models.configuration.GlideClusterClientConfiguration;import glide.api.models.configuration.NodeAddress;
GlideClusterClient config = GlideClusterClientConfiguration.builder() .address(NodeAddress.builder() .host("address.example.com") .port(6379).build()) .requestTimeout(500) .build();
GlideClusterClient client = GlideClusterClient.createClient(config).get();HashMap<String, String> stats = client.getStatistics();// do something with the `stats`import {GlideClusterClient} from "@valkey/valkey-glide";
const addresses = [ { host: "address.example.com", port: 6379 }];
const client = await GlideClusterClient.createClient({ addresses: addresses, requestTimeout: 500});
// Retrieve statisticsconst stats = await client.getStatistics();
// Example: Accessing and printing statisticsconsole.log(`Total Connections: ${stats.total_connections}`);console.log(`Total Clients: ${stats.total_clients}`);import ( "fmt" "log"
glide "github.com/valkey-io/valkey-glide/go/v2" "github.com/valkey-io/valkey-glide/go/v2/config")
clientConfig := config.NewClusterClientConfiguration(). WithAddress(&config.NodeAddress{Host: "address.example.com", Port: 6379})
client, err := glide.NewClusterClient(clientConfig)if err != nil { log.Fatal(err)}defer client.Close()
// Retrieve statisticsstats := client.GetStatistics()
// Example: Accessing and printing statisticsfmt.Printf("Total Connections: %d\n", stats["total_connections"])fmt.Printf("Total Clients: %d\n", stats["total_clients"])$addresses = [ ['host' => 'address.example.com', 'port' => 6379]];
$client = new ValkeyGlideCluster( addresses: $addresses, request_timeout: 500);
// Retrieve statistics$stats = $client->getStatistics();
// Example: Accessing and printing statisticsecho "Total Connections: {$stats['total_connections']}\n";echo "Total Clients: {$stats['total_clients']}\n";require "valkey"
client = Valkey.new( nodes: [{ host: "address.example.com", port: 6379 }], cluster_mode: true, timeout: 0.5 # request timeout in seconds (500 ms))
# Retrieve statisticsstats = client.get_statistics
# Example: Accessing and printing statisticsputs "Total Connections: #{stats[:total_connections]}"puts "Total Clients: #{stats[:total_clients]}"