-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
30 lines (24 loc) · 903 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
// Copyright: (c) 2022, Justin Béra (@just1not2) <[email protected]>
// GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
// Throws an error if a configuration file is not provided
if len(os.Args) > 2 {
log.Fatalf("error: command format is %s <configuration file>", os.Args[0])
}
configuration := NewConfiguration()
collector := NewYourlsCollector(configuration)
prometheus.MustRegister(collector)
// Starts the Prometheus exporter webserver
http.Handle("/metrics", promhttp.Handler())
fmt.Printf("Starting the YOURLS Prometheus exporter, listening on port %v...\n", configuration.Port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", configuration.Port), nil))
}