Context
The Aerospike Unique Data Agent (UDA) tracks unique data usage of an Aerospike cluster. The agent runs as a service that monitors an entire cluster. It polls the cluster for statistics on memory and disk usage relevant to your license agreement and stores them for later processing. The UDA integrates with asadm but can also be used with a custom client using the REST API.
This article demonstrates how that may be accessed from an application to retrieve the data.
Method
Here is some example GO code :-
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
// Define the URL you want to connect to
url := "http://127.0.0.1:8080/v1/entries"
// As the the API, you can add filters to the end of this
// Send an HTTP GET request to the URL
response, err := http.Get(url)
if err != nil {
fmt.Printf("Error making GET request: %v\n", err)
return
}
defer response.Body.Close()
// Read the response body
body, err := ioutil.ReadAll(response.Body)
if err != nil {
fmt.Printf("Error reading response body: %v\n", err)
return
}
// Print the response status code and body
fmt.Printf("Response Status Code: %d\n", response.StatusCode)
fmt.Printf("Response Body:\n%s\n", body)
}
When called, this is an example of what will be returned :-
[root@goclient mgmt]# go run uda.go
Response Status Code: 200
Response Body:
{"count":4,"entries":[{"time":"2023-09-22T08:00:00Z","hours_since_start":0,"cluster_name":"flipdst","cluster_generation":1,"cluster_stable":true,"node_count":2,"level":"info","master_objects":1000,"unique_data_bytes":49893,"namespaces":{"bar":{"master_objects":1000,"unique_data_bytes":49893},"test":{"master_objects":0,"unique_data_bytes":0}},"errors":[]},{"time":"2023-09-22T09:00:00Z","hours_since_start":1,"cluster_name":"flipdst","cluster_generation":1,"cluster_stable":true,"node_count":2,"level":"info","master_objects":1000,"unique_data_bytes":49893,"namespaces":{"bar":{"master_objects":1000,"unique_data_bytes":49893},"test":{"master_objects":0,"unique_data_bytes":0}},"errors":[]},{"time":"2023-09-22T10:00:00Z","hours_since_start":2,"cluster_name":"flipdst","cluster_generation":1,"cluster_stable":true,"node_count":2,"level":"info","master_objects":1000,"unique_data_bytes":49893,"namespaces":{"bar":{"master_objects":1000,"unique_data_bytes":49893},"test":{"master_objects":0,"unique_data_bytes":0}},"errors":[]},{"time":"2023-09-22T11:00:00Z","hours_since_start":3,"cluster_name":"flipdst","cluster_generation":1,"cluster_stable":true,"node_count":2,"level":"info","master_objects":1000,"unique_data_bytes":49893,"namespaces":{"bar":{"master_objects":1000,"unique_data_bytes":49893},"test":{"master_objects":0,"unique_data_bytes":0}},"errors":[]}]}