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

Expand filtering options for related resource pairs in /api/events/filter #16979

Open
ogenstad opened this issue Feb 5, 2025 · 0 comments
Open
Labels
enhancement An improvement of an existing feature

Comments

@ogenstad
Copy link

ogenstad commented Feb 5, 2025

Describe the current behavior

When using /api/events/filter it's possible to match against related resources using the EventFilter object in JSON format. The EventRelatedFilter object allows us to filter the events based on a set of keys and values contained within an related resource where all fields are expected to match a related resource.

Describe the proposed behavior

It would be great if there was an additional option to search and match against multiple pairs at once.

The filter, could then be expanded with an additional attribute looking something like this:

class EventRelatedFilter(EventDataFilter):
    label_pairs: Optional[List[ResourceSpecification]] = Field(
        None, description="Only include events for related resources with these label pairs"
    )

Example Use

Posting to the new API might look like this:

{
  "filter": {
      "related": {
          "label_pairs": [
              {
                  "prefect.resource.role": "department",
                  "prefect.resource.id": "develop"
              },
              {
                "prefect.resource.role": "environment",
                "prefect.resource.id": "test"
            }
          ]
      }
  }
}

The above would return all events that had a combination of the related resources.

Additional context

Note this is somewhat related to #16978 and a similar operator selection as described there would also be useful.

@ogenstad ogenstad added the enhancement An improvement of an existing feature label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant