Message Editing

This feature allows you to fully customize the messages that are generated by SentryOne. Add or remove information, change how the information is formatted, and change the order that the information is displayed. 

To access the Message Editor, select the Condition that you'd like to change in the Conditions pane (View > Conditions), select the Message tab on the bottom of the pane, and then select Edit.

SentryOne Conditions pane Message tab

How does customization work?

Understanding XML

To understand how customizing messages works in SentryOne, it's important to understand the following about XML:

  • The format of the XML that describes the format of the messages
  • The elements added to the XML
  • How these elements are related

At the root level (the Message element), each message formatted XML document (called a Template) uses the Imports attribute to inherit from another template. That template inherits from another template and so on, creating a chain of Parent/Child relationships. These chains are used extensively throughout the Template files to reduce the repetition of reused elements. The middle pane of Message Editor combines these chains into the single, complete XML document that's used to generate the final message. Sometimes the finale Template, sometimes referred to as a Leaf Template, has very little information because almost all of the XML is in the inherited Templates. In these cases, it can be useful to look at the complete XML to understand what's in the message and how to change it.

Inside the root message element, there are three parts to a template: 

  • the Format element
  • the TokenSets element
  • the Body element

See the following table for more information about each element and its contents.

Element NameElement contents
Format elementContains definitions for section, item, and token styles.
tokenSet elementContains a list of all of the tokenSets associated with the Template.
Body elementContains all of the sections, items and tokens that describe the message format itself.


Note:  All of these elements are combined with their imported parent elements during the import process so that inheritance is used.

The Format element is a list of style definitions that are referred to in the body of the Template. Leaf templates often don’t contain a Format element because they rely on a group of standard inherited styles. Add a format element if one doesn't exist or add to an existing one to define new styles. Only one format element is allowed per template.

The tokenSets element is a list of all of the tokenSets associated with a Template. A tokenSet is a logical grouping of tokens that exists in SentryOne. You can't add tokenSets to messages because the data for the tokens in the tokenSet needs to be created and assigned in the program. A list of all of the tokens in the tokenSets is available in the Message Editor. Only one tokenSets element is allowed per template.

The Body element describes all of the things that a message is made of. These things can be categorized as items (and things that inherit from items) and sections, which are groups of items. Only one body element is allowed per Template.

Items and sections

An item is the base element in the body section. TokenItems, textItems, breakItems and blankLineItems are all specialized types of items. See the following table for more information about these items:

Item/Section NameItem/Section Description
TokenItemsSpecial items that represent a name/value pair. A common example in SentryOne messages is [Condition]: SQL Server: Blocking SQL. The name (Condition) is a description of the value (SQL Server: Blocking SQL). The value for these tokenItems is set during the program execution.
MultiTokenItemsSpecial tokenItems that convert one or more tokenItems into a single token with specialized formatting. They have a converter attribute that's the name of a registered converter, and they reference one or more tokenItems.
TextItemsA special type of item that displays a literal text value.
BreakItemsA specialized textItem with pre-set text for ease of use. The breakItem takes whatever the current section format break is and places that in the message.
blankLineItemsA specialized textItem with pre-set text for ease of use. The blankLineItem inserts a blank line in a message.
section elementA way to group the above items. Sections can contain other sections. Nested sections are indented using the indentStyle from the current sectionStyle.

Item and Section Attributes

All items have the following attributes:

Item/Section AttributeDescription
idA unique string identifying the item.
visibleA boolean that determines if the item is visible in the message.
beforeThe id of the item, token or section that this item should be placed before.
afterThe id of the item, token or section that this item should be placed after.
requiresThe id of an item, token or section that must be visible for this item to be visible.
indentA boolean that determines if the item should be indented.
itemStyleIdThe id of the itemStyle (format) that should be used for this item.

TextItems have one additional attribute:

TextItem AttributeDescription
textThe text that will be displayed in the final message.

TokenItems have additional attributes:

TokenItem AttributesDescription
nameThe token name to be displayed in the message. If none is assigned, a default name based on the item id is displayed.
hideIfNoValueA boolean that when set to true, hides the token if no value is assigned.
tokenItemStyleIdThe id of the tokenStyle (format) that should be used for this token.

MultiTokenItems have all of the tokenItem attributes plus an additional attribute and element:

Attribute:

MultiTokenItems Addittional AttributeDescription
converterThe name of the registered converter.

Element:

MultiTokenItems Addittional ElementDescription
tokenAn element that represents a token to be passed to the converter. It has a single attribute—id—that's the id of a valid token. MultiTokenItems may have one or more token elements.

Sections have similar attributes to items:

Section AttributeDescription
idA unique string identifying the item.
visibleA boolean that determines if the item is visible in the message.
beforeThe id of the item, token or section that this item should be placed before.
afterThe id of the item, token or section that this item should be placed after.
requiresThe id of an item, token or section that must be visible for this item to be visible.
indentA boolean that determines if the item should be indented.
sectionStyleIdThe id of the sectionStyle that should be used for this section.
itemStyleIdThe id of the itemStyle (format) that should be used for this item.
tokenItemStyleIdThe id of the tokenStyle (format) that should be used for this token.

Styles

Styles are a very important part of how message customization works. There are three types of styles:

  • Section styles
  • Item styles
  • Token styles

Note:  Styles are defined in the format section of the XML. The styles are then referenced by their IDs in the sections, items and tokens. These styles use format strings to identify how to change an item, token or section when the message is built. The format strings use keywords to represent the data so you can add formatting content around them.

