Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RAC] Get o11y alerts in alerts table #109346

Merged
merged 9 commits into from
Aug 20, 2021
Merged

Conversation

XavierM
Copy link
Contributor

@XavierM XavierM commented Aug 19, 2021

Summary

Fixes #109317

@dhurley14 and I pair to bring back o11y alerts in the table. Now, we are passing directly the indexes name in our alerts search strategy and count on the filter of the authorization to show the right alerts. The index names are saved in memory inside of the ruleServiceData.

image

@XavierM XavierM added bug Fixes for quality problems that affect the customer experience v8.0.0 impact:critical This issue should be addressed immediately due to a critical level of impact on the product. Team:Threat Hunting Security Solution Threat Hunting Team Theme: rac label obsolete v7.15.0 v7.16.0 labels Aug 19, 2021
@XavierM XavierM requested a review from a team as a code owner August 19, 2021 21:14
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting (Team:Threat Hunting)

@XavierM XavierM added the release_note:skip Skip the PR/issue when compiling release notes label Aug 19, 2021
Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for jumping on this so quickly!

The fact that we're using the ruleDataClient here leads to a few problems (that existed before, but are solidified through these changes):

  • The field list is read using the internal user's permissions and not the current user's permissions.
  • The addition of the indexNames argument to getReader breaks the abstraction, because the whole point of the RuleDataClient is to delegate the index name generation to the RuleDataService.

How about the following:

  • The dynamic_index_pattern route turns a list of registrationContexts and a namespace into an index name pattern (e.g. ['.alerts-observability.logs.alerts-default', '.alerts-observability.metrics.alerts-default']). On the alerts page we then use Kibana's IndexPatternService to request getFieldsForWildcard to get the field list for use as a dynamicIndexPattern.

Does that make sense?

@@ -37,9 +37,13 @@ export class RuleDataClient implements IRuleDataClient {
return this.options.isWriteEnabled;
}

public getReader(options: { namespace?: string } = {}): IRuleDataReader {
public getReader(options: { namespace?: string; indexNames?: string[] } = {}): IRuleDataReader {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this break the abstraction layer the RuleDataClient represents?

@@ -148,4 +152,13 @@ export class RuleDataPluginService {
waitUntilReadyForWriting,
});
}

