Define rules in SSM

Contents

Overview

In SSM, a rule is a construction that defines what action should be taken with given data once a certain condition was met. Such rules give you flexibility to adjust your cluster for specific needs. For example, with SSM rules, you can automate moving log files that are older than 7 days to a special location and rename them, or if a file is requested rather frequently, you can move it to cache.

A rule consists of four parts:

  • Objects. Files to which the command will be applied.

  • Trigger. An optional parameter that defines when the condition will be checked, e.g. at a certain time or every N hours.

  • Conditions. An expression composed out of object property values and operators that is evaluated to true or false.

  • Commands. Actions that are launched once the condition is met.

A template for a rule is presented below:

<objects>: <trigger> | <conditions> | <commands>
NOTE
The symbols : and | are reserved by SSM as separators and cannot be used within the rule parts, otherwise the rule parse will fail.

The forementioned examples can be implemented as shown below.

file: path matches "var/logs/*.log" and age > 7day | rename -dest "var/old_logs/"
file: accessCount(15min) > 3 | cache

A rule can be in four states:

  • Active. When a rule is active, SSM will evaluate the conditions depending on the trigger and execute commands when the conditions are met.

  • Disabled. Default state of a rule after it was added. An active rule that is paused gets into this state, it can be reactivated afterwards. If there were unfinished actions while pausing, you can choose whether to finish these actions or to cancel them during the reactivation. The default behavior is to cancel them.

  • Finished. If a rule had a time trigger that was met and won’t be met again, it gets into this state.

  • Deleted. A state that a rule gets when the user deletes it, but there are still actions to complete. Once the actions are completed, the rule will be permanently deleted.

Add rules

To add a rule, you need to go the SSM Server web interface. To do that, follow the steps below:

  1. On the Clusters page, find your ADH cluster with SSM installed and click its name.

  2. On the Services tab, click SSM and go to the Info tab in the service menu.

  3. Click the link leading to the web interface.

In the web UI, you can add rules on the Smart Notebook page which is the starting page by default.

The SSM Smart Notebook page
The Smart Notebook page
The SSM Smart Notebook page
The Smart Notebook page

To create a new rule, type it in the Add Rule pane and run the notebook by either pressing Shift + Enter or clicking play outline dark play outline light in the top right corner. The created rule will be added to the Rule List pane. You can find object, trigger, and condition descriptions and several rule examples on the Help → Rule Grammar page. Also there is action description available on the Help → Action Usage page.

The created rule will have the Disabled status. To activate it, head to the User Rules page and click icon play next to the rule. The status will change to Active.

The SSM User Rules page
The User Rules page
The SSM User Rules page
The User Rules page
Found a mistake? Seleсt text and press Ctrl+Enter to report it