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

[APM] Add Agent Keys in APM settings - Create agent keys #120373

Merged
merged 17 commits into from
Dec 7, 2021

Conversation

gbamparop
Copy link
Contributor

@gbamparop gbamparop commented Dec 3, 2021

Summary

This PR adds the following:

  • Flyout to create agent keys
  • Callout to copy the Base64 token for the key created
  • Public API for creating agent keys

Agent keys table was added in #119543

There will be other PRs for the below:

  • Functionality to create agent keys
  • Documentation update
  • Stories and tests

Addresses part of #77966

Screen.Recording.2021-12-03.at.17.10.05.mov

@gbamparop
Copy link
Contributor Author

@kibanamachine merge upstream

@kibanamachine
Copy link
Contributor

merge conflict between base and head

.filter((x) => !x[1])
.map((x) => x[0])
.join(', ');
const error = `${username} is missing the following requested privilege(s): ${missingPrivileges}.\
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it makes sense to show this error in the UI as this requirement doesn't seem to be documented. Is it ok if we display whichever error is thrown from this route or hardcode the text in the UI as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cauemarcondes @sqren what do you think?

@gbamparop gbamparop added auto-backport Deprecated - use backport:version if exact versions are needed release_note:feature Makes this part of the condensed release notes Team:APM All issues that need APM UI Team support v8.0.0 v8.1.0 labels Dec 3, 2021
@gbamparop
Copy link
Contributor Author

@formgeist could you please have a look at this and #119543 ?

@gbamparop gbamparop requested review from formgeist and a team December 3, 2021 17:15
@gbamparop gbamparop marked this pull request as ready for review December 3, 2021 17:18
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@gbamparop
Copy link
Contributor Author

@kibanamachine merge upstream

Copy link
Contributor

@formgeist formgeist left a comment

Choose a reason for hiding this comment

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

Overall LGTM - I've added some copy comments and suggestions to the layout in some scenarios

Co-authored-by: Casper Hübertz <casper@formgeist.com>
@gbamparop gbamparop mentioned this pull request Dec 6, 2021
2 tasks
@gbamparop gbamparop requested a review from a team December 6, 2021 12:16
@formgeist
Copy link
Contributor

@gbamparop Another request - let me know if you'd rather have a separate issue for this... But I reckon we should move the agent keys closer to the agent configuration in the list of tabs in Settings. Also follows better the alphabetical sorting that (unintentionally) is happening there.

CleanShot 2021-12-06 at 13 30 53@2x

@gbamparop
Copy link
Contributor Author

@formgeist thanks for the feedback! All comments have been addressed in this PR

Copy link
Contributor

@formgeist formgeist left a comment

Choose a reason for hiding this comment

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

LGTM 🚢

Copy link
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

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

Nice work @gbamparop just added a few comments

</EuiCopy>
}
>
<input
Copy link
Contributor

@cauemarcondes cauemarcondes Dec 6, 2021

Choose a reason for hiding this comment

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

Any reason why you didn't use <EuiFieldText/> here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was following the UI pattern from api keys management with a custom EuiFormControlLayout so we can use the prepend and append elements. I could change it if you think there's a better solution

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is addressed in #120765

Comment on lines +49 to +52
const [keyName, setKeyName] = useState('');
const [agentConfigChecked, setAgentConfigChecked] = useState(true);
const [eventWriteChecked, setEventWriteChecked] = useState(true);
const [sourcemapChecked, setSourcemapChecked] = useState(true);
Copy link
Member

@sorenlouv sorenlouv Dec 7, 2021

Choose a reason for hiding this comment

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

WDYT about combining these into a single state?

Suggested change
const [keyName, setKeyName] = useState('');
const [agentConfigChecked, setAgentConfigChecked] = useState(true);
const [eventWriteChecked, setEventWriteChecked] = useState(true);
const [sourcemapChecked, setSourcemapChecked] = useState(true);
const [agentKeyBody, setAgentKeyBody] = useState<AgentKeyBody>({
name: '',
sourcemap: true,
event: true,
agentConfig: true
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a matter of preference and code consistency when working with forms, I normally use different states but happy to change it if a single state is preferred

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to single state in #120765

@gbamparop
Copy link
Contributor Author

@elasticmachine merge upstream

@gbamparop
Copy link
Contributor Author

@cauemarcondes @sqren thanks for the feedback! I have addressed most of the changes, please let me know what you think.

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Test Failures

  • [job] [logs] Default CI Group #1 / APM API tests trial apm_mappings_only_8.0.0 fetching service anomalies with a trial license with ml jobs "before all" hook for "returns a 200 for a user with access to ML"

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 1172 1174 +2

Async chunks

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

id before after diff
apm 2.8MB 2.8MB +5.5KB

History

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

Copy link
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

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

LGTM, great work!

@gbamparop gbamparop merged commit 79e013f into elastic:main Dec 7, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 7, 2021
)

* Add support for creating agent keys

Co-authored-by: Casper Hübertz <casper@formgeist.com>

Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
8.0

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Dec 7, 2021
…120652)

* Add support for creating agent keys

Co-authored-by: Casper Hübertz <casper@formgeist.com>

Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com>

Co-authored-by: Giorgos Bamparopoulos <georgios.bamparopoulos@elastic.co>
Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com>
@gbamparop gbamparop deleted the agent-key-management branch December 8, 2021 12:19
Heenawter pushed a commit to Heenawter/kibana that referenced this pull request Dec 8, 2021
)

* Add support for creating agent keys

Co-authored-by: Casper Hübertz <casper@formgeist.com>

Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com>
Comment on lines +88 to +94
if (!sourcemap && !event && !agentConfig) {
privileges.push(
PrivilegeType.SOURCEMAP,
PrivilegeType.EVENT,
PrivilegeType.AGENT_CONFIG
);
}
Copy link
Member

@sorenlouv sorenlouv Dec 8, 2021

Choose a reason for hiding this comment

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

@gbamparop Just noticing this. So if all 3 are false, we'll add the privileges for all of them anyway. Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed in #120765

Comment on lines +84 to +88
t.partial({
sourcemap: toBooleanRt,
event: toBooleanRt,
agentConfig: toBooleanRt,
}),
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned in the docs, I think this should simply take a list of the privileges, restricted to the 3 APM privileges.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed in #120765

@bmorelli25
Copy link
Member

bmorelli25 commented Dec 9, 2021

Sorry, I too am late to the party 🙃

With Elastic Agent in the picture, I wonder if we should be more descriptive with our UI text. The word "agent" appears a lot on this screen, but it might not be clear to users whether we're referring to Elastic Agent, APM agents, or both. Sure, we're in the APM app, but I don't think that's reason enough for users to assume we're talking about APM agents.

Screen Shot 2021-12-08 at 5 13 22 PM

What if we changed the buttons to each say, Create APM agent key, and changed the description to say, Create APM agent keys to authorize APM agent requests to the APM Server? With that being said, I can see a case for renaming all ..agent... instances to ...APM agent.., except for maybe the tab names at the top.

@formgeist
Copy link
Contributor

@bmorelli25 Very good points, I agree we can be more explicit.

What if we changed the buttons to each say, Create APM agent key, and changed the description to say, Create APM agent keys to authorize APM agent requests to the APM Server? With that being said, I can see a case for renaming all ..agent... instances to ...APM agent.., except for maybe the tab names at the top.

Makes sense to me - will you also look into aligning this in the other tab contents for agent config etc.?

@gbamparop
Copy link
Contributor Author

@bmorelli25 thanks for the feedback, I've changed all ...agent... instances apart from the tab in #120765

TinLe pushed a commit to TinLe/kibana that referenced this pull request Dec 22, 2021
)

* Add support for creating agent keys

Co-authored-by: Casper Hübertz <casper@formgeist.com>

Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com>
@MiriamAparicio MiriamAparicio self-assigned this Dec 22, 2021
@MiriamAparicio MiriamAparicio added the apm:test-plan-done Pull request that was successfully tested during the test plan label Dec 22, 2021
gbamparop added a commit to gbamparop/kibana that referenced this pull request Jan 12, 2022
)

* Add support for creating agent keys

Co-authored-by: Casper Hübertz <casper@formgeist.com>

Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:test-plan-8.0.0 apm:test-plan-done Pull request that was successfully tested during the test plan auto-backport Deprecated - use backport:version if exact versions are needed release_note:feature Makes this part of the condensed release notes Team:APM All issues that need APM UI Team support v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants