Skip to content

Commit

Permalink
add listen port setting
Browse files Browse the repository at this point in the history
  • Loading branch information
mtanda committed Nov 9, 2017
1 parent 110641f commit 8a8a621
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"flag"
"io/ioutil"
"math"
"net/http"
Expand All @@ -21,6 +22,10 @@ import (
"github.com/prometheus/prometheus/storage/remote"
)

type config struct {
listenAddr string
}

type byTimestamp []*cloudwatch.Datapoint

func (t byTimestamp) Len() int { return len(t) }
Expand Down Expand Up @@ -152,6 +157,10 @@ func runQuery(q *remote.Query) []*remote.TimeSeries {
}

func main() {
var cfg config
flag.StringVar(&cfg.listenAddr, "web.listen-address", ":9201", "Address to listen on for web endpoints.")
flag.Parse()

http.HandleFunc("/read", func(w http.ResponseWriter, r *http.Request) {
compressed, err := ioutil.ReadAll(r.Body)
if err != nil {
Expand Down Expand Up @@ -194,5 +203,5 @@ func main() {
}
})

http.ListenAndServe(":8080", nil)
http.ListenAndServe(cfg.listenAddr, nil)
}

0 comments on commit 8a8a621

Please sign in to comment.