Skip to content

Module Snippets

Module Snippets are LogicMonitor’s library of reusable Groovy code modules. These modules provide helper functions for common tasks like data emission, debugging, API calls, and vendor-specific integrations.

MethodAction
Keyboard ShortcutPress Ctrl+K, L / Cmd+K, L to open directly
Command PalettePress Cmd+Shift+P and type “Module Snippets”
Module Snippets dialog showing categorized modules and source preview

Module Snippets are fetched from your portal via a connected collector. The dialog displays all available modules grouped by category with full source code preview.

  1. Open the Module Snippets dialog

  2. Click Fetch Module Snippets to retrieve the list from your collector (first time only)

  3. Browse categories or search for a specific module

  4. Select a module to preview its full source code

  5. Choose a version if multiple are available

  6. Click Insert Import to add the loader boilerplate to your script


Modules are organized by vendor and functionality:

CategoryExamplesDescription
LogicMonitorlm.emit, lm.debug, lm.cacheCore LM helpers for data emission, debugging, and caching
Ciscocisco.meraki, cisco.aciCisco Meraki, ACI, and network device integrations
VMwarevmware.vspherevSphere, vCenter, and virtualization helpers
Arubaaruba.*Aruba network device integrations
Palo Altopaloalto.*Firewall and security integrations
NetAppnetapp.*Storage system integrations
Juniperjuniper.*Network device integrations
Protocolsproto.http, proto.snmpProtocol-specific helpers
Loaderloader.*Module loading utilities

When you click Insert Import, LMDA Composer inserts the proper module loader boilerplate at your cursor position. This is the standard pattern for loading LogicMonitor modules:

/*******************************************************************************
* Module Snippet: lm.emit
******************************************************************************/
import com.logicmonitor.common.sse.utils.GroovyScriptHelper as GSH
import com.logicmonitor.mod.Snippets
def modLoader = GSH.getInstance()._getScript("Snippets", Snippets.getLoader()).withBinding(getBinding())
def emit = modLoader.load("lm.emit", "1")
ComponentPurpose
GroovyScriptHelperLogicMonitor’s script execution helper
Snippets.getLoader()Retrieves the module loader from the collector
withBinding(getBinding())Passes the current script context to the module
modLoader.load(name, version)Loads the specified module at the given major version

The variable name is automatically derived from the module name:

Module NameVariable
lm.emitemit
cisco.merakimeraki
proto.httphttp
lm.data.topotopo

Each module can have multiple versions available:

FeatureDescription
Latest VersionShown by default with a latest badge. Recommended for new scripts.
Version SelectorUse the dropdown to select older versions for compatibility with existing scripts.
Major VersionsThe import uses the major version number only (e.g., "1" for version 1.3.0).

The right panel shows the complete source code of the selected module:

  • Full syntax highlighting with Groovy support
  • Copy button to copy the entire source to clipboard
  • Read-only editor for browsing and searching within the code
  • Version indicator showing which version you’re viewing

Module Snippets uses intelligent caching to minimize collector requests:

Cache TypeBehavior
Module ListCached after first fetch. Shows collector name and timestamp.
Source CodeCached per module+version when viewed. Shows green database icon.
  • Green database icon on a module = at least one version’s source is cached
  • Green database icon on version = that specific version is cached locally
  • Timestamp in footer shows when the list was last fetched

Click the Refresh button next to the search box to fetch an updated module list from the collector. This is useful if new modules have been added to your portal.


Once a module is loaded, you can call its methods. Each module has its own API—preview the source to see available functions.

// After loading the emit module
def emit = modLoader.load("lm.emit", "1")
// Use the emit helper to output datapoints
emit.dataPoint("cpuUsage", 75.5)
emit.dataPoint("memoryUsage", 82.3)
// After loading the meraki module
def meraki = modLoader.load("cisco.meraki", "1")
// Use Meraki API helpers
def orgs = meraki.getOrganizations(apiKey)
orgs.each { org ->
println "Organization: ${org.name}"
}

  • Use Latest Versions — Start with the latest version unless you need specific compatibility with existing scripts
  • Review Source First — Preview the module source to understand its API before importing
  • One Loader Per Script — The modLoader setup only needs to be included once per script, even if loading multiple modules
  • Check Module Updates — Periodically refresh the module list to see if newer versions are available

If you need multiple modules, include the loader setup once and call load() multiple times:

/*******************************************************************************
* Module Snippets
******************************************************************************/
import com.logicmonitor.common.sse.utils.GroovyScriptHelper as GSH
import com.logicmonitor.mod.Snippets
def modLoader = GSH.getInstance()._getScript("Snippets", Snippets.getLoader()).withBinding(getBinding())
def emit = modLoader.load("lm.emit", "1")
def http = modLoader.load("proto.http", "1")
def cache = modLoader.load("lm.cache", "1")
// Now use all three modules in your script