forked from halkyon/prometheus-hetrixtools-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (33 loc) · 1.28 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"flag"
"fmt"
"log"
"net/http"
"github.com/halkyon/prometheus-hetrixtools-exporter/internal/collector"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
const (
defaultListenAddress = ":8080" // Port where the Prometheus metrics will be exposed
defaultMetricsPath = "/metrics"
namespace = "hetrixtools"
)
func main() {
var (
listenAddress = flag.String("web.listen-address", defaultListenAddress, "Address on which to expose metrics and web interface.")
metricsPath = flag.String("web.telemetry-path", defaultMetricsPath, "Path under which to expose metrics.")
apiKey = flag.String("hetrixtools.api-key", "", "HetrixTools API key for authentication.")
)
flag.Parse()
if *apiKey == "" {
log.Fatal("HetrixTools API key is required")
}
// Create a new instance of the Collector
hetrixCollector := collector.New(namespace, *apiKey)
prometheus.MustRegister(hetrixCollector)
// This will point /metrics to the promhttp handler
http.Handle(*metricsPath, promhttp.Handler())
fmt.Println("Beginning to serve on port", *listenAddress)
log.Fatal(http.ListenAndServe(*listenAddress, nil))
}