Skip to content

Add more Event Rule ConditionsΒ #18159

Open
@Hardi100

Description

@Hardi100

NetBox version

v4.1.7

Feature type

Change to existing functionality

Triage priority

I volunteer to perform this work (if approved)

Proposed functionality

The Event Rule condition only checks the objects data, not the value it had before. https://github.com/netbox-community/netbox/blob/develop/netbox/extras/events.py#L90. This proposal could save a lot of unnecessary Webhooks or Scripts, if the data, that the condition checks doesn't change.

Use case

I want to create a device 1x in an external application, if the device has status active.

  1. I create a device with status Planned.
  2. I update the device and set the status to active.
  3. I update the device and give it a description.
  4. I Update the device and set the status to Offline.

I create an Event Rule, on update send a Webhook if the status of the device is active.
My Event Rule condition states:

{
    "attr": "status.value",
    "value": "active"
}

The event hook is sent on step 2 & 3. But on step 3 the webhook is executed unnecessary because the Device was created in step 2 in the external system.

Possible new condition syntax:

{
  "and": [
    {
      "attr": "status.value",
      "value": "active"
    },
    {
      "attr": "snapshots.prechange.status.value",
      "value": "snapshots.postchange.status.value",
      "op": "eq",
      "negate": true
    }
  ]
}

or

{
    "attr": "status.value",
    "value": "active",
    "changed": true
}

This rule should check if the status is active, and check if the value of the status has changed. Only if the status has been changed and set to active, the webhook is executed.

Database changes

None

External dependencies

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity: highExpected to require a large amont of time and effort to implement relative to other tasksneeds milestoneAwaiting prioritization for inclusion with a future NetBox releasestatus: backlogAwaiting selection for worktype: featureIntroduction of new functionality to the application

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions