forked from netbox-community/netbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
14132 Add EventRule - change webhook and add in script processing to …
…events (netbox-community#14267) --------- Co-authored-by: Jeremy Stretch <[email protected]>
- Loading branch information
1 parent
b83fcc6
commit a38a382
Showing
55 changed files
with
1,564 additions
and
584 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Event Rules | ||
|
||
NetBox includes the ability to execute certain functions in response to internal object changes. These include: | ||
|
||
* [Scripts](../customization/custom-scripts.md) execution | ||
* [Webhooks](../integrations/webhooks.md) execution | ||
|
||
For example, suppose you want to automatically configure a monitoring system to start monitoring a device when its operational status is changed to active, and remove it from monitoring for any other status. You can create a webhook in NetBox for the device model and craft its content and destination URL to effect the desired change on the receiving system. You can then associate an event rule with this webhook and the webhook will be sent automatically by NetBox whenever the configured constraints are met. | ||
|
||
Each event must be associated with at least one NetBox object type and at least one event (e.g. create, update, or delete). | ||
|
||
## Conditional Event Rules | ||
|
||
An event rule may include a set of conditional logic expressed in JSON used to control whether an event triggers for a specific object. For example, you may wish to trigger an event for devices only when the `status` field of an object is "active": | ||
|
||
```json | ||
{ | ||
"and": [ | ||
{ | ||
"attr": "status.value", | ||
"value": "active" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
For more detail, see the reference documentation for NetBox's [conditional logic](../reference/conditions.md). | ||
|
||
## Event Rule Processing | ||
|
||
When a change is detected, any resulting events are placed into a Redis queue for processing. This allows the user's request to complete without needing to wait for the outgoing event(s) to be processed. The events are then extracted from the queue by the `rqworker` process. The current event queue and any failed events can be inspected in the admin UI under System > Background Tasks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# EventRule | ||
|
||
An event rule is a mechanism for automatically taking an action (such as running a script or sending a webhook) in response to an event in NetBox. For example, you may want to notify a monitoring system whenever the status of a device is updated in NetBox. This can be done by creating an event for device objects and designating a webhook to be transmitted. When NetBox detects a change to a device, an HTTP request containing the details of the change and who made it be sent to the specified receiver. | ||
|
||
See the [event rules documentation](../features/event-rules.md) for more information. | ||
|
||
## Fields | ||
|
||
### Name | ||
|
||
A unique human-friendly name. | ||
|
||
### Content Types | ||
|
||
The type(s) of object in NetBox that will trigger the rule. | ||
|
||
### Enabled | ||
|
||
If not selected, the event rule will not be processed. | ||
|
||
### Events | ||
|
||
The events which will trigger the rule. At least one event type must be selected. | ||
|
||
| Name | Description | | ||
|------------|--------------------------------------| | ||
| Creations | A new object has been created | | ||
| Updates | An existing object has been modified | | ||
| Deletions | An object has been deleted | | ||
| Job starts | A job for an object starts | | ||
| Job ends | A job for an object terminates | | ||
|
||
### Conditions | ||
|
||
A set of [prescribed conditions](../../reference/conditions.md) against which the triggering object will be evaluated. If the conditions are defined but not met by the object, no action will be taken. An event rule that does not define any conditions will _always_ trigger. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.