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

[Endpoint] Unifying the test index name for resolver and alerts #59073

Merged

Conversation

jonathan-buttner
Copy link
Contributor

@jonathan-buttner jonathan-buttner commented Mar 2, 2020

This PR unifies the alerts and events index name. These names need to be the same for retrieving events and alerts since they will be stored in the same index. The name I used is more inline with what the package will have: elastic/package-registry#223

After this change goes in, you'll want to use events-endpoint-1 to store the alerts and events for testing.

@jonathan-buttner jonathan-buttner added release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0 Feature:Endpoint Elastic Endpoint feature labels Mar 2, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/endpoint-app-team (Feature:Endpoint)

static ENDPOINT_INDEX_NAME = 'endpoint-agent*';
static EVENT_INDEX_NAME = 'endpoint-events-*';
static ALERT_INDEX_NAME = 'events-endpoint-1';
Copy link
Contributor

Choose a reason for hiding this comment

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

so alerts always go to '-1' and events can go to anywhere starting with 'events-endpoint-'?

Copy link
Contributor

Choose a reason for hiding this comment

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

I have the same question... where do the other events go? Why "-1"?

Copy link
Contributor Author

@jonathan-buttner jonathan-buttner Mar 2, 2020

Choose a reason for hiding this comment

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

No, ultimately the alerts will go to events-endpoint-<some rollover number> same as other events. I had to hard code -1 because I ran into an issue getting this working with the alert details API.

@madirey @peluja1012 @marshallmain
The alert details API use the elasticsearch's get API which requires a specific index: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html the problem with that is I don't think the alert list api returns the specific index that a document is in with the response and the event index will roll over based on the ILM policy. So it'll change from events-endpoint-000001 to events-endpoint-000002 etc. I tried having the alert details request take a pattern like events-endpoint-* but that causes a 500 from elasticsearch because the get API needs a single index.

I think we need to encode the index of the document in the _id or something so when the frontend passes it back, the backend can determine the specific index since we won't know that ahead of time.

Another example:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

The index is returned by ES for each hit when searching... we can return that in the response to the FE and/or cache it... will need some logic to look it up if it's not available, or we could just change it to use the search API...

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a case where we should use aliases for the alert indexes to unify them into a single index endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@achuguy hmm I don't think we could use an alias to abstract the search/get api. The endpoint will use an alias for all events in general so it doesn't know the specific rollover index either. We could use a pipeline to break them out but we already made the decision to write the alerts and events to a single index.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jonathan-buttner Yeah, that sounds like a good approach...

Copy link
Contributor

Choose a reason for hiding this comment

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

@jonathan-buttner If the endpoint is using an alias to write to, can you use a get with the same alias or are you specifically trying to isolate you get to a single index?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@achuguy so I believe you can have an alias that points to multiple indices but it doesn't look like you can do a GET on an alias with multiple indices:

image

You can execute searches I believe though but I think we should avoid doing a search since we have all the info we need to just run a GET.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, thanks for clearing that up for me

@@ -7,7 +7,7 @@
import { ResolverEvent, LegacyEndpointEvent } from '../../../../common/types';

