Skip to content

Commit 13693ae

Browse files
authored
Merge pull request #11 from stackhpc/feature/env-vars
Adds environment variables to set listen address and port
2 parents 7a9ea0d + 09a0bf8 commit 13693ae

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

os_capacity/prometheus.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22

3+
import os
34
import collections
45
import json
56
import time
@@ -343,7 +344,12 @@ def collect(self):
343344

344345

345346
if __name__ == "__main__":
346-
prom_client.start_http_server(9000)
347+
kwargs = {
348+
"port": int(os.environ.get('OS_CAPACITY_EXPORTER_PORT', 9000)),
349+
"addr": os.environ.get('OS_CAPACITY_EXPORTER_LISTEN_ADDRESS', '0.0.0.0'),
350+
}
351+
prom_client.start_http_server(**kwargs)
352+
347353
prom_core.REGISTRY.register(OpenStackCapacityCollector())
348354
# there must be a better way!
349355
while True:

0 commit comments

Comments
 (0)