Session 02 — Single-Instance DataSource

Why this matters

This exercise connects three things: the values returned by the API, the names printed by the script, and the datapoints in the module. Keep those names in sync so LogicMonitor knows where each value belongs.

Import this first

Import module-scaffold.json using the shared import steps. The module includes the API request and the datapoint definitions. Your job is to connect the response fields to the three output lines in the script.

What to do

The /controller endpoint returns the values the module will report:

{
  "health": 1,
  "node_count": 4,
  "api_latency_ms": 42
}
  1. In the module settings, set AppliesTo to:

    hasCategory("Training_Fabric")
    

    The PropertySource checks for credentials before assigning this category. Keep the DataSource AppliesTo rule based on the category alone so later credential changes do not make the module stop applying.

  2. Look at the /controller response and find the three values we want to monitor.

  3. Complete the three marked output lines. The name before each = must match a datapoint name in the module.

  4. Review the datapoints and make sure their names, descriptions, units, and ranges make sense for the values being reported.

Check your result

  • The module collects successfully without Active Discovery.
  • All three datapoints receive values.
  • node_count matches the API response.
  • api_latency_ms changes between polls.
  • Each output line has a matching datapoint.

Discuss

Why does this module only need one instance?

The endpoint reports health and performance for the controller as a whole. It does not return a set of separate entities to discover, so one DataSource instance represents the controller.

Why does the output not need an instance ID?

There is only one controller-level instance, so the script can emit datapoint values directly. Instance IDs are needed when the same DataSource reports metrics for multiple discovered entities, as in the node exercise.

Which decisions belong in the module settings, and which belong in the script?

Use module settings for targeting, datapoint definitions, units, ranges, and graphs. Use the script to make the API request, handle the response, and emit values using the datapoint names defined in the module.

Key idea

Good module design keeps the script output and module settings telling the same story.

If you get stuck

Open scripts/reference.groovy and compare the three output lines with the datapoint names in the module.