Files
atc-agents/deploy/openmetadata/enrich/di_verify.py
T

32 lines
1.0 KiB
Python
Raw Normal View History

import json, os, time, urllib.request, urllib.parse, urllib.error
OM = "http://openmetadata-server:8585/api"
H = {"Authorization": "Bearer " + os.environ["OM_TOKEN"]}
now = int(time.time() * 1000)
start = now - 7 * 86400000
def get(path):
r = urllib.request.Request(OM + path, headers=H)
try:
with urllib.request.urlopen(r, timeout=30) as resp:
return resp.status, json.loads(resp.read().decode())
except urllib.error.HTTPError as e:
return e.code, e.read().decode()[:160]
charts = [
"total_data_assets",
"percentage_of_data_asset_with_owner",
"percentage_of_data_asset_with_description",
"total_data_assets_by_tier",
]
for c in charts:
p = "/v1/analytics/dataInsights/system/charts/name/%s/data?start=%d&end=%d" % (c, start, now)
st, r = get(p)
summary = r
if isinstance(r, dict):
res = r.get("results") or r.get("data") or []
summary = "results=%d e.g. %s" % (len(res), json.dumps(res[:2])[:220])
print("%-45s %s %s" % (c, st, summary))