Skip to content
DataMiner Dojo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Updates & Insights
  • Questions
  • Learning
    • E-learning Courses
    • Tutorials
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • YouTube Videos
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Agility
      • Learn more about Agile
        • Agile Webspace
        • Everything Agile
          • The Agile Manifesto
          • Best Practices
          • Retro Recipes
        • Methodologies
          • The Scrum Framework
          • Kanban
          • Extreme Programming
        • Roles
          • The Product Owner
          • The Agile Coach
          • The Quality & UX Coach (QX)
      • Book your Agile Fundamentals training
      • Book you Kanban workshop
    • >> Go to DataMiner Docs
  • DevOps
    • About the DevOps Program
    • Sign up for the DevOps Program
    • DataMiner DevOps Support
    • Feature Suggestions
  • Downloads
  • Swag Shop
  • PARTNERS
    • Business Partners
    • Technology Partners
  • Contact
    • Sales, Training & Certification
    • DataMiner Support
    • Global Feedback Survey
  • >> Go to dataminer.services

Can a correlation rule be enabled/disabled programmatically from a QAction?

Solved108 views2 days agoConnector Correlation rule Correlation rules driver
6
Enis Abaza [SLC] [DevOps Advocate]361 2 days ago 0 Comments

I have a use case where alarm ingestion into a connector follows this flow:

Correlation Rule triggers an automation script, which pushes data into a table in a connector.

I want to add a configuration parameter on the connector that enables or disables this entire flow. Ideally, I'd like to cut it off at the root by disabling the correlation rule itself when the parameter is toggled off.

I'm aware of workarounds, e.g. checking the parameter early in the automation script and exiting before doing any work. That's cheap and effective, but the correlation rule still fires and the script still starts for every alarm update, only to immediately exit.

Is there a way to programmatically enable or disable a correlation rule from a QAction (or automation script)? For example, via an SLNet message?

Enis Abaza [SLC] [DevOps Advocate] Selected answer as best 2 days ago

1 Answer

  • Active
  • Voted
  • Newest
  • Oldest
6
Stacey Van Colen [SLC] [DevOps Member]2.74K Posted 2 days ago 1 Comment

Hi Enis,

Yes, it's feasible to enable/disable a Correlation Rule from an Automation script.

We've already created a script for this before.

Here you can find the C# code for the Automation script:

namespace Update_Correlation_Rule_1
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Linq;
using Skyline.DataMiner.Automation;
    using Skyline.DataMiner.Net.Correlation;
    using Skyline.DataMiner.Net.Messages;

    /// <summary>
    /// Represents a DataMiner Automation script.
    /// </summary>
    public class Script
{
/// <summary>
/// The script entry point.
/// </summary>
/// <param name="engine">Link with SLAutomation process.</param>
public void Run(IEngine engine)
{

///Arguments to provide:  
///    ** Correlationrule Name
///    ** true / false

// get input string

// get input string
            string correlationGroup = engine.GetScriptParam("selectCorrelationGroup").Value;
            string correlationAction = engine.GetScriptParam("selectCorrelationAction").Value;

            // cast the selected action to a bool variable
            bool correlationActionbool = false;
            switch (correlationAction)
            {
                case "enable":
                    correlationActionbool = true;
                    break;
                case "disable":
                    correlationActionbool = false;
                    break;
                default:
                    break;
            }

            // get list of correlation rules containing the selected Group name in the description
            Dictionary<string, CorrelationRuleMeta> correlationRulesMeta = getMetas();
            IEnumerable<KeyValuePair<string, CorrelationRuleMeta>> CorrelationskeyValuePairs = correlationRulesMeta.Where(x => x.Value.Description.Contains(correlationGroup));

            // check if the group is enabled
            
            
            
            bool isEnabled = false;
            //string[] corr_resp_array = new string[];

            foreach (var item in CorrelationskeyValuePairs)
            {
if (correlationAction == "check")
isEnabled = item.Value.IsEnabled;
else
{
                if (correlationActionbool)
                {
                    if (!item.Value.IsEnabled)
                    {
                        if ( UpdateCorrelationRule(engine, item.Value.Name, correlationActionbool) == true)
                        {
                            isEnabled = true;
                        }
                    }
                    else
                    isEnabled = true;
                }
                else if (!correlationActionbool)
                {
                    if (item.Value.IsEnabled)
                    {
                        if (UpdateCorrelationRule(engine, item.Value.Name, correlationActionbool) == true)
                        {
                            isEnabled = false;
                        }
                        else
                        isEnabled = true;
                    }
                }
            }
}
            if (isEnabled)
            {
                engine.AddOrUpdateScriptOutput(UIVariables.VisualOverview.CreateKey("corrStatus"), "true");
            }
            else
            {
                engine.AddOrUpdateScriptOutput(UIVariables.VisualOverview.CreateKey("corrStatus"), "false");
            }
}

        public bool UpdateCorrelationRule(IEngine engine, string name, bool enable)
        {
            Skyline.DataMiner.Net.Messages.GetCorrelationRuleMessage crRule = new GetCorrelationRuleMessage();
            crRule.RuleName = name;

            UpdateCorrelationRuleMessage update = new UpdateCorrelationRuleMessage();
            update.RuleDefinition = ((GetCorrelationRuleResponse)Engine.SLNet.SendSingleResponseMessage(crRule)).Definition;
            update.RuleDefinition.IsEnabled = enable;
            update.Type = UpdateCorrelationRuleMessage.UpdateType.Update;
            DMSMessage[] UpdateResponse = Engine.SLNet.SendMessage(update);

            if (UpdateResponse.Length == 0)
            {
                engine.GenerateInformation(name + " not updated !");
                return false;
            }
            else 
            {
                return true;
            }
         
        }

public Dictionary<string, CorrelationRuleMeta> getMetas()
{
Skyline.DataMiner.Net.Messages.GetAvailableCorrelationRulesMessage crmes = new Skyline.DataMiner.Net.Messages.GetAvailableCorrelationRulesMessage();
var response = Engine.SLNet.SendMessage(crmes);
AvailableCorrelationRulesResponse res = (AvailableCorrelationRulesResponse)response[0];
Dictionary<string, CorrelationRuleMeta> dMetas = new Dictionary<string, CorrelationRuleMeta>();
foreach (CorrelationRuleMeta crMeta in res.Rules)
{
dMetas.Add(crMeta.Name, crMeta);
}
return dMetas;
}
}
}

Please also add two parameters for the Automation Script which will be used as input for knowing the Correlation rule and action needed. :
- selectCorrelationGroup
- selectCorrelationAction : {enable, disable}

Kind regards,

Enis Abaza [SLC] [DevOps Advocate] Selected answer as best 2 days ago
Enis Abaza [SLC] [DevOps Advocate] commented 2 days ago

It works as expected, thank you very much!

Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas
Privacy Policy • Terms & Conditions • Contact

© 2026 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs

[ Placeholder content for popup link ] WordPress Download Manager - Best Download Management Plugin