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

[Ingest Manager] New structure of agent configuration #19128

Merged
merged 10 commits into from
Jun 17, 2020

Conversation

michalpristas
Copy link
Contributor

What does this PR do?

This PR implements all 4 phases of configuration change described here #19082

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

@michalpristas michalpristas added review needs_backport PR is waiting to be backported to other branches. Team:Ingest Management Ingest Management:beta1 Group issues for ingest management beta1 labels Jun 11, 2020
@michalpristas michalpristas self-assigned this Jun 11, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ingest-management (Team:Ingest Management)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jun 11, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jun 11, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #19128 updated]

  • Start Time: 2020-06-17T11:47:13.856+0000

  • Duration: 52 min 13 sec

Test stats 🧪

Test Results
Failed 0
Passed 538
Skipped 127
Total 665

for _, datasourceNode := range datasourcesList.value {
nsNode, found := datasourceNode.Find("namespace")
for _, inputNode := range inputsNodeList.value {
nsNode, found := inputNode.Find("dataset.namespace")
Copy link
Contributor

Choose a reason for hiding this comment

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

Will Find("dataset.namespace") handle the fact that dataset could be a dictionary in the configuration:

dataset:
  namespace: default
  name: other

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no in fact it will not, i added support for both just to be sure

vars:
var: value
- type: apache/metrics
dataset.namespace: testing
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably good to add one of these tests files to use:

dataset:
  namespace: testing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you mean with invalid key?
keys we dont know are passed to input by default

Copy link
Contributor

Choose a reason for hiding this comment

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

No I mean add a test to ensure that dataset.namespace: testing or

dataset:
  namespace: testing

Both work

addFieldsMap := &Dict{value: []Node{&Key{"add_fields", processorMap}}}
processorsList.value = mergeStrategy(r.OnConflict).InjectItem(processorsList.value, addFieldsMap)

// add this for backwards compatibility remove later
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a general question: When is the remove later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

up to stack when they remove support for this

Copy link
Contributor

Choose a reason for hiding this comment

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

later is now :-) this was only a short transition where we needed it.

Copy link
Contributor

@blakerouse blakerouse 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.

@michalpristas
Copy link
Contributor Author

NOTE: do not merge until @ruflin gives a green light

- namespace: default
inputs:
- type: system/metrics
dataset.namespace: default
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you already have support for dataset.type? I don't think we need it in this PR but curious if you added it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep dataset.type is supported

@@ -4,7 +4,6 @@ filebeat:
paths:
- /var/log/hello1.log
- /var/log/hello2.log
dataset: generic
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this become dataset.name instead of removing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes this became dataset.name thing is we injected it previously which i think is incorrect as we're providing processor to enrich event. if you think this information is helpful in a final beat config i will add it back but for now i filtered it out

Copy link
Contributor

Choose a reason for hiding this comment

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

Even if the Beat does not understand it today, I think in the future the Beat should so having it there already would be helpful. Can happen in a later PR.

type: testtype
name: generic
namespace: default
- add_fields:
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to this PR but can you follow up to make sure we clean up the stream fields?

id: apache-metrics-id
streams:
- metricset: status
dataset:
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume dataset.name and

dataset:
  name: foo

work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah it was a bit tricky as transpiler understands dataset.name as a single key but i made both versions work

var: value
- type: logs
dataset:
type: testtype
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

if !ok {
continue
dsNode, found := inputNode.Find("dataset")
if found {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks pretty scary! Would be nice if ew can find a way to simplify this.

addFieldsMap := &Dict{value: []Node{&Key{"add_fields", processorMap}}}
processorsList.value = mergeStrategy(r.OnConflict).InjectItem(processorsList.value, addFieldsMap)

// add this for backwards compatibility remove later
Copy link
Contributor

Choose a reason for hiding this comment

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

later is now :-) this was only a short transition where we needed it.

func datasetNamespaceFromInputNode(inputNode Node) string {
const defaultNamespace = "default"

if namespaceNode, found := inputNode.Find("dataset.namespace"); found {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we have very similar code in several places. Two things I'm wondering: Could go-ucfg to this for you and if not, could we extract it into a method?

@ruflin
Copy link
Contributor

ruflin commented Jun 16, 2020

Tried to test it together with elastic/kibana#69226 but didn't work yet. Not sure if the problem is in KB, Agent or a general issue. Overall changes LGTM.

@michalpristas
Copy link
Contributor Author

tested and setting dataset.type to system/metrics causes auth issues. when i set it to metrics it works fine

@ruflin
Copy link
Contributor

ruflin commented Jun 17, 2020

Makes sense as dataset.type: system/metrics is not a valid type. Does it work with the most recent Kibana changes?

@michalpristas
Copy link
Contributor Author

Tested with latest kibana changes ok

@michalpristas michalpristas merged commit 3e4b0c6 into elastic:master Jun 17, 2020
michalpristas added a commit to michalpristas/beats that referenced this pull request Jun 18, 2020
* phase 1

* phase 2

* phase 4

* updated configuration

* fixed compact form (depends on aprser)

* configuration update

* fixed tests

* mod
michalpristas added a commit that referenced this pull request Jun 24, 2020
* phase 1

* phase 2

* phase 4

* updated configuration

* fixed compact form (depends on aprser)

* configuration update

* fixed tests

* mod
melchiormoulin pushed a commit to melchiormoulin/beats that referenced this pull request Oct 14, 2020
* phase 1

* phase 2

* phase 4

* updated configuration

* fixed compact form (depends on aprser)

* configuration update

* fixed tests

* mod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ingest Management:beta1 Group issues for ingest management beta1 needs_backport PR is waiting to be backported to other branches. review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants