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

[Fleet][APM] APM Server via Elastic Agent Fleet is missing permissions to create data stream #85761

Closed
simitt opened this issue Dec 14, 2020 · 10 comments · Fixed by #85802
Closed
Assignees

Comments

@simitt
Copy link
Contributor

simitt commented Dec 14, 2020

Description of the problem including expected versus actual behavior:

When starting APM Server via Elastic Agent integration with Fleet documents ending up in log or metric data streams can be written successfully, but the APM Server raises an error when trying to index span and transaction documents. For these docs a trace dataset should be created, but the API Key received from Fleets is missing privileges to create the data stream.

Logged Error:

 {\"type\":\"security_exception\",\"reason\":\"action [indices:admin/auto_create] is unauthorized for API key id [xxxx] of user [fleet_enroll] on indices [traces-apm-default], this action is granted by the privileges [auto_configure,create_index,manage,all]\"}

Steps to reproduce:

  1. Check out @graphaelli 's branch adding elastic-agent support to the integration testing
  2. Run ./scripts/compose.py start master --with-elastic-agent --no-apm-server
  3. Navigate to the Kibana UI and manually install APM Server integration
  4. log into the docker container docker exec -it <Container-ID> /bin/bash and send an example request to the APM Server that contains all kinds of events. (For now the APM Server port is not exposed, therefore sending the request from inside the container). For the span and transaction docs the mentioned error is logged. The logs can be found under data/elastic-agent-<ID>/logs/default/apm-server-json.log*.
    This is all a bit manual for now, until we have finished integration APM Server under Elastic Agent into the integration testing repo.

cc @ruflin

@ruflin
Copy link
Contributor

ruflin commented Dec 14, 2020

The problem is that these permissions were not given yet to the user in Kibana: https://github.com/elastic/kibana/blob/master/x-pack/plugins/fleet/server/services/setup.ts#L142 @nchaulet Can you take a look?

@simitt
Copy link
Contributor Author

simitt commented Dec 14, 2020

Sure thing, thanks @ruflin .

I also identified that the _index_template is missing the "allow_auto_create" : true, compared to the shipped minimal templates for logs and metrics.

@simitt simitt transferred this issue from elastic/apm-server Dec 14, 2020
@simitt simitt changed the title APM Server via Elastic Agent Fleet is missing permissions to create data stream [Fleet][APM] APM Server via Elastic Agent Fleet is missing permissions to create data stream Dec 14, 2020
@simitt simitt self-assigned this Dec 14, 2020
@nchaulet
Copy link
Member

Yes adding the permission in the fleet setup and here https://github.com/elastic/kibana/blob/master/x-pack/plugins/fleet/server/services/api_keys/index.ts/#L22-L32 should fix the missing permission issue

We do not have a way right now to update the existing API keys so the migration for existing Fleet user from 7.10 to 7.11 will not work for APM out of the box.

@ruflin
Copy link
Contributor

ruflin commented Dec 14, 2020

@nchaulet Can you update an issue around the "update API keys permissions" problem? Would be nice if we would have at least a way to "recreate" API Keys for a set of Elastic Agents or similar to upgrade them.

@simitt
Copy link
Contributor Author

simitt commented Dec 14, 2020

Thanks @ruflin and @nchaulet for the pointers - I added the changes and tested it through - APM Server ingestion works perfectly now with #85802

@nchaulet
Copy link
Member

For 7.11 we are probably not going to support the api key upgrade so we should probably document what users will have to do:

  • to recreate the fleet user POST /fleet/agents/setup {forceRecreate: true} should we expose this in the UI?
  • re-enroll existing agents.

For 7.12 we should probably have a better plan #85777

@jalvz
Copy link
Contributor

jalvz commented Dec 14, 2020

We do not have a way right now to update the existing API keys so the migration for existing Fleet user from 7.10 to 7.11 will not work for APM out of the box.

There is no APM integration in 7.10, so 7.10->7.11 migration for APM should not be a problem, right?
Or did I misunderstand?

@nchaulet
Copy link
Member

@jalvz We already have users using Fleet in 7.10 so that mean the user (fleet_enroll) that create agent API keys already exists with missing permission, and eventually a user can add the APM integration to an existing agent (where the existing API key will miss permission)

@jalvz
Copy link
Contributor

jalvz commented Dec 14, 2020

got it, thanks!

@simitt
Copy link
Contributor Author

simitt commented Dec 14, 2020

to recreate the fleet user POST /fleet/agents/setup {forceRecreate: true} should we expose this in the UI?

I would not expose this in the UI but only cover by documentation for the experimental APM integration, and it sounds like in the longer term #85777 should handle this in a better way anyways.

simitt added a commit that referenced this issue Dec 15, 2020
* Add APM traces index names to Fleet enroll role

* Removes fleet permissions for `events-*` as they became obsolete

fixes #85761
simitt added a commit to simitt/kibana that referenced this issue Dec 15, 2020
* Add APM traces index names to Fleet enroll role

* Removes fleet permissions for `events-*` as they became obsolete

fixes elastic#85761
simitt added a commit that referenced this issue Dec 15, 2020
* Add APM traces index names to Fleet enroll role

* Removes fleet permissions for `events-*` as they became obsolete

fixes #85761
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants