@@ -5,26 +5,26 @@ class Stats {
5
5
6
6
updateService ( name , status ) {
7
7
for ( var i = 0 ; i < this . services . length ; i ++ ) {
8
- if ( this . services [ i ] . name == name ) {
8
+ if ( this . services [ i ] . name == name ) {
9
9
this . services [ i ] . status = status ;
10
10
return ;
11
11
}
12
12
}
13
- this . services . push ( { name, status} )
13
+ this . services . push ( { name, status } ) ;
14
14
}
15
15
16
16
toPrometheus ( ) {
17
- var pstring = `` ;
17
+ var pstring = '' ;
18
18
19
19
for ( var i = 0 ; i < this . services . length ; i ++ ) {
20
- pstring += `sky_puppy_service_status{service="${ this . services [ i ] . name } " name="${ this . services [ i ] . name } "} ${ this . services [ i ] . status . up } ${ Date . now ( ) } \n` ;
21
- pstring += `sky_puppy_service_status_count_total{service="${ this . services [ i ] . name } " status="healthy"} ${ this . services [ i ] . status . count . healthy } ${ Date . now ( ) } \n` ;
22
- pstring += `sky_puppy_service_status_count_total{service="${ this . services [ i ] . name } " status="unhealthy"} ${ this . services [ i ] . status . count . unhealthy } ${ Date . now ( ) } \n` ;
23
- pstring += `sky_puppy_service_status_count_total{service="${ this . services [ i ] . name } " status="unhealthy_status"} ${ this . services [ i ] . status . count . unhealthy_status } ${ Date . now ( ) } \n` ;
24
- pstring += `sky_puppy_service_status_count_total{service="${ this . services [ i ] . name } " status="unhealthy_response_time"} ${ this . services [ i ] . status . count . unhealthy_response_time } ${ Date . now ( ) } \n` ;
25
- pstring += `sky_puppy_service_status_count_total{service="${ this . services [ i ] . name } " status="down"} ${ this . services [ i ] . status . count . down } ${ Date . now ( ) } \n` ;
26
- pstring += `sky_puppy_service_response_time{service="${ this . services [ i ] . name } " name="${ this . services [ i ] . name } "} ${ this . services [ i ] . status . time } ${ Date . now ( ) } \n` ;
27
- pstring += `sky_puppy_service_response_code{service="${ this . services [ i ] . name } " name="${ this . services [ i ] . name } "} ${ this . services [ i ] . status . code } ${ Date . now ( ) } \n` ;
20
+ pstring += `sky_puppy_service_status{service="${ this . services [ i ] . name } ", name="${ this . services [ i ] . name } " } ${ this . services [ i ] . status . up } ${ Date . now ( ) } \n` ;
21
+ pstring += `sky_puppy_service_status_count_total{service="${ this . services [ i ] . name } ", status="healthy"} ${ this . services [ i ] . status . count . healthy } ${ Date . now ( ) } \n` ;
22
+ pstring += `sky_puppy_service_status_count_total{service="${ this . services [ i ] . name } ", status="unhealthy"} ${ this . services [ i ] . status . count . unhealthy } ${ Date . now ( ) } \n` ;
23
+ pstring += `sky_puppy_service_status_count_total{service="${ this . services [ i ] . name } ", status="unhealthy_status"} ${ this . services [ i ] . status . count . unhealthy_status } ${ Date . now ( ) } \n` ;
24
+ pstring += `sky_puppy_service_status_count_total{service="${ this . services [ i ] . name } ", status="unhealthy_response_time"} ${ this . services [ i ] . status . count . unhealthy_response_time } ${ Date . now ( ) } \n` ;
25
+ pstring += `sky_puppy_service_status_count_total{service="${ this . services [ i ] . name } ", status="down"} ${ this . services [ i ] . status . count . down } ${ Date . now ( ) } \n` ;
26
+ pstring += `sky_puppy_service_response_time{service="${ this . services [ i ] . name } ", name="${ this . services [ i ] . name } "} ${ this . services [ i ] . status . time } ${ Date . now ( ) } \n` ;
27
+ pstring += `sky_puppy_service_response_code{service="${ this . services [ i ] . name } ", message=" ${ this . services [ i ] . status . message } ", name="${ this . services [ i ] . name } "} ${ Number ( this . services [ i ] . status . code ) || - 1 } ${ Date . now ( ) } \n` ;
28
28
}
29
29
return pstring ;
30
30
}
0 commit comments