forked from jwholdsworth/jira-cloud-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (29 loc) · 854 Bytes
/
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
package main
import (
"fmt"
"net/http"
"os"
"app/collector"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
)
func main() {
metricsPath := getEnv("METRICS_PATH", "/metrics")
listenAddress := getEnv("LISTEN_ADDRESS", ":9800")
jiraCollector := collector.JiraCollector()
prometheus.MustRegister(jiraCollector)
http.Handle(metricsPath, promhttp.Handler())
if metricsPath != "/" {
http.Handle("/", http.RedirectHandler(metricsPath, http.StatusMovedPermanently))
}
log.Info(fmt.Sprintf("Listening on %s", listenAddress))
log.Fatal(http.ListenAndServe(listenAddress, nil))
}
func getEnv(environmentVariable, defaultValue string) string {
envVar := os.Getenv(environmentVariable)
if len(envVar) == 0 {
return defaultValue
}
return envVar
}