Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

maheshkhatal
Mega Sage
Mega Sage

🧩 ServiceNow Discovery: Using Patterns 

 

In the previous article, we explored how to discover additional information about a Computer CI using the traditional Probes and Sensors method in ServiceNow. 🖥
Now, it’s time to move to the next evolution of Discovery — using Patterns! 🚀

 

What Are Discovery Patterns?

Patterns, much like Probes and Sensors, are designed to collect data from a host, process it, and update the CMDB with meaningful configuration information.

However, Patterns differ in several key ways:
🧠 They are written in Neebula Discovery Language (NDL) — not JavaScript.
⚙️ They operate in the later stages of the Horizontal Discovery process.
🎯 They provide a visual and modular way to define Discovery logic using the Pattern Designer.

In short — while Probes and Sensors are script-driven 🧾, Patterns are flow-driven, making Discovery more intuitive, reusable, and maintainable.

 

🔍 How Patterns Differ from Probes & Sensors

Let’s make the difference crystal clear 👇

Aspect

Probes & Sensors

Patterns

Language

JavaScript

Neebula Discovery Language (NDL)

Execution Stage

Early / Mid (Classification & Exploration)

Later (Horizontal Discovery)

Interface

Code-based

Visual Pattern Designer

Purpose

Collect and process data

Collect, process, and relate CIs

Flexibility

Custom scripting

Drag-and-drop logic blocks

Debugging

ECC Queue logs

Built-in Pattern Debugger

 

🧠 Why Use Patterns?

Patterns make Discovery smarter and simpler:

🔹 They provide a graphical interface to design and test Discovery logic.

🔹 They reduce script maintenance, since you can modify flow logic visually.

🔹 They are context-aware, automatically understanding which CI is being discovered.

🔹 They help build relationships between CIs, forming the foundation for Service Mapping.

🧪 Before You Start Building Patterns

Before you dive into writing your first Pattern, it’s important to know what you’re aiming to discover 🎯.
The type of device or application determines how you’ll communicate with it — whether via SSH, WMI, SNMP, HTTP, or database connections.

💬 In other words, you must understand the “language” your target system 

⚙️ Discovery vs. Service Mapping — Know the Context

While Discovery Patterns focus on populating data into the CMDB,
Service Mapping Patterns are primarily designed to build relationships between CIs across layers of a business service. 🌐

The syntax and design logic are similar — but their goals differ:

  • Discovery Patterns = populate and enrich CI data
  • Service Mapping Patterns = define application dependencies

Navigate to Discovery Definition -> Windows  and Open Windows record 

 

 

maheshkhatal_0-1764438595303.png

 

 

maheshkhatal_1-1764438603837.png

 

 

🪟 As you can see, the Windows Classifier is configured to launch the Pattern named Windows - OS Desktop during the Discovery process.

🔍 In our earlier Discovery run, this same Pattern was automatically triggered during the Exploration phase, where it collected detailed configuration data about the Windows system.

📘 You can verify this by navigating to the Discovery Log tab — it shows exactly when and how the Windows - OS Desktop Pattern was executed.

📸 Refer to the screenshot below for a visual confirmation.

 

 

maheshkhatal_2-1764438624312.png

 

🧩 Before we begin designing the Pattern, let’s first create a new field to store additional data — for example, the IPv6 Address of the target machine 🌐.

You can choose to reuse the ‘Some Extra Info’ field that we created earlier during the Probe/Sensor demo, but it’s recommended to keep them separate to avoid any data conflicts between Pattern-based Discovery and Probe/Sensor-based Discovery ⚙️.

🛠️ In this example, I’ve created a new field on the Computer CI table named IPv6 Address (u_ipv6_address). This field will hold the IPv6 data collected by our Pattern during Discovery.

 

 

maheshkhatal_3-1764438634940.png

 

🚀 Now we’re going to populate this field using a Discovery Pattern instead of Probes and Sensors.

You can access the Pattern in two ways:

 

  • 🧭 From the Windows Classifier record (if it’s already open), or
  • 🧩 Navigate to Pattern Designer → Discovery Patterns, and locate the Windows OS – Desktop pattern.

Once you’ve opened the pattern, scroll down to the Extension Sections area.
Create a new section named Extra Windows Info, then click Save, and open this new extension section to begin adding your pattern logic. 💡

 

maheshkhatal_4-1764438655311.png

maheshkhatal_5-1764438681474.png

 

🖥️ Enter the host name or IP address of the target machine and click Connect.
Once the connection is established, the Debug indicator will turn green — confirming that you’re successfully connected to the host.

Note: If you’re connecting for the first time, it may take a little longer to establish the connection, as initial authentication and setup steps are performed.

 

maheshkhatal_6-1764438723114.png

 

🔗 Once the connection is established, the connected host will be displayed in the list below.
After verifying the connection, simply click Close to proceed.

 

maheshkhatal_7-1764438745131.png

maheshkhatal_8-1764438775297.png

 

Create a Step called Get Windows Command Info.

Configure the details as shown below

maheshkhatal_9-1764438786574.png

 

 

⚙️ Click Run Command, and you’ll see the command output displayed in the Output panel 🖥️.

Next, use the Delimited Text Parsing technique along with the Include Lines field to extract the specific data you want — in this case, the IPv6 address 🌐.

📋 Then, in the Variables section, click Table and specify the following:

 

  • Table Name: cmdb_ci_computer
  • Field Name: u_ipv6_address

 

💡 This configuration tells the Pattern to extract the IPv6 address from the command output and populate it into the u_ipv6_address field of the Computer CI record in the CMDB.

Finally, click the Test button 🧪 — you should see the IPv6 Address value successfully set on the target CI.

maheshkhatal_10-1764438843997.png

 

🎯 Our job is now complete! When you re-run the Discovery, the Horizontal Discovery Probe will automatically trigger the Windows - OS Desktop pattern during the Exploration phase. 🧠

Within this pattern, the Extension Section we created will execute and populate the IPv6 Address field (u_ipv6_address) in the Computer CI record. 🌐

🪄 Once the Discovery process finishes, navigate to the Discovery Logs and open the entry for the Windows - OS Desktop pattern.
Here, you’ll be able to see your Extension Section in action — along with the IPv6 Address value successfully captured and set in the CMDB.

📎 Click the “Here” link to view the log details and confirm that the value was updated correctly.

 

maheshkhatal_11-1764438866126.png

 

maheshkhatal_12-1764438889812.png

 

Go to updated CI and find that IP6 Address filed is populated successfully.

maheshkhatal_13-1764438900125.png

 

 

🎉 Congratulations! You’ve successfully performed Discovery using Patterns — a modern, visual, and efficient approach to identifying and enriching Configuration Items in the CMDB.

Unlike Probes and Sensors, which rely on JavaScript scripting, Patterns offer a graphical, modular, and declarative way to define Discovery logic.
They simplify maintenance, improve visibility, and allow you to extend existing Discovery flows without touching complex code. 🧩

By leveraging the Pattern Designer, you not only collected the IPv6 Address of the Windows machine but also experienced how Patterns seamlessly integrate with the Discovery lifecycle — from Classification → Exploration → CMDB Update. ⚙️

 

 

Version history
Last update:
33m ago
Updated by:
Contributors