@@ -47,16 +47,24 @@ var (
4747 },
4848 []string {"route" , "attribute" },
4949 )
50+ spaceValidationVersionsGauge = prometheus .NewGaugeVec (
51+ prometheus.GaugeOpts {
52+ Name : "spaceapi_validation_version" ,
53+ Help : "SpaceAPI versions implemented by an endpoint" ,
54+ },
55+ []string {"route" , "version" },
56+ )
5057)
5158
5259type ValidateUrlV2Response struct {
53- Valid bool `json:"valid"`
54- IsHttps bool `json:"isHttps"`
55- HttpsForward bool `json:"httpsForward"`
56- Reachable bool `json:"reachable"`
57- Cors bool `json:"cors"`
58- ContentType bool `json:"contentType"`
59- CertValid bool `json:"certValid"`
60+ Valid bool `json:"valid"`
61+ IsHttps bool `json:"isHttps"`
62+ HttpsForward bool `json:"httpsForward"`
63+ Reachable bool `json:"reachable"`
64+ Cors bool `json:"cors"`
65+ ContentType bool `json:"contentType"`
66+ CertValid bool `json:"certValid"`
67+ CheckedVersions []string `json:"checkedVersions"`
6068}
6169
6270type entry struct {
@@ -95,6 +103,7 @@ func main() {
95103 prometheus .MustRegister (staticFileScrapCounter )
96104 prometheus .MustRegister (spaceRequestSummary )
97105 prometheus .MustRegister (spaceValidationGauge )
106+ prometheus .MustRegister (spaceValidationVersionsGauge )
98107 spaceApiDirectory = make (map [string ]entry )
99108
100109 directorySuccessfullyLoaded := loadPersistentDirectory ()
@@ -279,7 +288,9 @@ func validateEntry(ctx context.Context, url string) (spaceapivalidatorclient.Val
279288 defer spaceValidationGauge .With (prometheus.Labels {"route" : url , "attribute" : "ContentType" }).Set (b2i [response .ContentType ])
280289 defer spaceValidationGauge .With (prometheus.Labels {"route" : url , "attribute" : "CertValid" }).Set (b2i [response .CertValid ])
281290 defer spaceValidationGauge .With (prometheus.Labels {"route" : url , "attribute" : "Valid" }).Set (b2i [response .Valid ])
282-
291+ for _ , v := range response .CheckedVersions {
292+ defer spaceValidationVersionsGauge .With (prometheus.Labels {"route" : url , "version" : v }).Set (1 )
293+ }
283294 return response , nil
284295}
285296
@@ -299,13 +310,14 @@ func buildEntry(ctx context.Context, url string, c chan entry) {
299310 }
300311
301312 entry .ValidationResult = ValidateUrlV2Response {
302- Valid : response .Valid ,
303- IsHttps : response .IsHttps ,
304- HttpsForward : response .HttpsForward ,
305- Reachable : response .Reachable ,
306- Cors : response .Cors ,
307- ContentType : response .ContentType ,
308- CertValid : response .CertValid ,
313+ Valid : response .Valid ,
314+ IsHttps : response .IsHttps ,
315+ HttpsForward : response .HttpsForward ,
316+ Reachable : response .Reachable ,
317+ Cors : response .Cors ,
318+ ContentType : response .ContentType ,
319+ CertValid : response .CertValid ,
320+ CheckedVersions : response .CheckedVersions ,
309321 }
310322 entry .Valid = response .Valid
311323 entry .LastSeen = time .Now ().Unix ()
0 commit comments