For example, token styles use %itemname% to represent the name of a token and %itemvalue% to represent its value. To create the finished message value of [Condition]: SQL Server: Blocking SQL, use the format string: [%itemname%]: %itemvalue%. If the desired finished value is Condition-->SQL Server: Blocking SQL the format string needs to be changed to %itemname%-->%itemvalue%. You can also add whitespace characters such as newline (\r\n) or tab (\t).

Style Attributes

Section styles (sectionStyle elements) have three attributes:

Section Style AttributeDescriptionKeywordExample
idA unique string identifying them.NANA
indentStyleA format string to determine how a nested section should be indented.  %sectionitem% represents each item in the section.%sectionitem% places four spaces before each item in the section.
formatStyleA format string to determine how a section should be formatted.%sectionitems% represents the entire section as a whole.%sectionitems% ----------\r\n places a line of dashes as a break after the section.

Item styles (itemStyle elements) have two attributes:

Item Style AttributeDescriptionKeywordExample
idA unique string identifying this style.NANA
indentStyleA format string to determine how an item should be indented (when the indent attribute is set to true).  %item% represents the item.\t%item% places a tab character in front of the item.

Token styles (tokenItemStyle elements) extend item styles and have three additional attributes:

Token style AttributeDescriptionKeywordExample
formatStyleA format string to determine how a token should be formatted.%itemname% represents the token name; %itemvalue% represents the value of the token.[%itemname%]: %itemvalue% creates the standard "[Name]: Value" token style.
itemStyleIdThe id of the itemStyle this tokenStyle references. Because a token is an item underneath, the format needs to specify the item style as well.NANA
itemValueStyleA .NET format string for the item value. This string gives you the ability to format the token value itself using .NET format string which is useful for date or number formatting.  NA0.## formats a decimal value to a maximum of two decimal places.

Customizing a Message

SentryOne Message Editor

Sections of the Message Editor

Message Editor SectionDescriptionImage
Tokens pane Displays a list of tokens that are available for use in the message.SentryOne Message Editor Tokens pane
Text Items paneContains various XML elements that can be copied and pasted into the Message Level XML pane to add custom text and line breaks to the message.SentryOne Message Editor Text Items pane
Formats paneContains XML attributes that can be used with an element to adjust the formatting of the element.SentryOne Message Editor Formats pane
Message Level XML paneThe Message Level XML pane is where you can edit the message. Changes made in this pane are reflected in the Complete XML and Message Sample panes.SentryOne Message Editor Message Level XML pane
Complete XML paneDisplays the final product of the template displayed in the Message Level XML pane plus all of the templates that are imported by it. You can use this pane as guideline when making changes to the Message Level XML.SentryOne Message Editor Complete XML pane
Message Sample pane Displays a mock-up of what the complete XML becomes.SentryOne Message Editor Message Sample pane
Conditions That Use Template paneDisplays a list of conditions that are currently using the template you're editing. The check boxes give you the ability to quickly save a new template and apply it to multiple conditions.SentryOne Message Editor Conditions That Use Template pane

Editing a Message

Adding Additional Information

New items can be added inside or outside of a section. Available nodes are listed in the Tokens pane and can be copy-and-pasted, highlighted-and-dragged, or typed directly into the editor. Set the before or after attributes to place the item in a particular spot in the message.

Removing or Hiding an Item

If an item is only in the Message Level XML, you can delete that node from the XML. If the item is in an imported template, you can hide the item in the finished message by setting the visible attribute to False. You can also set the hideIfNoValue attribute to True which hides the item if there's no value assigned to it.

Moving an Item

Items are displayed in the final message as they are placed in the XML, top to bottom, unless before or after attributes are placed on the items or sections. 

Note:  This quickly gets confusing with the inheritance chain, so the easiest way to move an item is to set its before or after attribute.

Adding, Hiding, or Moving a Section 

Sections are a lot like items (by design). Add one by typing in a new <section></section>, hide one by setting its visible property to False and move one by setting its before or after attribute.

Changing a Token Name

Change the displayed name of a token by setting its name property.

Indenting an Item

Indent an item by setting the indent attribute for an item to true.

Note:  All items have an inherited default indent style.

For custom indents, create a new itemStyle with your custom indent and apply that style to a body, section or item.

Formatting a Token

Each template has several inherited token styles that are listed in the Formats pane of the Message Editor. Copy-and-paste or highlight-and-drag these attributes into the body, section or token item. For custom formatting, define a new tokenItemStyle in the Format section and set the formatStyle string to suit your needs. Reference this new style by id in the attributes of the body, section or tokenItem.

Example:

tokenItemStyle definition to get a token like {Condition}-->Name of Condition:

<tokenItemStyle id="NewStyle" itemStyleId="defaultItem" formatStyle="{%itemname%}-->%itemvalue%"/>

Formatting a Section

Each template has at least one inherited section style that's listed in the Formats pane of the Message Editor. Copy-and-paste or highlight-and-drag the attribute into the body or section. For custom formatting, define a new sectionStyle in the Format section and set the formatStyle string to suit your needs. Reference this new style by id in the attributes of the body or section.

Example section:

Style definition to replace the standard line of dashes after a section with a line of equal signs:

<sectionStyle id="NewSectionStyle" formatStyle="%sectionitems%=======================\r\n" indentStyle=" %sectionitem%" />

Formatting a Token Value

Define a .NET format string to format a token value itself. This is especially useful in formatting dates and number values. Define a new tokenItemStyle in the format section, set up the formatStyle and itemStyleId attributes (or copy them from another style) and then set the itemValueStyle to a .NET format string.