Created
June 12, 2018 03:29
-
-
Save WakeupTsai/b9eb8590528529030f4f69ce83009d7a to your computer and use it in GitHub Desktop.
Client for prometheus example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
"time" | |
"github.com/prometheus/client_golang/api" | |
prometheus "github.com/prometheus/client_golang/api/prometheus/v1" | |
"golang.org/x/net/context" | |
) | |
func main() { | |
metrick := `sum by(pod_name)(container_memory_usage_bytes{namespace="kube-system"})` | |
conf := api.Config{ | |
Address: "http://192.168.64.14:30003", | |
RoundTripper: api.DefaultRoundTripper, | |
} | |
client, err := api.NewClient(conf) | |
if err != nil { | |
fmt.Printf("Error while creating api.NewClient %s", err) | |
} | |
testTime := time.Now() | |
api := prometheus.NewAPI(client) | |
q, _ := api.Query(context.Background(), metrick, testTime) | |
fmt.Println(reflect.TypeOf(q)) | |
fmt.Println(q) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment