> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/action-center/compare/compare-with-last-discovery.md).

# Compare With Last Discovery

**Compare With Last Discovery** narrows the assets passed along a workflow to what changed since the previous completed discovery. It runs the Condition node's saved query against that previous discovery, compares the old result with the current one and passes on both the added and the removed assets. A **threshold percentage** lets you ignore small changes.

Unlike [Compare With Day](broken://pages/2bc4676122a353079a13dd4fef3b0b6044f2577f) and [Compare With Specific Date](broken://pages/89603324c683c082611efd148972693fce144710), it has no direction setting: added and removed assets are both passed on.

### Before you begin

* Connect the job directly after a **Condition node**. Without a condition on the previous node, the job is skipped and the log says "Compare job has been skipped. It must be connected to condition node."
* A previous completed, non-deleted discovery (other than the current one) must exist. If none is found, the job is skipped with a warning and the assets pass on unchanged.
* The job accepts these asset types: device, user, application, vulnerability, certificate, service, source code, AI, domain and policy.
* Each asset is matched by a key column, which the job requires in the node's columns:

| Asset type                                                  | Key column       |
| ----------------------------------------------------------- | ---------------- |
| device                                                      | `Hostname`       |
| user, certificate, service, source code, AI, domain, policy | `PrimaryKey`     |
| application                                                 | `NameAndVersion` |
| vulnerability                                               | `Id`             |

* The job has no connection fields, so nothing is required in [Action Center Settings](broken://pages/2bc5a56c2dcb8ef89cc0d72d4c41b59f8d5561f1).

### Settings

| Setting               | Type  | Required | Default | Description                                                                                                                                          |
| --------------------- | ----- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| threshold\_percentage | Float | No       | `0`     | Minimum change, in percent, for the job to pass assets on. Cannot be negative. Below the threshold, the job passes on no assets for that asset type. |

### How it works

1. For every selected asset type, the job runs the Condition node's query on the previous discovery and compares the key values with the assets currently in the workflow.
2. It computes the change: (added + removed) divided by the number of old matches, times 100. If there were no old matches, the change is 100 when anything differs and 0 otherwise.
3. If the change is below `threshold_percentage`, that asset type is emptied and the log says the job skipped it. With the default `0`, every change passes.
4. Otherwise it passes on the added assets and the removed assets together, each marked with `compare_status`:

| Meaning                                         | `compare_status`    |
| ----------------------------------------------- | ------------------- |
| Added, did not exist in the previous discovery  | `new_machine`       |
| Added, existed but did not match the query then | `parameter_added`   |
| Removed, no longer in the current discovery     | `removed_machine`   |
| Removed, still exists but no longer matches     | `parameter_removed` |

Removed assets are the old records from the previous discovery. The check runs once per asset type, not per asset.

### Example

Alert only when at least 10 percent of the matching devices changed.

| Node                        | Value                                              |
| --------------------------- | -------------------------------------------------- |
| Condition                   | Saved query: devices with a critical vulnerability |
| Compare With Last Discovery | threshold\_percentage: `10`                        |
| Next job                    | A notification job, for example Send Mail          |

### What's next?

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Compare With Day</strong></td><td>Compare with the discovery from x days ago.</td><td><a href="broken://pages/2bc4676122a353079a13dd4fef3b0b6044f2577f">Broken link</a></td></tr><tr><td><strong>Compare With Specific Date</strong></td><td>Compare with a fixed calendar date.</td><td><a href="broken://pages/89603324c683c082611efd148972693fce144710">Broken link</a></td></tr><tr><td><strong>About Action Center</strong></td><td>Workflows, triggers, conditions and job nodes.</td><td><a href="broken://pages/770677b93eb449b2e9819d4c13d63e600c9d490b">Broken link</a></td></tr></tbody></table>
