References and Expressions

Connectors use references to wire data across sections and runtime contexts.

When References Are Resolved

Family Syntax Resolved
Load-time substitutions ${constant::}, ${var::} Inlined once, when the connector is parsed and loaded.
Job-time references ${source::}, ${file::}, ${translation::}, $1/$2 column refs, ${attribute::}, ${protocol::}, ${resource.attribute::}, ${awk::} Evaluated during job execution — e.g. ${source::...} yields the referenced source's current output for that cycle. Relative ${source::} paths are normalized to their absolute form at load time.
Runtime credential macros %{USERNAME}, %{PASSWORD}, %{BASIC_AUTH_BASE64}, … At execution time, per request, from the resource's configured credentials.

Source References

Use ${source::...} to reference a source output table.

leftTable: ${source::monitors.network.discovery.sources.ports}
rightTable: ${source::monitors.network.discovery.sources.aliases}

Relative vs Absolute

  • Prefer absolute paths when crossing monitor/job boundaries.
  • Relative forms are acceptable for local same-job references.

Column and Entry References

Column references are positional and 1-based:

attributes:
  id: $1
  name: $2

These positions refer to the current table shape at that pipeline stage.

  • $1 = first column of the current row
  • $2 = second column of the current row
  • $3 = third column of the current row

If computes add, remove, or reorder columns, these references must be updated accordingly.

The example below shows the same row as a table and as serialized text:

Table

Table

$1 $2 $3
disk01 SSD ok

In this row, $1 is disk01, $2 is SSD, and $3 is ok.

Serialized Text

Serialized Text

disk01;SSD;ok

File References

Use ${file::<relative-path>} for embedded scripts/files in connector folder.

script: ${file::fan-info.awk}
commandLine: /bin/sh ${file::collector.sh}

Translation References

Use ${translation::<tableName>} with translate/arrayTranslate/perBitTranslation.

translationTable: ${translation::SensorStatusTable}

Constant References

Use ${constant::<constantName>} for reusable literal values.

hw.parent.id: ${constant::_DEVICE_ID}

Connector Variable References

Use ${var::<variableName>} for user-configurable values declared under connector.variables (each with a description and a defaultValue):

commandLine: /usr/bin/ps -e -o comm,args | grep -E "${var::matchName}"

Variables are substituted at connector load time, from the defaultValue or from the user's additionalConnectors configuration. Always declare a defaultValue: with neither a default nor a configured value, the literal ${var::name} survives unresolved. See Reuse and Configuration[1] for declaration and configuration details.

Protocol and Resource Attribute References

value: ${protocol::jmx.port}
header: "Authorization: Bearer ${resource.attribute::api.token}"
  • ${protocol::<type>.<property>} accesses configured protocol data.
  • ${resource.attribute::<key>} accesses host/resource-level attributes.

Mono-Instance Attribute References

Use ${attribute::<key>} in mono-instance contexts: monoInstance collect jobs run once per discovered instance, and this reference injects that instance's attributes (as mapped during discovery) into the source. See Monitors and Jobs[2].

commandLine: /bin/sh ${file::detail.sh} ${attribute::id}

Inline AWK Expressions

Use ${awk::...} for concise expression-level formatting.

name: ${awk::sprintf("%s (%s)", $2, $3)}

References in Compute Attributes

Format

A compute attribute can reference:

A resource attribute

${resource.attribute::<attribute-key>}

A protocol property

${protocol::<protocol-type>.<property>}

A source content

${source::<source-name>}

Examples

Replace a value with a protocol property

The following example replaces the value PORT in column 1 with the HTTP port configured for the protocol:

sources:
  source(1):
    type: http
    path: /api/device
    computes:
      - type: replace
        column: 1
        existingValue: "PORT"
        newValue: ${protocol::http.port}

Append content from another source

The following example appends the content of another source to the value in column 1:

sources:
  source(1):
    type: http
    path: /api/device
    computes:
      - type: append
        column: 1
        value: " - ${source::monitors.enclosure.simple.sources.source_discovery}"

Reference a resource attribute

The following example keeps only the lines whose value in column 3 matches the URL built from the host.name resource attribute:

sources:
  source(1):
    type: http
    path: /api/hosts
    computes:
      - type: keepOnlyMatchingLines
        column: 3
        valueList: "https://${resource.attribute::host.name}"

Runtime Credential Macros (%{...})

%{...} macros inject the resource's configured credentials at execution time. They work in HTTP sources and criteria (url, path, header, body, authenticationToken) and in command lines (SSH/local/WMI):

Macro Resolves to
%{USERNAME} The configured username.
%{PASSWORD} The configured password.
%{HOSTNAME} The hostname of the resource being monitored.
%{AUTHENTICATIONTOKEN} The configured authentication token.
%{PASSWORD_BASE64} Base64-encoded password.
%{BASIC_AUTH_BASE64} Base64 of username:password — ready for Authorization: Basic %{BASIC_AUTH_BASE64}.
%{SHA256_AUTH} SHA-256 hex digest of the authentication token.
header: "Authorization: Basic %{BASIC_AUTH_BASE64}"

To escape the injected value for the surrounding syntax, wrap the macro as %{esc(TYPE)::MACRO} where TYPE is one of json, xml, url, regex, windows, cmd, powershell, linux, bash, sql:

body: '{ "user": "%{esc(json)::USERNAME}", "password": "%{esc(json)::PASSWORD}" }'
Warning

Macro names must be written in full and in uppercase. A misspelled or unknown macro (e.g. %{BASICAUTH}) is silently replaced with an empty string. Token-based macros (%{AUTHENTICATIONTOKEN}, %{SHA256_AUTH}) resolve to empty in command lines.

The related %{SUDO:command} macro (command elevation) is tied to the connector's sudoCommands list — see Reuse and Configuration[1].

Serialization Side Effects (Advanced but Important)

Tables are internally list-of-list-of-strings, but many transformations pass through semicolon-separated serialized rows. Because semicolon is the column separator, appending ;value to a column payload can effectively create a new materialized column once the row is re-parsed.

Example:

# original row
node01;ClusterA;ok

# after append on column 2 with value ';PowerStore'
node01;ClusterA;PowerStore;ok

Use this behavior intentionally and carefully; it is powerful but easy to misuse.

Tip

Keep inline AWK expressions short. Move heavier logic into AWK compute scripts for maintainability.

Common Mistakes

  • broken source paths when refactoring monitor names
  • using relative source references where absolute references are required
  • mixing positional columns after compute pipeline changes without remapping
  • embedding secrets directly instead of protocol/resource references
references expressions source reference translation reference protocol reference metricshub community connector hardware system
Links:
  • [1] reuse-and-configuration.html
  • [2] monitors-and-jobs.html
Searching...
No results.