Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api/endpoint): allow filtering eventlogs by attributes #34417

Merged
merged 5 commits into from Sep 27, 2023

Conversation

hainenber
Copy link
Contributor

Closes: #34210

feat(api/endpoint): Allow filtering for Event Logs at /eventlogs endpoint using the entity's attributes.

Tests added and API schema updated


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues labels Sep 16, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Sep 16, 2023

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@hainenber hainenber force-pushed the allow-filtering-eventlogs-by-attrs branch from 6bd57a7 to b6a6c67 Compare September 16, 2023 08:44
if event:
query = query.where(Log.event == event)
if before:
query = query.where(Log.dttm <= timezone.parse(before))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we use strictly less then before in this type of queries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest commit. Thanks for the review!

Comment on lines 4819 to 4825
EventLogDAGID:
in: query
name: dag_id
schema:
type: string
required: false
description: DAG ID of an event log.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have already a dag id param:

DAGID:
in: path
name: dag_id
schema:
type: string
required: true
description: The DAG ID.

so I don't know if we should use it or create a new one, @pierrejeambrun wdyt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should re-use it if this is exatly the same thing. No need to duplicate I believe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this dag_id parameter works for path and not as query parameter. In addition, it's set as required while eventlogs's filtering parameters aren't strictly required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, maybe we can prefix that with Filter and put them in the Filter section where other filters reside in the spec. Also maybe a generic name such as FilterDAGID so we can easily reuse it. (shouldn't be specific to EventLog I believe)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameters are now converted to filters in latest commit. Thanks!

Comment on lines 4827 to 4833
EventLogTaskID:
in: query
name: task_id
schema:
type: string
required: false
description: Task ID of an event log.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for task id

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! I've replied in above review.

Comment on lines 237 to 238
eventlog1 = create_log_model(event="1", dag_id="1", task_id="1", owner="1", when=self.default_time)
eventlog2 = create_log_model(event="2", dag_id="2", task_id="2", owner="2", when=self.default_time_2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try to use different values? (ex event_1, dag_1, task_1, ...) instead of having the same value for all the variables, without that we cannot ensure that the filter is really working.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest commit. Thanks for the review!

@eladkal eladkal added this to the Airflow 2.8.0 milestone Sep 16, 2023
@eladkal eladkal added the type:improvement Changelog: Improvements label Sep 16, 2023
@hainenber hainenber force-pushed the allow-filtering-eventlogs-by-attrs branch 3 times, most recently from 5aa520e to 4af14ac Compare September 21, 2023 13:57
@hainenber hainenber force-pushed the allow-filtering-eventlogs-by-attrs branch from 4af14ac to b3d1b8a Compare September 21, 2023 15:17
@hainenber
Copy link
Contributor Author

hello there, can someone help reviewing and merge if deemed sufficient? Thanks!

Copy link
Contributor

@bbovenzi bbovenzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

airflow/api_connexion/openapi/v1.yaml Outdated Show resolved Hide resolved
@uranusjr uranusjr merged commit 3189ebe into apache:main Sep 27, 2023
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues type:improvement Changelog: Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add filters to get event logs
6 participants