client_golang
client_golang copied to clipboard
How to parse the query result, it seems like only provides Type and String
I want to iterator result from query, but it's a string, so, i need to handle it by myself?
`result, warnings, err := cli.api.Query(context.TODO(), "kube_node_status_condition{condition="Ready"}", time.Now()) if warnings != nil { log.Printf("warning: %v", warnings) }
if err != nil {
log.Printf("warning: %v", err)
}
log.Printf("result: %v", result)`
You need to cast result to model.Vector (https://pkg.go.dev/github.com/prometheus/common/model#Vector) for instant queries or model.Matrix (https://pkg.go.dev/github.com/prometheus/common/model#Matrix) for range queries.
result, warnings, err := cli.api.Query(...)
for _, sample := range result.(model.Vector) {
...
}
Hello 👋 Looks like there was no activity on this issue for the last 3 months. Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗 If there will be no activity in the next 4 weeks, this issue will be closed (we can always reopen an issue if we need!).
Closing for now as promised, let us know if you need this to be reopened! 🤗