File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ Prometheus metrics exporter for github actions self-hosted runners.
1212| REFRESH_INTERVAL | No | Internval time in seconds betwen api requests (Default: 20)
1313| LOG_LEVEL | No | Log level: DEBUG, INFO, WARNING or ERROR (Default: INFO)
1414| API_URL | No | URL to your github API (Default: https://api.github.com )
15+ | GITHUB_APP_ID | No | The Github app id to login as
16+ | GITHUB_PRIVATE_KEY | No* | The Github app private key generated from the app settings, required if GITHUB_APP_ID is set
1517
1618
1719## How to deploy
Original file line number Diff line number Diff line change 1+ cryptography == 42.0.5
12prometheus_client == 0.15.0
23requests == 2.28.2
3- PyJWT == 2.6 .0
4+ PyJWT == 2.8 .0
45python-dateutil == 2.8.1
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ def __init__(
3838 self .github_app_id = github_app_id
3939 self .private_key = private_key
4040 self .github_owner = github_owner
41+ self .api_url = api_url
4142 self .logger = logger
4243
4344 def app_jwt_header (self ):
@@ -152,7 +153,7 @@ def list_runners(self) -> list:
152153 headers = self .get_headers ()
153154
154155 per_page = 100
155- url = f"https://api.github.com /orgs/{ self .github_owner } /actions/runners?per_page={ per_page } "
156+ url = f"{ self . api_url } /orgs/{ self .github_owner } /actions/runners?per_page={ per_page } "
156157
157158 while True :
158159 try :
Original file line number Diff line number Diff line change @@ -156,17 +156,14 @@ def main():
156156 GITHUB_APP_ID = os .getenv ("GITHUB_APP_ID" )
157157 GITHUB_PRIVATE_KEY = os .getenv ("GITHUB_PRIVATE_KEY" )
158158 OWNER = os .getenv ("OWNER" )
159- API_URL = os .getenv ("API_URL" )
159+ API_URL = os .getenv ("API_URL" , "https://api.github.com" )
160160
161161 # Start prometheus metrics
162162 logger .info ("Starting metrics server" )
163163 start_http_server (8000 )
164164
165165 runner_exports = runnerExports ()
166166
167- if API_URL == None or API_URL == "" :
168- API_URL = "https://api.github.com"
169-
170167 github = githubApi (
171168 OWNER ,
172169 logger ,
You can’t perform that action at this time.
0 commit comments