Closed Cookiery closed 1 year ago
Hi @Cookiery ,
You can get the ttl distribution through the go client using info commands, then parse that to JSON.
The info command you want is histogram.
Specifically something like this to get the ttl histogram. histogram:namespace=<namespace_name>;type=ttl
Go client example...
package main
import (
"log"
"time"
as "github.com/aerospike/aerospike-client-go/v6"
)
func main() {
// remove timestamps from log messages
log.SetFlags(0)
// connect to the host
cp := as.NewClientPolicy()
cp.Timeout = 10 * time.Second
// cp.User = "admin"
// cp.Password = "admin"
conn, err := as.NewConnection(cp, as.NewHost("localhost", 3000))
if err != nil {
log.Fatalln(err.Error())
}
// Login if needed
// if err := conn.Login(cp); err != nil {
// log.Fatalln(err.Error())
// }
infoMap, err := conn.RequestInfo("histogram:namespace=test;type=ttl")
if err != nil {
log.Fatalln(err.Error())
}
cnt := 1
for k, v := range infoMap {
log.Printf("%d : %s\n %s\n", cnt, k, v)
cnt++
}
}
output:
% go run main.go
1 : histogram:namespace=test;type=ttl
units=seconds:hist-width=2095700:bucket-width=20957:buckets=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,39597
code based off https://github.com/aerospike/aerospike-client-go/blob/v6/examples/info/info.go
Hi team, I want to get the time_to_live. I can get the data from
asadm -e 'show distribution time_to_live'
. But it returned the table format data. I want to get JSON format data from golang SDK.Thank you very much!