mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2025-06-28 06:16:41 +00:00
Adding boilerplate files
Signed-off-by: Per Ploug <per.ploug@zalando.de>
This commit is contained in:
33
example/main.go
Normal file
33
example/main.go
Normal file
@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func metricsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(200)
|
||||
w.Write([]byte(fmt.Sprintf(`{"queue": {"length": %d}}`, size)))
|
||||
}
|
||||
|
||||
var (
|
||||
size int
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.IntVar(&size, "fake-queue-length", 10, "Fake queue length for fake metrics.")
|
||||
flag.Parse()
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/metrics", metricsHandler)
|
||||
|
||||
server := &http.Server{
|
||||
Addr: ":9090",
|
||||
Handler: mux,
|
||||
ReadTimeout: 5 * time.Second,
|
||||
}
|
||||
|
||||
server.ListenAndServe()
|
||||
}
|
Reference in New Issue
Block a user