Session 01 — Resource Enrichment

Why this matters

A PropertySource is a small setup script. It asks the controller for a few useful facts about the resource, then saves those facts so LogicMonitor can use them when it decides which modules apply.

Import this first

Import module-scaffold.json using the shared import steps. This is your starting point: the script is mostly complete, but a few small sections are left for you to finish. It is disabled with appliesTo: false() until you review the targeting rule.

Use scripts/student.groovy for the guided exercise. The complete implementation is scripts/reference.groovy.

What to do

The controller endpoint returns metadata like this:

{
  "name": "Enterprise Fabric Controller",
  "site": "training-east",
  "version": "7.4.2"
}
  1. In the module settings, change AppliesTo from false() to:

    fabric.api.user && fabric.api.pass && !hasCategory("Training_Fabric")
    

    Best practice: !hasCategory("Training_Fabric") makes this PropertySource a one-time enrichment step: after it successfully adds the category, it no longer applies. For a PropertySource that should keep resource metadata current, such as installed software versions, omit the !hasCategory(...) clause so it can run again and update changed values.

  2. Read through the supplied request flow before changing anything.

  3. Fill in the marked system.hostname lookup. This tells the script where the workshop API lives.

  4. Uncomment the three output lines. Notice that one adds a category and the other two save controller details as resource properties.

  5. Run the PropertySource once against the workshop resource and check the resource details page.

Check your result

  • The Training_Fabric category is added.
  • auto.fabric_site and auto.fabric_version appear on the resource.
  • Running it a second time does not target the resource again because it already has the category.

Discuss

Why is category assignment a better targeting mechanism than repeating API-specific logic in every DataSource?

The PropertySource checks the API-specific credentials once and assigns the Training_Fabric category. Each DataSource can then target that category with a short, consistent rule instead of repeating API checks.

Why should a PropertySource be safe to run again without creating duplicate results?

Running a PropertySource again is safe: it updates resource properties when the returned values change. The AppliesTo rule determines whether it gets another chance to run; use the one-time gate only when you do not need ongoing metadata refreshes.

What should happen when credentials or the API response are unavailable?

The script should stop with a failure status and avoid saving incomplete or misleading properties. It should report enough diagnostic information to troubleshoot the issue without printing secrets.

Key idea

The script performs enrichment; the module metadata controls where and when that enrichment runs.

If you get stuck

Open scripts/reference.groovy and compare the hostname lookup, output lines, and targeting rule with your version.