Skip to content

Commit

Permalink
[Security Solution] Improve READMEs for the Detection Engine health A…
Browse files Browse the repository at this point in the history
…PI (#160137)

**Partially addresses:** #125642

## Summary

- fixes typos noticed by @maximpn in
#159970 (comment)
- adds additional docs for #159875
  • Loading branch information
banderror authored Jun 21, 2023
1 parent 4a589e4 commit aaaef2e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ Minimal required parameters for the `POST` route: empty object.
{}
```

The `GET` route don't accept any parameters and use the default parameters instead:
The `GET` route doesn't accept any parameters and uses the default parameters instead:

- interval: `last_day`
- granularity: `hour`
Expand Down Expand Up @@ -737,7 +737,7 @@ Minimal required parameters for the `POST` route: empty object.
{}
```

The `GET` route don't accept any parameters and use the default parameters instead:
The `GET` route doesn't accept any parameters and uses the default parameters instead:

- interval: `last_day`
- granularity: `hour`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Detection Engine health API

See [README](../../../../../../common/detection_engine/rule_monitoring/api/detection_engine_health/README.md) in the common folder.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Detection Engine health logic

See [README](../../../../../../common/detection_engine/rule_monitoring/api/detection_engine_health/README.md) in the common folder for info about the Detection Engine health API.

This logic provides the following functionality via the `IDetectionEngineHealthClient` interface:

- Calculating health snapshots for different "slices" of rules in the cluster:
- the whole cluster: all detection rules in all Kibana spaces
- a given space: all rules in the current Kibana space
- a given rule: an individual rule specified by id
- Installing assets for monitoring health, such as Kibana dashboards, etc.

## Assets for monitoring health

The assets' sources are located in the repo under `x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/assets`.

### Assets are installed on behalf of the internal user

The important aspect to know about is that we install these assets via the saved objects `import()` method, and do it on behalf of the internal Kibana user (which is `kibana_system` by default). This user has privileges for writing saved objects out of the box, which allows our users to be able to install the assets without configuring any additional RBAC.

See `createDetectionEngineHealthClient` and `installAssetsForMonitoringHealth` for the implementation details.

### Assets' source files are JSON

Another thing to consider is that the assets are stored as `.json` files in the repo. This has pros and cons, but the important benefit here is that it allows you to make changes in the assets faster. Especially it applies to Kibana dashboards, which are large objects, and it's hard to construct a dashboard manually in the code.

### Updating the rule monitoring dashboard

For example, let's talk about updating the `dashboard_rule_monitoring.json`. It is very convenient to be able to install this dashboard via calling the `_setup` endpoint, and then go edit it in Kibana, save it, export it, and update the source file based on the exported `.ndjson` file.

Only a few adjustments would need to be done after that manually in the source file:

- obviously, formatting to JSON
- the dashboard's id has to be updated to `security-detection-rule-monitoring-<spaceId>`
- you have to make sure the references to tags are specified correctly:

```json
{
"id": "fleet-managed-<spaceId>",
"name": "tag-ref-fleet-managed",
"type": "tag"
},
{
"id": "security-solution-<spaceId>",
"name": "tag-ref-security-solution",
"type": "tag"
}
```

0 comments on commit aaaef2e

Please sign in to comment.