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.
managing-best-practice-rules |
|
---|---|
Get historical results for running rules. |
|
Get the latest results for all rules that have run. |
|
Run a best practice rule immediately. |
Managing Best Practice Rules
Best Practice Result
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 }
Data:
-
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
orFailed
. -
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.
Path arguments: cluster_id: The ID of a cluster returned from GET /cluster-configs.
Query params: rules: A comma-separated list of rules for which to fetch results.
Optional parameters:
-
start: A Unix timestamp in seconds indicating the start of the window in which to retreive results. Defaults to the current time.
-
end: A Unix timestamp in seconds indicating the end of the window in which to retreive results.
-
count: 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.
Example:
curl http://127.0.0.1:8888/Test_Cluster/bestpractice/results?count=1&rules=check-simple-strategy
Output:
{
"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.
Path arguments: cluster_id: 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.
Example:
curl http://127.0.0.1:8888/Test_Cluster/bestpractice/results/latest
Output:
{
"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.
Path arguments:
cluster_id: The ID of a cluster returned from GET /cluster-configs. * rule_name: The name of the rule to run.
Returns a dictionary describing the result of running the rule.
Example:
curl -X POST http://127.0.0.1:8888/Test_Cluster/bestpractice/run/check-simple-strategy
Output:
{
"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"
}