function isLegacyData(data: ResolverEvent): data is LegacyEndpointEvent {
return data.agent.type === 'endgame';
return data.agent?.type === 'endgame';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The endpoint isn't sending the agent.type field yet so guard against a crash here

@EricDavisX
Copy link
Contributor

@jonathan-buttner
Copy link
Contributor Author

Thanks @EricDavisX yeah it was updated
image

@jonathan-buttner
Copy link
Contributor Author

@elasticmachine merge upstream

@jonathan-buttner
Copy link
Contributor Author

@elasticmachine merge upstream

@jonathan-buttner
Copy link
Contributor Author

@elasticmachine merge upstream

@jonathan-buttner
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💛 Build succeeded, but was flaky


Test Failures

Kibana Pipeline / kibana-xpack-agent / X-Pack OpenID Connect API Integration Tests.x-pack/test/oidc_api_integration/apis/authorization_code_flow/oidc_auth·js.apis OpenID Connect authentication finishing handshake should succeed if both the OpenID Connect response and the cookie are provided

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has failed 3 times on tracked branches: https://github.com/elastic/kibana/issues/43736

[00:00:00]       │
[00:00:00]         └-: apis
[00:00:00]           └-> "before all" hook
[00:00:00]           └-: OpenID Connect authentication
[00:00:00]             └-> "before all" hook
[00:00:00]             └-> should reject API requests if client is not authenticated
[00:00:00]               └-> "before each" hook: global before each
[00:00:00]               └- ✓ pass  (162ms) "apis OpenID Connect authentication should reject API requests if client is not authenticated"
[00:00:00]             └-: initiating handshake
[00:00:00]               └-> "before all" hook
[00:00:00]             └-: finishing handshake
[00:00:00]               └-> "before all" hook
[00:00:00]               └-> should fail if OpenID Connect response is not complemented with handshake cookie
[00:00:00]                 └-> "before each" hook: global before each
[00:00:00]                 └-> "before each" hook
[00:00:00]                 └- ✓ pass  (93ms) "apis OpenID Connect authentication finishing handshake should fail if OpenID Connect response is not complemented with handshake cookie"
[00:00:00]               └-> should fail if state is not matching
[00:00:00]                 └-> "before each" hook: global before each
[00:00:00]                 └-> "before each" hook
[00:00:00]                 │ info [o.e.x.s.a.AuthenticationService] [kibana-ci-immutable-centos-tests-xl-1583444604837070989] Authentication to realm oidc1 failed - Failed to authenticate user with OpenID Connect (Caused by org.elasticsearch.ElasticsearchSecurityException: Invalid state parameter [someothervalue], while [iis_zrnZDmOj3_j-N1kiQM2DRh9wQTmyVE88MmznqAg] was expected)
[00:00:00]                 └- ✓ pass  (182ms) "apis OpenID Connect authentication finishing handshake should fail if state is not matching"
[00:00:00]               └-> should succeed if both the OpenID Connect response and the cookie are provided
[00:00:00]                 └-> "before each" hook: global before each
[00:00:00]                 └-> "before each" hook
[00:00:00]                 │ info [o.e.x.s.a.AuthenticationService] [kibana-ci-immutable-centos-tests-xl-1583444604837070989] Authentication to realm oidc1 failed - Failed to authenticate user with OpenID Connect (Caused by org.elasticsearch.ElasticsearchSecurityException: Failed to exchange code for Id Token using the Token Endpoint.)
[00:00:01]                 └- ✖ fail: "apis OpenID Connect authentication finishing handshake should succeed if both the OpenID Connect response and the cookie are provided"
[00:00:01]                 │

Stack Trace

Error: expected 302 "Found", got 401 "Unauthorized"
    at Test._assertStatus (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:268:12)
    at Test._assertFunction (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:283:11)
    at Test.assert (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:173:18)
    at assert (/dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:131:12)
    at /dev/shm/workspace/kibana/node_modules/supertest/lib/test.js:128:5
    at Test.Request.callback (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/index.js:718:3)
    at parser (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/index.js:906:18)
    at IncomingMessage.res.on (/dev/shm/workspace/kibana/node_modules/superagent/lib/node/parsers/json.js:19:7)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

History

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

@jonathan-buttner jonathan-buttner merged commit 2e41a27 into elastic:master Mar 6, 2020
@jonathan-buttner jonathan-buttner deleted the feature/single-event-index branch March 6, 2020 14:43
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 7, 2020
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59073 or prevent reminders by adding the backport:skip label.

5 similar comments
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59073 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59073 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59073 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59073 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59073 or prevent reminders by adding the backport:skip label.

jkelastic pushed a commit to jkelastic/kibana that referenced this pull request Mar 12, 2020
…tic#59073)

* Unifying the test index name for resolver and alerts

* Endpoint isn't sending the agent field so check for it

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59073 or prevent reminders by adding the backport:skip label.

5 similar comments
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59073 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59073 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59073 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59073 or prevent reminders by adding the backport:skip label.

@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59073 or prevent reminders by adding the backport:skip label.

spalger pushed a commit to spalger/kibana that referenced this pull request Mar 19, 2020
…tic#59073)

* Unifying the test index name for resolver and alerts

* Endpoint isn't sending the agent field so check for it

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 19, 2020
@spalger
Copy link
Contributor

spalger commented Mar 19, 2020

7.x/7.7: dfea6de

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Endpoint Elastic Endpoint feature release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants