ServiceNow Pattern Designer: A Practical Guide to Defining Discovery Pattern Steps

This guide explains how to create, customise, debug, and maintain ServiceNow Discovery and Service Mapping patterns using Pattern Designer. It is designed for administrators, consultants, architects, and engineers who need to improve CI discovery, application mapping, and CMDB relationship quality.


What are ServiceNow patterns?

Patterns are reusable discovery instructions that tell ServiceNow how to identify configuration items, collect attributes, evaluate conditions, parse technical data, and create relationships. They are used across IT Operations Management to support both infrastructure discovery and application service mapping.

In practical terms, a pattern answers questions such as:

  • What type of CI is this?
  • Which process, port, registry key, file, command output, API response, or SNMP value proves what it is?
  • Which attributes should be populated on the CI?
  • Which other CIs does this CI depend on or communicate with?
  • When should discovery stop, continue, or branch based on conditions?

Pattern Designer provides the interface for building and maintaining this logic through sections, steps, variables, operations, and debugging tools.

Pattern types

ServiceNow patterns are generally created as either application patterns or infrastructure patterns.

Pattern type Purpose Used by
Application Discovers application CIs and their relationships. Application patterns can support both top-down mapping and horizontal discovery. Service Mapping and Discovery
Infrastructure Discovers host, device, or infrastructure-level CIs. Discovery

Roles and prerequisites

Before creating or editing a pattern, confirm the following prerequisites are in place:

  • The application or infrastructure component has a corresponding CI type.
  • The CI type has an appropriate classification.
  • The user has the pd_admin role for Pattern Designer activity.
  • The MID Server can reach the target host, application, API, or device.
  • Required credentials are configured and tested.
  • For domain-separated environments, the correct domain is selected.
  • The implementer has enough scripting, command-line, or platform knowledge to understand what the pattern is collecting.

High-level pattern build process

A typical pattern build follows this lifecycle:

  1. Confirm the target CI type and classification.
  2. Create or open a pattern in Pattern Designer > Discovery Patterns.
  3. Define the basic pattern attributes.
  4. Create one or more identification sections.
  5. Add discovery steps to identify the CI and populate attributes.
  6. For Service Mapping, add connection sections to discover outbound relationships.
  7. Use variables to pass values between steps.
  8. Use Debug mode to test each step.
  9. Activate the pattern.
  10. Synchronise the pattern to the MID Server.
  11. Run Discovery or Service Mapping and validate the resulting CIs and relationships.

Create or customise a pattern

To create or modify a pattern:

  1. Navigate to All > Pattern Designer > Discovery Patterns.
  2. Select New, or open an existing pattern.
  3. On the Basic tab, define the key attributes.
  4. Save the pattern.
  5. Create identification sections for incoming entry points.
  6. Define discovery steps for each section.
  7. For application patterns used by Service Mapping, create connection sections where outbound dependencies need to be discovered.
  8. Activate the pattern when testing is complete.
  9. Run Pattern Sync to MID so MID Servers receive the latest pattern version.

Basic pattern attributes

Field Guidance
Pattern type Select Application for application discovery or Service Mapping. Select Infrastructure for host or device discovery.
Name Use a clear, unique, self-explanatory name such as Apache on Unix Pattern.
CI type Select the CI class the pattern should discover.
Operating system For application patterns, choose the relevant OS or select All if the application runs across multiple operating systems.
Run Order Use when one pattern could be confused with another. For example, a more specific pattern may need to run before a generic web server pattern.
Description Explain what the pattern discovers and any important assumptions.

Identification sections

An identification section contains the logic used to recognise a CI from an incoming connection or entry point. A pattern can have multiple identification sections when different entry point types or discovery routes are possible.

Field Purpose
Name A unique name for the identification section.
Entry Point Types The incoming entry point types relevant to the CI, such as TCP or HTTP(S).
Find Process Strategy Determines how the process variable is populated. Options include listening port, target port and IP, or none.
Order Controls the order in which sections are used. The lowest number runs first.

Design guidance

  • Use separate identification sections for materially different entry point types.
  • Keep the section name descriptive, for example Identification for HTTPS TCP.
  • Place the most reliable identification logic earlier in the run order.
  • Avoid broad matching logic that could identify the wrong CI type.

Discovery steps

Discovery steps are the building blocks of a pattern. Each step performs an operation. The operation determines which fields, variables, parsing rules, or conditions must be configured.

Add a discovery step

  1. Open the relevant pattern.
  2. Select the required identification section or connection section.
  3. Add a step above or below the current step.
  4. Select an operation from the operation list.
  5. Complete the operation-specific fields.
  6. Use comments to explain complex logic.
  7. Use Debug mode to test the result.
  8. Save the section and pattern.

Common step settings

Setting Purpose
Precondition Runs the step only when specific criteria are met.
CI Attributes Displays CI attribute variables generated from the selected CI type.
Temporary Variables Stores values created and used during pattern execution.
Comments Documents the intent or reasoning behind a step.
Active Allows a step to be skipped without deleting it.

Pattern operations reference

The table below summarises common Pattern Designer operations and when to use them.

Operation Use when you need to
Change UserUse OS credentials instead of the default administrative credentials.
Unchange UserSwitch back to the default administrative credentials.
Create ConnectionDefine an outgoing application, cluster, inclusion, or storage connection in a Service Mapping connection section.
Filter TableFilter a source table into a target table based on conditions.
Find Matching URLFind the best match for an application URL from a list of candidate URLs.
Get Registry KeyQuery Windows registry values and save the result in variables or tables.
Get ProcessFind running processes by command line, working directory, parent process, port, or process ID.
Library ReferenceReuse a shared group of steps.
MatchValidate a condition and stop the pattern if the condition is not met.
Merge TableCombine two source tables into a target table.
Parse Command OutputRun a command and extract values from the output.
Parse FileExtract values from configuration files or structured data files.
Parse URLBreak a URL into protocol, host, port, path, and file components.
Parse VariableExtract structured data from an existing variable.
HTTP Get CallRetrieve and parse information from HTTP-based targets.
Cloud REST CallQuery cloud APIs for PaaS or cloud resource discovery.
Create Relation/ReferenceCreate relationships or references between discovered CIs.
Put FileTransfer a file from the MID Server to a remote system.
Run SSH Script FileRun a script or sequence of commands on Unix-based hosts.
Set Parameter ValueApply a value to a pattern parameter.
SNMP QueryQuery SNMP-enabled devices, commonly network devices and load balancers.
Transform TableAdd computed columns to an existing table.
Union TablesAppend two tables that share the same structure.
WMI QueryRun a WMI query against a Windows system.
WMI Method InvocationExecute a method using a table returned by a prior WMI query.

Working with variables

Variables are used to pass values between steps, populate CI attributes, store command output, and build relationships. Pattern Designer uses several variable types.

Variable type Description Can be modified?
Global variables Preconfigured values such as computer system, entry point, process, or pre-CMDB process. No
CI attribute variables Variables generated from the CI type definition. No
Temporary variables Variables created during pattern execution and used by specific steps. Yes

Variable syntax examples

Value type Syntax Example
Constant string Wrap in double quotes "Apache"
Variable Prefix with dollar sign $process
Container variable value Use dot notation $process.pid
Specific row in a table Reference row and column $IfTable[2].InstanceID
Current row in a table Use empty square brackets $IfTable[].InstanceID
Sequential table values from first row Use an asterisk $IfTable[*].InstanceID
Concatenated value Use plus signs $install_directory + "conf/httpd.conf"

Important: Avoid hard-coded paths where possible. Use discovered variables or parsed values so the pattern works across hosts with different installation locations.

Using Debug mode

Debug mode allows you to test pattern logic as you build it. This is one of the most important tools in Pattern Designer because it shows whether each operation returns the expected data before the pattern is activated.

Debug mode can help you:

  • Run individual pattern steps.
  • Browse processes, files, or registry entries where supported.
  • Run commands against the target host or MID Server.
  • Populate and inspect temporary variables.
  • Validate parsing logic.
  • Confirm that preconditions and Match operations behave as expected.

Activate Debug mode

  1. Open the pattern section you want to test.
  2. Select Debug Mode.
  3. Optionally select a MID Server for the session.
  4. Select the debug type:
    • Top down for Service Mapping behaviour.
    • Horizontal for Discovery behaviour.
  5. Select the entry point type.
  6. Enter the required entry point values, such as URL, host name, or IP address.
  7. Select Connect.
  8. Run Test on each step and review the temporary variables.

Make a step conditional

Preconditions control whether a step should run. Use them to prevent unnecessary processing, avoid false matches, and make a pattern more resilient across different host configurations.

Example use cases

  • Only parse a file if the file path variable is not empty.
  • Only run a Unix command when the host OS is Linux or Unix.
  • Only create a relationship when both parent and child values exist.
  • Only run a connection step in top-down discovery mode.

Configure a precondition

  1. Select the step.
  2. Enable Precondition.
  3. Enter the first value, such as a variable or string.
  4. Select an operator.
  5. Enter the second value where required.
  6. Add additional conditions if needed.
  7. Choose whether All or Any conditions must match.
  8. Choose whether the condition must evaluate to True or False.

Connection sections for Service Mapping

Connection sections are used by Service Mapping to discover outbound dependencies from an application CI. A CI can have multiple outgoing connection types, so create a separate connection section for each meaningful connection type.

Examples of connection sections include:

  • Database connections
  • Message queue connections
  • Web service calls
  • Cluster relationships
  • Storage flows
  • Included child components such as websites or deployed application artefacts

Create a connection section

  1. Open an application pattern.
  2. In the Connectivity Section, select New.
  3. Enter a meaningful section name.
  4. Save the pattern.
  5. Open the connection section.
  6. Start with a Create Connection operation.
  7. Define the connection type, entry point, attributes, target CI type, and any hidden or traffic-based settings.

Creating relationships and references

Use the Create Relation/Reference operation when a pattern needs to create relationships or references between CIs discovered within the pattern.

Key fields

Field Purpose
Parent Table The table for the parent CI in the relationship.
Child Table The table for the child CI in the relationship.
Result Table The table that stores the relationship or reference output created by the operation.
Relation Type The CMDB relationship type, such as Owns::Owned by. Ensure the direction is correct.
Reference Optional setting to create a reference between parent and child records.
Creation Criteria Determines whether the relationship is created for all records, by field matching, or by condition.

Tip: Validate the CI class relationship model before creating relationships in a pattern. Incorrect relationship direction can create confusing maps and poor CMDB data quality.

Parsing strategies

Several operations can parse data from commands, files, HTTP responses, variables, scripts, or API calls. Choose the parsing strategy based on the format of the source data.

Parsing strategy Use case
XML fileExtract values from XML content.
INI fileExtract settings from INI-style configuration files.
Properties fileParse key-value property files.
JSON fileParse JSON data using custom parsing logic.
Vertical FileParse structured text where each record spans multiple lines.
After KeywordExtract text directly following a keyword.
Command Line Java StyleRetrieve Java-style command-line parameter values.
Command Line Unix StyleRetrieve Unix-style command-line parameter values.
Position From StartExtract text based on position from the beginning of a line.
Position From EndExtract text based on position from the end of a line.
Regular ExpressionExtract values using Java regular expression syntax.
Delimited TextExtract values based on delimiters and position. This is useful for many generic text files.

Parsing best practices

  • Test parsing in Debug mode using real command output or file content.
  • Name variables clearly so later steps are easy to understand.
  • Use Terminate carefully. Only stop discovery when missing results should genuinely halt the pattern.
  • Use caching for expensive or repeated calls to reduce load on shared components.
  • Prefer robust parsing strategies over fragile string positions where source output may vary.

Operation deep dives

Get Process

Use Get Process to find running processes that identify an application. You can search by command line, working directory, parent process, port, or process ID. The result is stored in a tabular variable that can be used by later steps.

Best practice: Avoid relying only on process ID because it can change. Command line and port-based matching are usually more reliable.

Parse Command Output

Use Parse Command Output to run a command and extract values from the result. This is useful when required data is only available through a command-line utility.

Best practice: Avoid hard-coded file paths in commands. Use variables and discovered installation directories where possible.

Parse File

Use Parse File to extract values from configuration files. This is common for application discovery where ports, endpoints, cluster names, or dependencies are stored in local configuration files.

Best practice: In Debug mode, browse to the target file and validate both the path and the parsing logic.

Match

Use Match to verify that required conditions are met. If the condition is not met, discovery stops. This is useful for avoiding false-positive identification.

Best practice: Where a non-match is expected in some environments, use an expected termination message so the discovery log explains the result clearly.

Filter Table

Use Filter Table to reduce a source table to only the rows that match specific criteria. This is useful when a prior step returns a broad data set and only some rows are relevant to the CI or relationship being discovered.

Merge Table

Use Merge Table to combine data from two tables. You can merge by matching fields or conditions and choose how unmatched values are handled.

SNMP Query

Use SNMP Query for devices that expose management information through SNMP, such as load balancers or network devices. In Debug mode, browse the MIB tree, select scalar values or table columns, and test the query result.

WMI Query and WMI Method Invocation

Use WMI Query to collect data from Windows systems. Use WMI Method Invocation when a method must be executed against a table returned by a previous WMI query.

Best practice: The WMI Method Invocation step should follow the WMI Query step because it depends on the source table produced by that query.

HTTP Get Call and Cloud REST Call

Use HTTP Get Call to retrieve data from HTTP-based CIs. Use Cloud REST Call to query cloud APIs such as AWS or Microsoft Azure. Both operations can parse the response and create variables for later steps.

Best practice: Refer to the vendor API documentation for correct URL, method, body, and header syntax.

Run SSH Script File and Put File

Use Put File to transfer a file from the MID Server to the target host. Use Run SSH Script File to execute composite commands or scripts on Unix-based hosts.

Best practice: Use these operations when built-in commands are not enough or when complex host-side logic must be executed consistently.

Custom operations

Standard operations allow input parameters to be configured, but custom operations allow administrators to define the business logic and mechanism of an operation. This is useful when the discovery process requires a protocol, API, or transformation that is not covered by the base operation set.

When to create a custom operation

  • A proprietary system requires a custom query format.
  • A vendor API does not fit an existing operation.
  • Complex MID Server-side logic needs to be reused across patterns.
  • Input parameters need custom validation.

Custom operation design notes

  • Create parameters using a dollar sign prefix, such as $fileName.
  • Use the execution context object to access information from pattern execution.
  • Return operation results using the expected return variable.
  • Define operation parameters in the related list after writing the script.
  • Use validation regex where parameter input must conform to a required format.

Testing and validation checklist

Before activating a pattern, validate it with the following checklist:

  • Pattern name and description are clear.
  • CI type is correct.
  • Run order is configured if there is a risk of pattern confusion.
  • Identification sections are ordered correctly.
  • Entry point types match the expected discovery route.
  • Process classification is enabled where appropriate.
  • Variables are named consistently and clearly.
  • No unnecessary hard-coded paths are used.
  • Each step has been tested in Debug mode.
  • Preconditions are used to avoid invalid execution paths.
  • Match operations stop discovery only when appropriate.
  • Parsing strategies are resilient against realistic output variations.
  • Relationships and references follow the CMDB relationship model.
  • Connection sections create the expected outbound dependencies.
  • Credentials work from the selected MID Server.
  • The pattern has been activated.
  • The updated patterns have been synchronised to MID Servers.

Troubleshooting guide

Symptom Likely cause Recommended action
CI is not identified Entry point, process strategy, or Match condition is incorrect. Run the identification section in Debug mode and inspect the process and entry point variables.
Wrong CI type is discovered Pattern is too broad or run order is incorrect. Refine Match logic and configure Run Order so more specific patterns run first.
Step returns no data Command, file path, registry key, query, or credential is incorrect. Use Debug mode and Command Prompt to validate the command or source path manually.
Variables are empty Parsing strategy is incorrect or source data format is different than expected. Review the raw output and adjust parsing rules.
Discovery stops unexpectedly Terminate option or Match operation is stopping the pattern. Review Match steps, Terminate settings, and expected termination messages.
Connections do not appear in Service Mapping Connection section is missing or Create Connection fields are incomplete. Validate connection type, entry point, target CI type, and connection attributes.
Relationships are incorrect Parent-child direction or relationship type is wrong. Check CI Class Manager and validate relationship direction before updating the pattern.
Pattern change is not taking effect Pattern was not activated or synced to the MID Server. Activate the pattern and run Pattern Sync to MID.

Recommended implementation approach

For a reliable implementation, build patterns incrementally rather than attempting to configure the full pattern in one pass.

  1. Start with identification. Confirm that the pattern correctly recognises the CI.
  2. Populate core attributes. Add only the fields needed to uniquely identify and describe the CI.
  3. Add parsing logic. Extract additional details from files, commands, APIs, registry keys, or SNMP.
  4. Add relationships. Create references and relationships once parent and child values are reliable.
  5. Add connections. For Service Mapping, define outbound dependencies after identification is stable.
  6. Optimise and harden. Add preconditions, caching, expected terminations, and comments.
  7. Validate in multiple environments. Test across hosts with different installation paths, versions, and configurations.

Governance and maintainability

Patterns become part of the operational foundation for CMDB and service visibility. Treat them as maintained technical assets.

Recommended governance practices

  • Use a naming convention for custom patterns, sections, steps, and variables.
  • Document why each complex step exists.
  • Record assumptions about OS, application version, path structure, or API format.
  • Keep custom operations to a minimum and reuse them where appropriate.
  • Test patterns after upgrades or application version changes.
  • Review discovery logs regularly for recurring expected and unexpected terminations.
  • Align relationships with the approved CMDB class and relationship model.

Quick reference: what to use when

Requirement Recommended operation
Find a running processGet Process
Read a Windows registry valueGet Registry Key
Run a command and extract outputParse Command Output
Read an application configuration fileParse File
Break down a URLParse URL
Extract values from an existing variableParse Variable
Query an HTTP endpointHTTP Get Call
Query a cloud APICloud REST Call
Query a network device or load balancerSNMP Query
Query a Windows systemWMI Query
Create a dependency between CIsCreate Relation/Reference
Create an outbound Service Mapping dependencyCreate Connection
Stop discovery when conditions are not metMatch
Run a step only in certain conditionsPrecondition