in distributed_nhc/export_nhc_result_to_kusto.py [0:0]
def ingest_debug_log(debug_file, creds, ingest_url, database, debug_table_name):
filename_parts = os.path.basename(debug_file).split("-", maxsplit=2)
ts_str = filename_parts[2].split(".")[0]
ts = datetime.strptime(ts_str, "%Y-%m-%d_%H-%M-%S")
job_name = filename_parts[1]
if job_name == "pssh":
job_name = f"{job_name}-{ts_str}"
with open(debug_file, 'r') as f:
lines = f.readlines()
reader = DictReader(lines, fieldnames = ["Hostname", "DebugLog"], delimiter='|', restkey="extra")
df = pd.DataFrame(reader)
df['Timestamp'] = ts
df['JobName'] = job_name
df['NodeName'] = df.apply(lambda x: x['Hostname'].strip(), axis=1)
df['DebugLog'] = df.apply(lambda x: x['DebugLog'].strip(), axis=1)
df = df[['Timestamp', 'JobName', 'Hostname', 'DebugLog']]
ingest_client = QueuedIngestClient(KustoConnectionStringBuilder.with_azure_token_credential(ingest_url, creds))
print(f"Ingesting health results from {os.path.basename(debug_file)} into {ingest_url} at {database}/{debug_table_name}")
ingest_client.ingest_from_dataframe(df, IngestionProperties(database, debug_table_name))