@@ -3,6 +3,8 @@ package main
3
3
import (
4
4
"flag"
5
5
"fmt"
6
+ "log"
7
+ "net/http"
6
8
"os"
7
9
"os/signal"
8
10
"time"
@@ -26,6 +28,8 @@ import (
26
28
"github.com/k8snetworkplumbingwg/whereabouts/pkg/controlloop"
27
29
"github.com/k8snetworkplumbingwg/whereabouts/pkg/logging"
28
30
"github.com/k8snetworkplumbingwg/whereabouts/pkg/reconciler"
31
+ "github.com/prometheus/client_golang/prometheus"
32
+ "github.com/prometheus/client_golang/prometheus/promhttp"
29
33
)
30
34
31
35
const (
@@ -62,6 +66,24 @@ func main() {
62
66
63
67
networkController .Start (stopChan )
64
68
69
+ reconcilerSuccessTotal := prometheus .NewCounter (prometheus.CounterOpts {
70
+ Name : "reconciler_success_total" ,
71
+ Help : "Increments upon successful run of IP reconciler" ,
72
+ })
73
+
74
+ reconcilerAttempted := prometheus .NewCounter (prometheus.CounterOpts {
75
+ Name : "reconciler_attempted" ,
76
+ Help : "Increments after each attempt of an IP reconciler run" ,
77
+ })
78
+
79
+ prometheus .MustRegister (reconcilerSuccessTotal , reconcilerAttempted )
80
+
81
+ http .Handle ("/metrics" , promhttp .Handler ())
82
+
83
+ go func () {
84
+ log .Fatal (http .ListenAndServe (":1984" , nil ))
85
+ }()
86
+
65
87
s := gocron .NewScheduler (time .UTC )
66
88
s .Cron ("0 30 4 1/1 * ? *" ).Do (func () { // every day at 4:30 UTC (user configurable cron expression)
67
89
reconciler .InvokeIPReconciler (returnErr )
@@ -74,7 +96,9 @@ func main() {
74
96
s .Stop ()
75
97
return
76
98
case err := <- returnErr :
99
+ reconcilerAttempted .Inc ()
77
100
if err == nil {
101
+ reconcilerSuccessTotal .Inc ()
78
102
logging .Verbosef ("reconciler success" )
79
103
} else {
80
104
logging .Verbosef ("reconciler failure" )
0 commit comments