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 from the 02-controller-single folder in your extracted workshop bundle. You can also download this session’s personalized module-scaffold.json here.
How to import this module in LogicMonitor
Use these steps whenever a session asks you to import a JSON file:
Open the LogicMonitor
Modulespage.Select
Import from file.Choose the JSON file from the matching session folder in your extracted workshop bundle, or the personalized file downloaded from that session’s page.
If LogicMonitor reports:
This module has a conflict with a module that is currently installed.
select
View data comparison, thenOverwrite installed module.Finish the import, then continue with the session’s instructions. After editing a module’s AppliesTo, script, discovery filter, or datapoint settings, click Save, enter an Update Reason describing your changes, and complete the save before testing or leaving the page.
The workshop intentionally reuses module names as the design develops. Re-importing a module replaces the earlier workshop version with the next checkpoint version.
The module includes the API request and the datapoint definitions. Your job is to read the response fields into three variables. The supplied output lines use those variables to report values to the module’s datapoints.
What to do
The /controller endpoint returns the values the module will report:
{
"health": 1,
"node_count": 4,
"api_latency_ms": 42
}
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.
Look at the example
/controllerpayload above. Identify the field for controller health, the number of nodes, and API latency.In
LAB STEP 1, replace each"Replace Me"value with the matching field from the parsedcontrollerresponse, usingcontroller.<field_name>. Complete thecontrollerHealth,nodeCount, andapiLatencyassignments. Read the values from the response rather than typing the example numbers into the script.Keep the supplied
printlnlines active. They use your variables to report the values. The name before each=must match a datapoint name in the module; it may differ from the API field name.Click Save, enter an Update Reason such as
Map controller response fields to datapoints, and complete the save.Run test collection on the saved module and confirm that all three output lines report numbers. Review the datapoints and make sure their names, descriptions, units, and ranges make sense for the values being reported. If you change any datapoint settings, save again with an Update Reason.
The starting script runs with the placeholder strings, but the datapoints need numeric values. Replace all three placeholders before checking collection results.
Check your result
- The module collects successfully without Active Discovery.
- All three datapoints receive values.
node_countmatches the API response.api_latency_mschanges 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 its variable assignments with the payload above, then check how the variables feed the output lines.