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_adminrole 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:
- Confirm the target CI type and classification.
- Create or open a pattern in Pattern Designer > Discovery Patterns.
- Define the basic pattern attributes.
- Create one or more identification sections.
- Add discovery steps to identify the CI and populate attributes.
- For Service Mapping, add connection sections to discover outbound relationships.
- Use variables to pass values between steps.
- Use Debug mode to test each step.
- Activate the pattern.
- Synchronise the pattern to the MID Server.
- Run Discovery or Service Mapping and validate the resulting CIs and relationships.
Create or customise a pattern
To create or modify a pattern:
- Navigate to All > Pattern Designer > Discovery Patterns.
- Select New, or open an existing pattern.
- On the Basic tab, define the key attributes.
- Save the pattern.
- Create identification sections for incoming entry points.
- Define discovery steps for each section.
- For application patterns used by Service Mapping, create connection sections where outbound dependencies need to be discovered.
- Activate the pattern when testing is complete.
- 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
- Open the relevant pattern.
- Select the required identification section or connection section.
- Add a step above or below the current step.
- Select an operation from the operation list.
- Complete the operation-specific fields.
- Use comments to explain complex logic.
- Use Debug mode to test the result.
- 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 User | Use OS credentials instead of the default administrative credentials. |
| Unchange User | Switch back to the default administrative credentials. |
| Create Connection | Define an outgoing application, cluster, inclusion, or storage connection in a Service Mapping connection section. |
| Filter Table | Filter a source table into a target table based on conditions. |
| Find Matching URL | Find the best match for an application URL from a list of candidate URLs. |
| Get Registry Key | Query Windows registry values and save the result in variables or tables. |
| Get Process | Find running processes by command line, working directory, parent process, port, or process ID. |
| Library Reference | Reuse a shared group of steps. |
| Match | Validate a condition and stop the pattern if the condition is not met. |
| Merge Table | Combine two source tables into a target table. |
| Parse Command Output | Run a command and extract values from the output. |
| Parse File | Extract values from configuration files or structured data files. |
| Parse URL | Break a URL into protocol, host, port, path, and file components. |
| Parse Variable | Extract structured data from an existing variable. |
| HTTP Get Call | Retrieve and parse information from HTTP-based targets. |
| Cloud REST Call | Query cloud APIs for PaaS or cloud resource discovery. |
| Create Relation/Reference | Create relationships or references between discovered CIs. |
| Put File | Transfer a file from the MID Server to a remote system. |
| Run SSH Script File | Run a script or sequence of commands on Unix-based hosts. |
| Set Parameter Value | Apply a value to a pattern parameter. |
| SNMP Query | Query SNMP-enabled devices, commonly network devices and load balancers. |
| Transform Table | Add computed columns to an existing table. |
| Union Tables | Append two tables that share the same structure. |
| WMI Query | Run a WMI query against a Windows system. |
| WMI Method Invocation | Execute 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
- Open the pattern section you want to test.
- Select Debug Mode.
- Optionally select a MID Server for the session.
- Select the debug type:
- Top down for Service Mapping behaviour.
- Horizontal for Discovery behaviour.
- Select the entry point type.
- Enter the required entry point values, such as URL, host name, or IP address.
- Select Connect.
- 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
- Select the step.
- Enable Precondition.
- Enter the first value, such as a variable or string.
- Select an operator.
- Enter the second value where required.
- Add additional conditions if needed.
- Choose whether All or Any conditions must match.
- 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
- Open an application pattern.
- In the Connectivity Section, select New.
- Enter a meaningful section name.
- Save the pattern.
- Open the connection section.
- Start with a Create Connection operation.
- 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 file | Extract values from XML content. |
| INI file | Extract settings from INI-style configuration files. |
| Properties file | Parse key-value property files. |
| JSON file | Parse JSON data using custom parsing logic. |
| Vertical File | Parse structured text where each record spans multiple lines. |
| After Keyword | Extract text directly following a keyword. |
| Command Line Java Style | Retrieve Java-style command-line parameter values. |
| Command Line Unix Style | Retrieve Unix-style command-line parameter values. |
| Position From Start | Extract text based on position from the beginning of a line. |
| Position From End | Extract text based on position from the end of a line. |
| Regular Expression | Extract values using Java regular expression syntax. |
| Delimited Text | Extract 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.
- Start with identification. Confirm that the pattern correctly recognises the CI.
- Populate core attributes. Add only the fields needed to uniquely identify and describe the CI.
- Add parsing logic. Extract additional details from files, commands, APIs, registry keys, or SNMP.
- Add relationships. Create references and relationships once parent and child values are reliable.
- Add connections. For Service Mapping, define outbound dependencies after identification is stable.
- Optimise and harden. Add preconditions, caching, expected terminations, and comments.
- 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 process | Get Process |
| Read a Windows registry value | Get Registry Key |
| Run a command and extract output | Parse Command Output |
| Read an application configuration file | Parse File |
| Break down a URL | Parse URL |
| Extract values from an existing variable | Parse Variable |
| Query an HTTP endpoint | HTTP Get Call |
| Query a cloud API | Cloud REST Call |
| Query a network device or load balancer | SNMP Query |
| Query a Windows system | WMI Query |
| Create a dependency between CIs | Create Relation/Reference |
| Create an outbound Service Mapping dependency | Create Connection |
| Stop discovery when conditions are not met | Match |
| Run a step only in certain conditions | Precondition |