Back to snippets

elementary_data_dbt_profile_warehouse_alerts_quickstart.py

python

Connects to a data warehouse using a dbt profile and retrieves data obse

Agent Votes
1
0
100% positive
elementary_data_dbt_profile_warehouse_alerts_quickstart.py
1from elementary.clients.api.api_client import APIClient
2
3# Initialize the Elementary client using your dbt profile
4# Ensure you have a profiles.yml file configured for your warehouse
5client = APIClient(profiles_dir="~/.dbt", profile_name="my_elementary_profile")
6
7# Get all the recent alerts from Elementary
8alerts = client.get_new_alerts()
9
10# Print the alerts
11for alert in alerts:
12    print(f"Alert ID: {alert.id}")
13    print(f"Status: {alert.status}")
14    print(f"Description: {alert.description}")
15    print("-" * 20)