Mustache pickers How they help you design better dashboards

By Josip DlakaSquaredUp, Director of Engineering

According to Merriam-Webster, a mustache is 'the hair growing on the human lip' – so let's be clear that when referring to mustache pickers in this blog, we are not suggesting using tweezer-like tools to help you design hipster dashboards. Instead, we are talking about an awesome SquaredUp productivity feature called mustache picker that helps you get quick and effective results when using mustache template syntax within SquaredUp.

So, what is a mustache?

The easiest way to think of a mustache is as an expression that always returns a value. When a perspective or tile is shown for a particular object, SquaredUp automatically replaces these mustache templates with their actual values for the object being viewed and the query executed. The mustache template syntax has been an integral part of SquaredUp since version 3. 

The content of the mustache can refer to any property of the SCOM object, also known as a context that the perspective or tile applies to. If you are familiar with mustache syntax, you can specify advanced labels that can transform properties before displaying them (such as showing only a portion of the text, converting a number or reformatting a date). Perhaps, the most common use of mustache templates within SquaredUp is in custom labels.


What does the mustache picker do?

As much as mustache templates are a handy and powerful companion, trying to remember all the SCOM object properties that they can be applied to is not an easy task by any measure. This is where the mustache picker comes into play! As a productivity tool, the mustache picker allows quick property selection in mustache template format and its insertion into your custom labels and queries. When specifying a mustache for a custom label or query, clicking the {{ }} button or typing {{ brings up a helpful picker which shows all the properties of your selected resources, along with sample values.


Automatically filter to find a property quickly

To get a full list for a particular object you can also run the following PowerShell script, replacing hostname.dnsdomain with your details (e.g. server1.domain.local):

Get-SCOMClassInstance -Name "hostname.dnsdomain" | Format-List


Once the mustache helper is displayed, the list of properties will automatically filter based on what you type, allowing you to quickly find a property using a partial name or likely term. Clicking an item in the list will automatically insert that property into your label and complete the mustache. Note that SCOM object properties are case sensitive, so when manually modifying mustache content, it is essential to apply the correct property name case, i.e. displayName is not same as DisplayName. The mustache picker will automatically apply proper casing to object properties.


Scoping perspective criteria

When configuring the scope of a tile on a perspective, the Criteria option allows you to more precisely filter objects displayed in the tile by creating a specific expression to refine data returned from SCOM. This is a great way to fine-tune tile scope using available object properties and applying useful operators to achieve the exact results you want. You can find out more about how to use criteria when scoping object here.

In SquaredUp version 4.7, mustache picker has found its way to perspective scope criteria. With the addition of mustache picker to the perspective scope criteria field, it is now easier than ever to create a complex perspective scope. The mustache picker will only show when viewing the Criteria field on a perspective and not on a dashboard. This is because mustaches are processed against the perspective object, not the scope objects.


Example: filtering certificates on a server perspective

In this example, we will scope perspective tile to list all certificates (from certificate store or perhaps result of an API call). However, we would like to show only the certificates attached to a server object that perspective is showing. To do this, we can scope perspective tile to a Certificate class which would show all certificates regardless of server object displayed on the perspective. This is where scope criteria come handy as we can fine-tune scope by adding the following expression:

DisplayName LIKE '%{{displayName.split('.')[0]}}%'


This expression helps us narrow down certificates whose server display name contains the particular text. If we didn't have mustache template at our disposal, the text used to filter certificates would be static and would always show the same list of certificates regardless of the perspective server object. By using the mustache template as in the above example, we are implicitly tying this particular tile scope back to perspective scope, in this case to a perspective server object name. Note the contextual difference between DisplayName and displayName properties in this expression. DisplayName property belongs to a certificate object, while displayName belongs to the server object. Doing this, we are effectively showing only certificates attached to a server on a perspective. 


Mustache templates in other places

Mustache templates are not limited to use in just custom labels and perspective scope criteria. Beyond this, they have handy application for query parametrisation in SQL, WEB API, Azure Monitors Log, Azure Application Insights and Service Now tiles.

Queries in these tiles can be parameterised using the {{parameter}} syntax. For example, if you want to use the SCOM object ID in your SQL query, you would use: {{id}} or if you want to use the VM name of the server (a class property), you will use: {{properties.virtualMachineName}

A query like:

SELECT * FROM owner WHERE server_name = {{properties.dnsName}}


is resolved to:

SELECT * FROM owner WHERE server_name = "myserver.domain.local"


How do I get started?

If you're an existing SquaredUp for SCOM user and want to start using this new feature, you simply need to upgrade to version 4.7 (see SCOM upgrade documentation for help). Head over to SquaredUp downloads to download version 4.7.

Thank you for reading this blog post about using the Mustache Picker in Criteria Scoping functionality. Please take the time to read our blogs about version 4.7's other cool features, and stay tuned for more exciting feature blogs!