/**
* Initializes alerts-as-data index and starts index bootstrapping right away.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this comment correlate to the actual function?

@weltenwort
Copy link
Member

@XavierM I took the liberty of removing the RuleDataClient usage. Let me know what you think.

return callObservabilityApi({
signal,
endpoint: 'GET /api/observability/rules/alerts/dynamic_index_pattern',
params: {
query: {
namespace: 'default',
Copy link
Contributor

@dhurley14 dhurley14 Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weltenwort Is there a way to get the space id from the UI? This may not always be default, no?

We were pulling it off of the alerting framework rulesClient in the rules/alerts/dynamic_index_pattern route so we could ensure we acquired the correct space id on the request.. If observability doesn't plan on segmenting by space id I could understand why this would be hard coded to default then. Just looking for clarification here..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentionally fixed as default, because in observability we're not using the space id in the namespace. The filtering by space happens as part of the RBAC filter if I saw that correctly.

Copy link
Contributor

@banderror banderror left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall, I just left a few comments. Thank you @XavierM @dhurley14 @weltenwort

Also, mapConsumerToIndexName is still used by AlertsClient (RBAC), right?

@@ -105,6 +106,8 @@ export class RuleDataPluginService {
indexOptions,
});

this.registeredIndices.set(indexOptions.registrationContext, indexInfo);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The full index name (indexInfo.baseName) is defined not only by registrationContext, but also by dataset (alerts or events).

I guess the proper key for this map would be ${indexOptions.registrationContext}.${indexOptions.dataset}, and getRegisteredIndexInfo would need to accept dataset as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, this only works because we assume alerts as a dataset implicitly. Would it be ok to add that as a follow-up to unblock this ASAP?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, of course 👍
TODO in the follow-up PR: let getRegisteredIndexInfo to accept dataset as well, generate keys of the registeredIndices map correctly.

x-pack/plugins/observability/server/plugin.ts Show resolved Hide resolved
registrationContexts: [
'observability.apm',
'observability.logs',
'observability.infrastructure',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

observability.infrastructure registration context doesn't exist in the code. What plugin is supposed to be defining it?

Copy link
Member

@weltenwort weltenwort Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be observability.metrics. The app is called infrastructure for historical reasons, but not the registration context.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO in the follow-up PR: remove observability.infrastructure and make sure observability.metrics is there.

Copy link
Contributor Author

@XavierM XavierM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weltenwort, I agree with what you did and to be honest I was not really familiar with all the work and discussion around ruleDataClient or ruleDataService. So I am glad you fix it and make it good for everybody.

IMG

Copy link
Contributor

@banderror banderror left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to unblock and merge this PR ASAP.

I'll try to address these things in a follow-up PR:

Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks everyone for the collaboration.

Known issues are the wrong observability.infrastructure registration context and the lack of dataset in the registered index info map.

@XavierM XavierM added the auto-backport Deprecated - use backport:version if exact versions are needed label Aug 20, 2021
@XavierM XavierM enabled auto-merge (squash) August 20, 2021 15:57
Copy link
Contributor

@michaelolo24 michaelolo24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! LGTM!!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
observability 256 259 +3

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cases 582.8KB 582.6KB -204.0B
observability 489.6KB 492.1KB +2.6KB
securitySolution 6.5MB 6.5MB -702.0B
timelines 437.2KB 437.2KB -60.0B
total +1.6KB
Unknown metric groups

API count

id before after diff
ruleRegistry 134 136 +2
timelines 961 960 -1
total +1

API count missing comments

id before after diff
ruleRegistry 113 114 +1
timelines 841 840 -1
total -0

Non-exported public API item count

id before after diff
ruleRegistry 6 7 +1

References to deprecated APIs

id before after diff
observability 41 37 -4

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@XavierM XavierM merged commit e8e53e3 into elastic:master Aug 20, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 20, 2021
* get back index names  in o11y

* testing and integration

* fix types

* Avoid using the rule data client for field list

* Remove left-over index argument

* no needs of alert consumer anymore

Co-authored-by: Felix Stürmer <stuermer@weltenwort.de>
@kibanamachine
Copy link
Contributor

💔 Backport failed

Status Branch Result
7.15
7.x Commit could not be cherrypicked due to conflicts

Successful backport PRs will be merged automatically after passing CI.

To backport manually run:
node scripts/backport --pr 109346

@weltenwort
Copy link
Member

weltenwort commented Aug 20, 2021

The failed backport is probably due a chain of other backports failing. I'll keep track of those any retry later today:

kibanamachine added a commit that referenced this pull request Aug 20, 2021
* get back index names  in o11y

* testing and integration

* fix types

* Avoid using the rule data client for field list

* Remove left-over index argument

* no needs of alert consumer anymore

Co-authored-by: Felix Stürmer <stuermer@weltenwort.de>

Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
Co-authored-by: Felix Stürmer <stuermer@weltenwort.de>
weltenwort pushed a commit to weltenwort/kibana that referenced this pull request Aug 23, 2021
* get back index names  in o11y

* testing and integration

* fix types

* Avoid using the rule data client for field list

* Remove left-over index argument

* no needs of alert consumer anymore

Co-authored-by: Felix Stürmer <stuermer@weltenwort.de>
# Conflicts:
#	x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx
#	x-pack/plugins/observability/public/pages/alerts/index.tsx
weltenwort added a commit that referenced this pull request Aug 23, 2021
* get back index names  in o11y

* testing and integration

* fix types

* Avoid using the rule data client for field list

* Remove left-over index argument

* no needs of alert consumer anymore

Co-authored-by: Felix Stürmer <stuermer@weltenwort.de>
# Conflicts:
#	x-pack/plugins/observability/public/pages/alerts/alerts_table_t_grid.tsx
#	x-pack/plugins/observability/public/pages/alerts/index.tsx

Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
banderror added a commit that referenced this pull request Aug 25, 2021
…atures to index names (#109567)

**Ticket:** #102089

🚨 **This PR is critical for Observability 7.15** 🚨

## Summary

This PR introduces changes that fix the usage of alerts-as-data index naming in RBAC. It builds on top of #109346 and replaces #108872.

TODO:

- [x] Address #109346 (review)
- [x] Make changes to `AlertsClient.getAuthorizedAlertsIndices()` so it starts using `RuleDataService` to get index names by feature ids.
- [x] Delete the hardcoded `mapConsumerToIndexName` where we had incorrect index names.
- [x] Close #108872

### Checklist

Delete any items that are not applicable to this PR.

- [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 25, 2021
…atures to index names (elastic#109567)

**Ticket:** elastic#102089

🚨 **This PR is critical for Observability 7.15** 🚨

## Summary

This PR introduces changes that fix the usage of alerts-as-data index naming in RBAC. It builds on top of elastic#109346 and replaces elastic#108872.

TODO:

- [x] Address elastic#109346 (review)
- [x] Make changes to `AlertsClient.getAuthorizedAlertsIndices()` so it starts using `RuleDataService` to get index names by feature ids.
- [x] Delete the hardcoded `mapConsumerToIndexName` where we had incorrect index names.
- [x] Close elastic#108872

### Checklist

Delete any items that are not applicable to this PR.

- [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 25, 2021
…atures to index names (elastic#109567)

**Ticket:** elastic#102089

🚨 **This PR is critical for Observability 7.15** 🚨

## Summary

This PR introduces changes that fix the usage of alerts-as-data index naming in RBAC. It builds on top of elastic#109346 and replaces elastic#108872.

TODO:

- [x] Address elastic#109346 (review)
- [x] Make changes to `AlertsClient.getAuthorizedAlertsIndices()` so it starts using `RuleDataService` to get index names by feature ids.
- [x] Delete the hardcoded `mapConsumerToIndexName` where we had incorrect index names.
- [x] Close elastic#108872

### Checklist

Delete any items that are not applicable to this PR.

- [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
kibanamachine added a commit that referenced this pull request Aug 25, 2021
…atures to index names (#109567) (#110068)

**Ticket:** #102089

🚨 **This PR is critical for Observability 7.15** 🚨

## Summary

This PR introduces changes that fix the usage of alerts-as-data index naming in RBAC. It builds on top of #109346 and replaces #108872.

TODO:

- [x] Address #109346 (review)
- [x] Make changes to `AlertsClient.getAuthorizedAlertsIndices()` so it starts using `RuleDataService` to get index names by feature ids.
- [x] Delete the hardcoded `mapConsumerToIndexName` where we had incorrect index names.
- [x] Close #108872

### Checklist

Delete any items that are not applicable to this PR.

- [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios

Co-authored-by: Georgii Gorbachev <georgii.gorbachev@elastic.co>
kibanamachine added a commit that referenced this pull request Aug 25, 2021
…atures to index names (#109567) (#110067)

**Ticket:** #102089

🚨 **This PR is critical for Observability 7.15** 🚨

## Summary

This PR introduces changes that fix the usage of alerts-as-data index naming in RBAC. It builds on top of #109346 and replaces #108872.

TODO:

- [x] Address #109346 (review)
- [x] Make changes to `AlertsClient.getAuthorizedAlertsIndices()` so it starts using `RuleDataService` to get index names by feature ids.
- [x] Delete the hardcoded `mapConsumerToIndexName` where we had incorrect index names.
- [x] Close #108872

### Checklist

Delete any items that are not applicable to this PR.

- [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios

Co-authored-by: Georgii Gorbachev <georgii.gorbachev@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed bug Fixes for quality problems that affect the customer experience impact:critical This issue should be addressed immediately due to a critical level of impact on the product. release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting Security Solution Threat Hunting Team Theme: rac label obsolete v7.15.0 v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RAC] Observability alerts table reads from incorrect indices
7 participants