Clarive Announces Rule Keeper: Enhanced Monitoring and Debugging for Your DevOps Workflows

At Clarive, we’re always striving to make our platform more transparent, debuggable, and user-friendly. We’re excited to announce the latest update: Rule Keeper, a powerful monitoring and debugging tool that provides real-time insights into your rule executions. This new feature allows you to track, monitor, and debug rule performance with unprecedented visibility, helping you identify bottlenecks, troubleshoot issues, and optimize your DevOps workflows.

In this blog post, we’ll dive deep into the technical aspects of using Rule Keeper, explore its monitoring capabilities, and provide practical examples to help you get the most out of this powerful debugging tool.

What is Rule Keeper?

Rule Keeper is an interactive monitoring system that tracks rule execution, performance metrics, and provides detailed insights into rule behavior. It’s designed to help administrators and developers understand how rules are performing, identify potential issues, and optimize their DevOps processes. With Rule Keeper, you can monitor rule executions in real-time, analyze performance patterns, and quickly debug problems when they occur.

Why Use Rule Keeper?

Enabling Rule Keeper in your Clarive environment offers several advantages:

  • Real-time Monitoring: Watch your rules execute in real-time with live updates and performance metrics.
  • Performance Optimization: Identify slow-running rules and bottlenecks that could impact your deployment pipeline.
  • Quick Debugging: Rapidly locate and resolve rule execution issues with detailed trace information.
  • Capacity Planning: Understand resource requirements for rule execution and plan your infrastructure accordingly.
  • Compliance and Auditing: Track rule execution for audit and compliance purposes with detailed logs.

Setting Up Rule Keeper

Configuring Rule Keeper involves a simple configuration change in your Clarive instance. This feature is controlled entirely by a single parameter in your configuration file.

Basic Configuration

To enable Rule Keeper, you need to modify your config/clarive.yml file:

# rule tracing and management
rule_keeper: 1

After making this change, restart your web server for the configuration to take effect. No additional setup is required – the monitoring is automatically active when enabled.

Verifying the Setup

Once configured, you can verify that Rule Keeper is working by running:

cla keeper -e 'ps' -c myconfig

If you see a warning message about rule_keeper being false, double-check your configuration file and ensure you’ve restarted the web server.

Using Rule Keeper

Rule Keeper provides both interactive and command-line interfaces for monitoring your rules. Let’s explore the most powerful features.

Interactive Mode

Start the interactive monitoring session:

cla keeper -c myconfig

This opens a REPL (Read-Eval-Print Loop) where you can run various monitoring commands.

Command-Line Mode

Execute single commands and exit immediately:

cla keeper -e 'ps' -c myconfig
cla keeper -e 'ps W' -c myconfig
cla keeper -e 'ps t=form' -c myconfig

Key Monitoring Commands

Process Listing with ps

The ps command is your primary tool for viewing rule executions. It provides a comprehensive view of all rule activities with pagination support.

Basic Usage:

ps

Advanced Options:
W – Wide mode (shows start/end timestamps)
R – Show only currently running rules
t=type1,type2 – Filter by rule types (comma-separated)

Examples:

ps          # Show all rules
ps W        # Wide mode with timestamps
ps R        # Only running rules
ps t=rule   # Only rule type executions
ps t=rule,workflow  # Multiple types

The output shows:
SEQ: Sequence number for tracking
ID: Rule identifier
RULE: Rule name
TYPE: Rule type (form, workflow, etc.)
STATUS: Current status (running, ok, ko, killed)
HOST: Hostname where rule is executing
USER: User executing the rule
PID: Process ID
DURATION: Execution time

Real-time Monitoring with top

The top command provides real-time monitoring with auto-refresh capabilities, similar to the Unix top command.

top

Interactive Controls:
q – Quit the top view
w – Toggle wide mode (show timestamps)
r – Toggle running-only mode
t – Set type filter

This is particularly useful for monitoring active deployments or troubleshooting ongoing issues.

Debugging with Trace and Code Commands

When you encounter a rule that’s stuck or behaving unexpectedly, Rule Keeper provides powerful debugging tools.

