Skip to content

Commit

Permalink
Use new "monitor" flag to determine if a component should be monitored (
Browse files Browse the repository at this point in the history
  • Loading branch information
mattops authored Nov 3, 2023
1 parent 5f1716b commit 9c314db
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions health_ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
import socketserver

sc_api_endpoint = os.getenv("SERVICE_CATALOGUE_API_ENDPOINT")
sc_api_filter = os.getenv("SC_FILTER", '')
sc_api_token = os.getenv("SERVICE_CATALOGUE_API_KEY")
redis_host = os.getenv("REDIS_ENDPOINT")
redis_port = os.getenv("REDIS_PORT")
redis_tls_enabled = os.getenv("REDIS_TLS_ENABLED", 'False').lower() in ('true', '1', 't')
redis_token = os.getenv("REDIS_TOKEN", "")
redis_max_stream_length = int(os.getenv("REDIS_MAX_STREAM_LENGTH", "180"))
redis_max_stream_length = int(os.getenv("REDIS_MAX_STREAM_LENGTH", "360"))
refresh_interval = int(os.getenv("REFRESH_INTERVAL", 60))
log_level = os.environ.get('LOG_LEVEL', 'INFO').upper()

Expand Down Expand Up @@ -128,6 +129,7 @@ def startHttpServer():
host = redis_host,
port = redis_port,
ssl = redis_tls_enabled,
ssl_cert_reqs = None,
decode_responses = True
)
if redis_token:
Expand All @@ -149,7 +151,7 @@ def startHttpServer():
log.critical("Unable to connect to the Service Catalogue.")
raise SystemExit(e)

sc_endpoint = f"{sc_api_endpoint}/v1/components?populate=environments"
sc_endpoint = f"{sc_api_endpoint}/v1/components?populate=environments{sc_api_filter}"

while True:
log.info(sc_endpoint)
Expand All @@ -173,7 +175,7 @@ def startHttpServer():
for env in component["attributes"]["environments"]:
c_name = component["attributes"]["name"]
e_name = env["name"]
if env["url"]:
if (env["url"]) and (env["monitor"] == True):
if env["health_path"]:
endpoint = f'{env["url"]}{env["health_path"]}'
endpoint_type = "health"
Expand Down

0 comments on commit 9c314db

Please sign in to comment.