Create monitors
StackState Self-hosted v5.0.x
This page describes StackState version 5.0.
Overview
Monitors can be attached to any number of elements in the StackState topology to calculate a health state based on 4T data. Each monitor consists of a monitor definition and a monitor function. Monitors are created and managed by StackPacks, you can also create custom monitors and monitor functions outside of a StackPack without having to modify any configuration.
The example on this page creates a CPU metric monitor using an example monitor function.
➡️ Learn more about the STJ file format used for monitor definitions
Example - CPU metric monitor
To create the example CPU metric custom monitor in StackState we will:
Create a new STJ import file
You can place multiple monitors on the same STJ file. You can also add other node types on the same import file.
➡️ Learn more about the STJ file format used for monitor definitions
Populate the monitor node
A monitor node of type Monitor
needs to be added to the import file. This type of node is supported in API version 1.0.39 and above. The required fields are the name
, identifier
and description
. The identifier
should be a value that uniquely identifies this specific monitor definition. intervalSeconds
, function
and arguments
determine what validation rule and how often it is run. An optional parameter of remediationHint
can be specified - it is a Markdown-encoded instruction of what to do if this monitor produces an unhealthy health state. It is displayed on the interface together with the monitor result panel.
Configuring the monitor function is best done by utilizing the get
helper function paired with the identifier
of the function itself. In this example the function is named Metric above threshold
and its identifier is urn:system:default:monitor-function:metric-above-threshold
.
The invocation of the get
helper function will automatically resolve to the ID of the desired function during import time.
➡️ Learn more about the STJ file format used for monitor definitions
Populate the parameters of the monitor function invocation
The parameters are different for each monitor function. In the case of Metric above threshold
we need to populate threshold
, metrics
and topologyIdentifierPattern
:
Similar to the function
, parameters can be referred to by utilizing the get
helper function.
For further details of defining arguments in the monitor definition and how to work with commonly used parameters such as a metrics query or topology identifier, see monitor STJ file format > Arguments.
Apply the newly created monitor in StackState
This can be achieved by using the dedicated StackState CLI command:
⚠️ PLEASE NOTE - from StackState v5.0, the old sts
CLI has been renamed to stac
and there is a new sts
CLI. The command(s) provided here are for use with the new sts
CLI.
An alternative way is to include the newly created monitor in a custom StackPack and installing it.
Verify that your newly created monitor is working correctly
You can check if your monitor is working correctly by invoking the CLI command:
⚠️ PLEASE NOTE - from StackState v5.0, the old sts
CLI has been renamed to stac
and there is a new sts
CLI. The command(s) provided here are for use with the new sts
CLI.
You can also preview the results it generates by invoking the CLI command:
⚠️ PLEASE NOTE - from StackState v5.0, the old sts
CLI has been renamed to stac
and there is a new sts
CLI. The command(s) provided here are for use with the new sts
CLI.
[](http://not.a.link "StackState Self-Hosted only")
See also
Last updated