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

Add flags to allow for routing to dynamic datasets and namespaces #327

Merged
merged 10 commits into from
Nov 17, 2022

Conversation

felixbarny
Copy link
Member

@felixbarny felixbarny commented Apr 29, 2022

What does this PR do?

Adds data_stream.elasticsearch.dynamic_dataset/data_stream.elasticsearch.dynamic_namespace.

When set to true, instead of granting permissions to the exact data stream the integration is sending data to (for example logs-router-default), it grants permissions for all datasets and namespaces, respectively, for the data_stream.type (for example (logs-*-*).

Why is it important?

This is required for event routing. Instead of creating an API key that has permissions for an exact data stream, such as logs-generic-default, in event routing situations, the target data stream is determined within an ingest node pipeline.

See also

Checklist

Related issues

@felixbarny felixbarny requested review from ruflin and joshdover April 29, 2022 18:09
@felixbarny felixbarny requested a review from a team as a code owner April 29, 2022 18:09
@elasticmachine
Copy link

elasticmachine commented Apr 29, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-11-17T15:05:41.151+0000

  • Duration: 9 min 25 sec

Test stats 🧪

Test Results
Failed 0
Passed 658
Skipped 0
Total 658

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@ruflin
Copy link
Member

ruflin commented May 2, 2022

I made a different proposal directly in the spec to use existing Elasticsearch primitives. Instead of having something routing specific it would allow any package to specify additional privileges. But Fleet should at some point inform users about these additional privileges.

@ruflin
Copy link
Member

ruflin commented May 3, 2022

@joshdover @jsoriano @aspacca Would be good to get some additional opinions on the discussion in #327 (comment) Most important, lets get this moving forward.

test/packages/good/data_stream/foo/manifest.yml Outdated Show resolved Hide resolved
versions/1/integration/data_stream/manifest.spec.yml Outdated Show resolved Hide resolved
versions/1/integration/data_stream/manifest.spec.yml Outdated Show resolved Hide resolved
joshdover
joshdover previously approved these changes May 4, 2022
Copy link
Contributor

@joshdover joshdover left a comment

Choose a reason for hiding this comment

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

One suggestion on the description but overall LGTM.

@mtojek, question: do we have a way to specify new fields in the package-spec that aren’t considered “stable”? It’d be nice to be able to add fields to the spec to allow experimentation with new features before we make a hard commitment to it. We may want to explore other ways of configuring a feature in the future.

That said, I’m ok with this one going forward anyways, since it supporting it from the Fleet side should be quite trivial, but just something I think we should be thinking about. Being able to mark a package-spec field as beta or experimental could be valuable.

versions/1/integration/data_stream/manifest.spec.yml Outdated Show resolved Hide resolved
@ruflin
Copy link
Member

ruflin commented May 5, 2022

@joshdover It would be great if the PR for this feature on the Fleet side could be opened in parallel, so it can be merged at the same time. Otherwise I'm worried we have the case that it is in the for but not in Fleet yet.

@mtojek
Copy link
Contributor

mtojek commented May 5, 2022

@mtojek, question: do we have a way to specify new fields in the package-spec that aren’t considered “stable”? It’d be nice to be able to add fields to the spec to allow experimentation with new features before we make a hard commitment to it. We may want to explore other ways of configuring a feature in the future.

I'm afraid that we don't have it at the moment as it seems to be hard to ensure compatibility with stacks. Consider the case, when the field is beta, but its type changes once it's GA. It's hard to predict the consequences of it.

@mtojek mtojek self-requested a review May 5, 2022 08:11
mtojek
mtojek previously approved these changes May 5, 2022
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

LGTM from the Ecosystem team, let's wait for @joshdover's official approval.

@joshdover
Copy link
Contributor

@joshdover It would be great if the PR for this feature on the Fleet side could be opened in parallel, so it can be merged at the same time. Otherwise I'm worried we have the case that it is in the for but not in Fleet yet.

I started implementing this in elastic/kibana#131609 but found that it’s going to be dependent on elastic/kibana#115032 which I am assigned to for 8.3 and may be able to finish up this week. The issue is that we’re not reading the data stream information directly from the packages today, we’re using the registry API’s summary during package installation. We want to stop duplicating all of these fields that are only used during install and pull this info directly from the package instead.

I’ll follow up finishing this up after the blocking task is done. The amount of work is very small.

@felixbarny
Copy link
Member Author

Are the dependent tasks still expected to land in 8.3?

@joshdover
Copy link
Contributor

Are the dependent tasks still expected to land in 8.3?

They got delayed, but I have requested they are included for 8.4.

@@ -1,5 +1,6 @@
title: Nginx access logs
type: logs
allow_routing: true
Copy link
Member

Choose a reason for hiding this comment

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

As this is related to elasticsearch configuration, I think it could be at the root level of elasticsearch, even if it doesn't belong to the elasticsearch.privileges object #327 (comment).

We did something similar for the time series mode in https://github.com/elastic/package-spec/pull/357/files.

Copy link
Member

Choose a reason for hiding this comment

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

@felixbarny is this change still required? Wdyt about placing this parameter under elasticsearch object?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is still required. Are all the blockers resolved now? I don’t care so much about where the flag is. Happy to change it to be under elasticsearch if you think that’s a better place.

Copy link
Member

Choose a reason for hiding this comment

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

This blocker was solved elastic/kibana#115032, not sure if there were any others.

Yes, please update the branch to put the new setting under elasticsearch. We removed the versions directory, so you will also need to move the changes to the new structure.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've moved it and renamed and split the property so that it's both more self-explanatory and flexible.

@felixbarny felixbarny changed the title Add data_stream.elasticsearch.privileges.allow_routing flag Add flags to allow for routing to dynamic datasets and namespaces Nov 16, 2022
@elasticmachine
Copy link

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (7/7) 💚
Files 68.0% (17/25) 👍
Classes 76.471% (26/34) 👍
Methods 56.075% (60/107) 👍
Lines 42.229% (538/1274) 👍
Conditionals 100.0% (0/0) 💚

jsoriano
jsoriano previously approved these changes Nov 16, 2022
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

LGTM, do you know if there is an open issue in kibana to support these settings?

@jsoriano
Copy link
Member

LGTM, do you know if there is an open issue in kibana to support these settings?

I guess it is this one elastic/kibana#134971

@jsoriano jsoriano merged commit 2ba2d4d into elastic:main Nov 17, 2022
@joshdover
Copy link
Contributor

We've had a use case come up that this is close to solving but doesn't quite hit the mark.

Users may want to add custom routing to ingest pipelines created for input-type packages to route to more specific pipelines. To do this, it'd be required that the API key granted to the Agent running the integration has adequate privileges. Ideally, this wouldn't be turned on by default, and instead would be an option in the integration policy, rather than always on for all instances of an input package.

@jsoriano what do you think about extending this package-spec option to be allow_routing: false | true | 'optional'? This would allow to expose this option in the integration policy editor in the UI.

@jsoriano
Copy link
Member

jsoriano commented Nov 23, 2022

Users may want to add custom routing to ingest pipelines created for input-type packages to route to more specific pipelines.

This would allow to expose this option in the integration policy editor in the UI.

Is this something that we would want for some packages but not for others? If we add the flag to the package spec, we are making package developers to take the decision on this, but this looks like something that the user should decide.

If a user adds custom routing using the integration policy editor, Fleet could (should?) ensure that the Agent receives an API key with adequate privileges. This doesn't look like a responsibility of the package developer.

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 this pull request may close these issues.

[Change Proposal] Ability to add privileges for all data streams of a specific type
6 participants