Using trace for Stack Analysis

The trace command shows the complete stack trace for a specific rule execution:

trace 402

This displays the full call stack, helping you understand exactly where the rule execution is occurring and what might be causing issues.

Using code for Context Analysis

The code command shows the actual DSL code around the line where an error occurred:

code 402

This displays the code with line numbers, highlighting the problematic area. You can also specify the number of context lines:

code 402 10

This shows 10 lines before and after the error location, providing more context for debugging.

Complete Debugging Workflow

Here’s a typical debugging workflow when you encounter a problematic rule:

  1. Identify the Issue: Use ps to find the problematic rule execution
  2. Kill the Process: Use kill to stop the stuck rule
  3. Analyze the Trace: Use trace to see the stack trace
  4. Examine the Code: Use code to see the actual code around the error
  5. Fix and Retry: Make the necessary corrections and restart the rule

Example Workflow:

# Find stuck rules
ps R

# Kill a stuck rule (using sequence number 402)
kill 402

# Analyze what happened
trace 402

# Look at the code around the error
code 402 5

Advanced Monitoring Features

Process Management

Kill Processes:

kill <signal> <seq>

If no signal is specified, it uses WINCH (28). This is useful for gracefully stopping stuck rules.

Process Information:

pid <pid>

Shows detailed process information for a specific PID.

Data Management

Cleanup Old Entries:

cleanup old        # Delete entries > 1h old
cleanup truncate   # Delete all entries

Remove Orphaned Entries:

roadkill

This removes entries where the process is missing or not owned by the current user.

Logging and Output

Log to File:

log debug_output.txt

Close Log:

close

Performance Optimization with Rule Keeper

Rule Keeper isn’t just for debugging – it’s also a powerful tool for performance optimization.

Identifying Bottlenecks

Use the ps command with duration sorting to identify slow-running rules:

ps W

Look for rules with unusually long durations and investigate further.

Monitoring Resource Usage

The top command helps you monitor resource usage in real-time, allowing you to identify patterns and optimize accordingly.

Capacity Planning

By analyzing rule execution patterns, you can better understand your infrastructure requirements and plan for scaling.

Best Practices

Regular Monitoring

Set up regular monitoring sessions to check rule health:

# Quick health check
cla keeper -e 'ps R' -c myconfig

# Detailed analysis
cla keeper -e 'ps W' -c myconfig

Debugging Workflow

Establish a consistent debugging workflow:

  1. Always start with ps to get an overview
  2. Use top for real-time monitoring of active issues
  3. Use trace and code for detailed analysis
  4. Document findings and solutions

Performance Tracking

Regularly review rule execution times and identify optimization opportunities.

Troubleshooting Common Issues

Rule Keeper Not Working

If Rule Keeper isn’t showing any data:

  1. Verify rule_keeper: 1 is set in your config
  2. Restart the web server
  3. Check that rules are actually running

No Rules Showing

If ps shows no results:

  1. Ensure rules are actively executing
  2. Check the time range (older entries may be cleaned up)
  3. Verify you’re looking at the correct environment

Permission Issues

If you encounter permission errors:

  1. Ensure you have the necessary permissions to access the database
  2. Check that the MongoDB connection is working
  3. Verify your user has access to the rule_keeper collection

Conclusion

Rule Keeper represents a significant advancement in Clarive’s monitoring and debugging capabilities for your custom rules. Whether you are troubleshooting a complex deployment issue, optimizing performance, or simply monitoring your DevOps workflows, Clarive’s Rule Keeper offers the visibility and tools necessary for understanding what’s running where, how and what.

We encourage all users to explore these features and incorporate Rule Keeper into their daily operations, just turn the toggle on and give it a try. Especially if topic loading is taking a while in your installation. It could be due to a long running form, field or workflow rule.

Stay tuned for more updates and features!

If you have any questions or need assistance with your Rule Keeper setup, please do not hesitate to contact our support team. Happy monitoring!

For more information about Rule Keeper and other Clarive features, visit our documentation.