Best practice rules

With these methods, you can run best practice rules immediately, as well as view the historical results of running a specific best practice rule. Scheduling a best practice rule to run periodically can be done through the scheduling api Schedule management.

Manage best practice rules Method

Get historical results for running rules.

GET /{cluster_id}/bestpractice/results

Get the latest results for all rules that have run.

GET /{cluster_id}/bestpractice/results/latest

Run a best practice rule immediately.

POST /{cluster_id}/bestpractice/run/{rule_name}

Manage best practice rules

Best practice results

OpsCenter returns a JSON dictionary representing a single run of a best practice rule when querying for rule results.

A best practice result has the following form:

{
  "alert-level": "ALERT_LEVEL",
  "category": "CATEGORY",
  "description": "DESCRIPTION",
  "display-name": "DISPLAY",
  "enabled_by_default": "ENABLED",
  "errors":
    {
      "cluster-error": "CLUSTER_ERROR",
      "node-errors": "NODE_ERRORS",
      "request-errors": "REQUEST_ERRORS"
    },
  "importance": "IMPORTANCE",
  "name": "NAME",
  "recommendation": "RECOMMENDATION",
  "run_time": "RUN_TIME",
  "scope": "SCOPE",
  "status": "STATUS",
  "suggested_interval": "SUGGESTED_INTERVAL",
  "version": "VERSION"
}

The fields in the dictionary are as follows:

  • ALERT_LEVEL (string): The level used when creating an alert for the failed rule.

  • CATEGORY (string): The category the rule is in. Used by the OpsCenter UI.

  • DESCRIPTION (string): A detailed description of what the rule is checking.

  • DISPLAY (string): A UI-friendly name for the rule.

  • ENABLED (string): Whether the rule is enabled by default or not.

  • CLUSTER_ERROR (string): If the rule failed, and is run at the cluster scope, this describes the failure.

  • NODE_ERRORS (string): The list of individual nodes on which the rule failed to run.

  • REQUEST_ERRORS (string): The list of nodes on which the rule was unable to run.

  • IMPORTANCE (string): The importance of the rule passing. Can be high, medium, or low.

  • RECOMMENDATION (string): The suggested action to resolve the rule.

  • RUN_TIME (string): The time at which this run of the rule occurred.

  • SCOPE (string): The scope of the rule. Can be cluster, node, or cluster-and-node.

  • STATUS (string): Either Passed or Failed.

  • SUGGESTED_INTERVAL (string): The recommended default interval for rules that are enabled by default.

  • VERSION (string): The version of OpsCenter in which the rule was added.

GET /{cluster_id}/bestpractice/results

Get the historical results of running the specified rules.

curl http://127.0.0.1:8888/Test_Cluster/bestpractice/results?count=1&rules=check-simple-strategy

Accepts the following parameters:

cluster_id

Path parameter. The ID of a cluster returned from GET /cluster-configs.

rules

Query parameter. A comma-separated list of rules for which to fetch results.

start

Optional query parameter. A Unix timestamp in seconds indicating the start of the window in which to retreive results. Defaults to the current time.

end

Optional query parameter. A Unix timestamp in seconds indicating the end of the window in which to retrieve results.

count

Optional query parameter. Number of results to return. Defaults to 100.

Returns a dictionary describing the rule results. Each key in the dictionary is the name of the rule and each value is an array of dictionaries describing the result. For example:

{
  "check-simple-strategy": [
    {
      "alert-level": "alert",
      "category": "Replication",
      "description": "Checks that you are not using SimpleStrategy for any keyspaces in a multi-datacenter environment.",
      "display-name": "SimpleStrategy keyspace usage found",
      "enabled_by_default": true,
      "errors": {},
      "importance": "medium",
      "name": "check-simple-strategy",
      "recommendation": "Please update the replication strategies of the relevant keyspace(s) to use NetworkTopologyStrategy.",
      "run_time": "2014-07-22 23:37:14.329808",
      "scope": "cluster",
      "status": "Passed",
      "suggested_interval": "daily",
      "version": "5.0.0"
    }
  ]
}

GET /{cluster_id}/bestpractice/results/latest

Get the latest results for all rules that have run.

curl http://127.0.0.1:8888/Test_Cluster/bestpractice/results/latest

Accepts the following parameters:

cluster_id

Path parameter. The ID of a cluster returned from GET /cluster-configs.

Returns a dictionary describing the rule results. Each key in the dictionary is the name of the rule and each value is a dictionary describing the latest run of the rule. For example:

{
  "check-simple-strategy": {
    "alert-level": "alert",
    "category": "Replication",
    "description": "Checks that you are not using SimpleStrategy for any keyspaces in a multi-datacenter environment.",
    "display-name": "SimpleStrategy keyspace usage found",
    "enabled_by_default": true,
    "errors": {},
    "importance": "medium",
    "name": "check-simple-strategy",
    "recommendation": "Please update the replication strategies of the relevant keyspace(s) to use NetworkTopologyStrategy.",
    "run_time": "2014-07-22 23:41:50.727939",
    "scope": "cluster",
    "status": "Passed",
    "suggested_interval": "daily",
    "version": "5.0.0"
  },
  "check-simple-snitch": {
    ...
  }
}

POST /{cluster_id}/bestpractice/run/{rule_name}

Run a specific best practice rule immediately.

curl -X POST http://127.0.0.1:8888/Test_Cluster/bestpractice/run/check-simple-strategy

Accepts the following parameters:

cluster_id

Path parameter. The ID of a cluster returned from GET /cluster-configs.

rule_name

Path parameter. The name of the rule to run.

Returns a dictionary describing the result of running the rule. For example:

{
  "alert-level": "alert",
  "category": "Replication",
  "description": "Checks that you are not using SimpleStrategy for any keyspaces in a multi-datacenter environment.",
  "display-name": "SimpleStrategy keyspace usage found",
  "enabled_by_default": true,
  "errors": {},
  "importance": "medium",
  "name": "check-simple-strategy",
  "recommendation": "Please update the replication strategies of the relevant keyspace(s) to use NetworkTopologyStrategy.",
  "run_time": "2014-07-22 23:44:22.179740",
  "scope": "cluster",
  "status": "Passed",
  "suggested_interval": "daily",
  "version": "5.0.0"
}

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2025 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM