@@ -13,14 +13,15 @@ class TeamCityOpenMetrics(OpenMetricsBaseCheckV2):
13
13
__NAMESPACE__ = 'teamcity'
14
14
DEFAULT_METRIC_LIMIT = 0
15
15
16
- DEFAULT_METRICS_URL = "/{}/ app/metrics"
17
- EXPERIMENTAL_METRICS_URL = "/{}/ app/metrics?experimental=true"
16
+ DEFAULT_METRICS_URL = "/app/metrics"
17
+ EXPERIMENTAL_METRICS_URL = "/app/metrics?experimental=true"
18
18
19
19
def __init__ (self , name , init_config , instances ):
20
20
super (TeamCityOpenMetrics , self ).__init__ (name , init_config , instances )
21
21
self .basic_http_auth = is_affirmative (
22
22
self .instance .get ('basic_http_authentication' , bool (self .instance .get ('password' )))
23
23
)
24
+ self .token_auth = is_affirmative (self .instance .get ('auth_token' ))
24
25
self .auth_type = 'httpAuth' if self .basic_http_auth else 'guestAuth'
25
26
parsed_endpoint = urlparse (self .instance .get ('server' ))
26
27
self .server_url = "{}://{}" .format (parsed_endpoint .scheme , parsed_endpoint .netloc )
@@ -29,9 +30,12 @@ def __init__(self, name, init_config, instances):
29
30
experimental_metrics = is_affirmative (self .instance .get ('experimental_metrics' , False ))
30
31
31
32
if experimental_metrics :
32
- self .metrics_endpoint = self .EXPERIMENTAL_METRICS_URL . format ( self . auth_type )
33
+ self .metrics_endpoint = self .EXPERIMENTAL_METRICS_URL
33
34
else :
34
- self .metrics_endpoint = self .DEFAULT_METRICS_URL .format (self .auth_type )
35
+ self .metrics_endpoint = self .DEFAULT_METRICS_URL
36
+
37
+ if not self .token_auth :
38
+ self .metrics_endpoint = '/{}{}' .format (self .auth_type , self .metrics_endpoint )
35
39
36
40
def configure_scrapers (self ):
37
41
config = deepcopy (self .instance )
0 commit comments