Merge pull request #5 from PovilasID/main

Default exporter port change option
main
Rhys Bailey 2023-11-30 21:26:36 +11:00 committed by GitHub
commit ba203cd8b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import re
import time import time
import sys import sys
import logging import logging
import os
def add_metric(metric, label, stats, key, multiplier=1.0): def add_metric(metric, label, stats, key, multiplier=1.0):
@ -200,7 +201,7 @@ if __name__ == '__main__':
logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO) logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO)
try: try:
url = sys.argv[1] url = str(os.environ.get('FRIGATE_STATS_URL', 'http://localhost:5000/api/stats'))
REGISTRY.register(CustomCollector(url)) REGISTRY.register(CustomCollector(url))
except IndexError: except IndexError:
logging.error( logging.error(
@ -208,10 +209,11 @@ if __name__ == '__main__':
"e.g. FRIGATE_STATS_URL=http://<your-frigate-ip>:5000/api/stats") "e.g. FRIGATE_STATS_URL=http://<your-frigate-ip>:5000/api/stats")
exit() exit()
start_http_server(9100) port = int(os.environ.get('PORT', 9100))
start_http_server(port)
logging.info('Started, Frigate API URL: ' + sys.argv[1]) logging.info('Started, Frigate API URL: ' + url)
logging.info('Metrics at: http://localhost:9100/metrics') logging.info('Metrics at: http://localhost:' + str(port) + '/metrics')
while True: while True:
time.sleep(1) time.sleep(1)