raviagarwalunravel commented on a change in pull request #5118: [AIRFLOW-4315] 
Add monitoring API's to airflow
URL: https://github.com/apache/airflow/pull/5118#discussion_r280706835
 
 

 ##########
 File path: airflow/www/api/experimental/endpoints.py
 ##########
 @@ -41,6 +47,124 @@
 api_experimental = Blueprint('api_experimental', __name__)
 
 
+@api_experimental.route(
+    
'/dags/<string:dag_id>/dag_runs/<string:execution_date>/tasks/<string:task_id>/logs',
+    methods=['GET'])
+@requires_authentication
+def logs(dag_id, execution_date, task_id):
+    """
+    Return logs for the specified task identified by dag_id, execution_date 
and task_id
+    """
+    try:
+        log = get_task_logs(dag_id, task_id, execution_date)
+    except AirflowException as err:
+        _log.info(err)
+        response = jsonify(error="{}".format(err))
+        response.status_code = err.status_code
+        return response
+    except ValueError:
+        error_message = (
+            'Given execution date, {}, could not be identified '
+            'as a date. Example date format: 2015-11-16T14:34:15+00:00'
+            .format(execution_date))
+        response = jsonify({'error': error_message})
+        response.status_code = 400
+        return response
+    except AttributeError as e:
+        error_message = ["Unable to read logs.\n{}\n".format(str(e))]
+        metadata = {}
+        metadata['end_of_log'] = True
+        return jsonify(message=error_message, error=True, metadata=metadata)
+
+    return log
+
+
+@api_experimental.route('/dag_runs', methods=['GET'])
+@requires_authentication
+def dag_runs_filter():
+    """
+    Return the list of all dag_runs
+    :query param state: a query string parameter 
'?state=queued|running|success...'
+    :query param state_not_equal: a query string parameter 
'?state_not_equal=queued|running|success...'
 
 Review comment:
   done in all places.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

Reply via email to