XD-DENG commented on a change in pull request #4309: [AIRFLOW-3504]
Extend/refine the functionality of "/health" endpoint
URL: https://github.com/apache/airflow/pull/4309#discussion_r246398014
##########
File path: airflow/www/blueprints.py
##########
@@ -32,6 +37,26 @@ def index():
@routes.route('/health')
def health():
- """ We can add an array of tests here to check the server's health """
- content = Markup(markdown.markdown("The server is healthy!"))
- return content
+ session = settings.Session()
+ DM = models.DagModel
+ payload = {}
+
+ latest_scheduler_run = None
+ payload['metadatabase'] = {'status': 'healthy'}
+ try:
+ latest_scheduler_run =
session.query(func.max(DM.last_scheduler_run)).scalar()
+ except Exception as _:
+ payload['metadatabase']['status'] = 'unhealthy'
+
+ if not latest_scheduler_run:
+ scheduler_status = 'unhealthy'
+ else:
+ if timezone.utcnow() - latest_scheduler_run <= timedelta(seconds=30):
Review comment:
I have put this threshold into `airflow.cfg` as a configuration item, with
default value 30 seconds.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services