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

[Beats] Adding support for elastic-agent-autodiscovery v0.6.13 Introduce log message for not supported annotations #38213

Merged
merged 46 commits into from Apr 25, 2024

Conversation

gizas
Copy link
Contributor

@gizas gizas commented Mar 7, 2024

Note: Dont merge until elastic/elastic-agent-autodiscover#81 is merged.
We need to udpate go.mod of the beats with v0.6.9
PR is merged

  • Enhancement

Proposed commit message

Relates with the updates of shared elastic/elastic-agent-autodiscover#81.
In more details we updated utils.GenerateHints to be able to check whether the provided annotation follows the supported format and vocabulary. The check happens for annotations that have prefix co.elastic

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.

How to test this PR locally

  1. Checkout this branch
  2. Update hints.go file of your /go/pkg/mod/github.com/elastic/elastic-agent-autodiscover@v0.6.8/utils as per hints.go
  3. Build metricbeat/ filebeat locally (as per doc)
  4. Configure autodiscovery in your manifest
  5. Configure some "wrong" co.elastic.hints annotation inside a pod.
  6. Warning messages should be available.

Related issues

Logs

Copy link
Contributor

mergify bot commented Mar 7, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @gizas? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@mergify mergify bot assigned gizas Mar 7, 2024
@gizas gizas added the Team:Cloudnative-Monitoring Label for the Cloud Native Monitoring team label Mar 7, 2024
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Mar 7, 2024
@gizas gizas changed the title adding support for logshints and autodiscovery 0.6.9 [Beats] Adding support for elastic-agent-autodiscovery 0.6.9. Introduce log message for not supported annotations Mar 7, 2024
@elasticmachine
Copy link
Collaborator

elasticmachine commented Mar 7, 2024

💚 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: 2024-04-25T13:53:54.847+0000

  • Duration: 241 min 42 sec

Test stats 🧪

Test Results
Failed 0
Passed 28811
Skipped 1911
Total 30722

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

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

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@gizas gizas marked this pull request as ready for review March 8, 2024 10:20
@gizas gizas requested review from a team as code owners March 8, 2024 10:20
@@ -30,6 +30,8 @@ import (
"github.com/elastic/elastic-agent-libs/logp"
)

var AllSupportedHints = []string{"enabled", "module", "metricsets", "host", "period", "timeout", "metricspath", "username", "password", "stream", "processors", "multiline", "json", "disable", "ssl", "metrics_filters", "raw", "include_lines", "exclude_lines", "fileset", "pipeline"}
Copy link
Contributor

Choose a reason for hiding this comment

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

does metricspath actually works? shouldn't it be metrics_path based on https://www.elastic.co/guide/en/beats/metricbeat/current/configuration-autodiscover-hints.html#_co_elastic_metricsmetrics_path ?

where disable is coming from?

Also as I understand it is a merged list for the metricbeat and for the filebeat, correct? can you please add a comment for that? Is there any way to split it?

Copy link
Contributor Author

@gizas gizas Mar 13, 2024

Choose a reason for hiding this comment

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

I changed metricspath to metrics_path ! Nice catch, thanks Tania!

Disable comes from this: https://github.com/elastic/elastic-agent-autodiscover/blob/7490558445cb8d3248462255edc8ac64bc18b8eb/utils/hints_test.go#L177
We can disable logs collection apparently

I have added a comment in 7d2c429

Currently we parse annotations based on the fact that start with the prefix (L209) and then we split with "/" symbol (L215)
So currently this is a unified solution for elastic-agent and beats. I deliberately had moved the solution to the elastic-agent-autodiscovery in oder not to introduce an additional annotation loop and different implementations. So splitting it for beats will require additional checks if we have Prefix.logs or Prefix.metrics. I consider it out of scope here, mainly because the main reason behind those changes, is to offer the feature in elastic-agent and not in beats. Hope it makes sense

@@ -383,7 +383,7 @@ func (d *Provider) generateHints(event bus.Event) bus.Event {
e["ports"] = ports
}
if labels, err := dockerMeta.GetValue("labels"); err == nil {
hints := utils.GenerateHints(labels.(mapstr.M), "", d.config.Prefix)
hints, _ := utils.GenerateHints(labels.(mapstr.M), "", d.config.Prefix, []string{})
Copy link
Contributor

Choose a reason for hiding this comment

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

didn't know we call GenerateHints here. Looking on this use case, wondering if it wouldn't be a better option to introduce additionally smth like GenerateHintsWithValidation instead - maybe we should consider it in future for cases when signature is changed

Copy link
Contributor

Choose a reason for hiding this comment

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

Here GenerateHints will actually return all hints as incorrect but we just ignore them. I think we should make it more clear. Maybe add a bool (validate), which is then checked in GenerateHints

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@rdner rdner left a comment

Choose a reason for hiding this comment

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

There is still one more linter issue to be resolved but the rest looks good to me.

@gizas
Copy link
Contributor Author

gizas commented Apr 24, 2024

@rdner I added the skip based on comment becaus this is a test f3b6f21#diff-9f24ba274864b933a726842c2b9fb8ee487a13545579938f9e373d0463611142R2200

@gizas
Copy link
Contributor Author

gizas commented Apr 24, 2024

@gizas
Copy link
Contributor Author

gizas commented Apr 24, 2024

@elastic/beats-tech-leads can I have a review here as well?

Copy link
Contributor

mergify bot commented Apr 24, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b logshints upstream/logshints
git merge upstream/main
git push upstream logshints

@rdner
Copy link
Member

rdner commented Apr 24, 2024

@rdner have you seen this https://github.com/elastic/beats/actions/runs/8813847492/job/24193021847?pr=38213 again?

@gizas Looks like something is wrong with the Ubuntu itself, it failed on buildkite too. I think we should try to restart, I'm going to update the branch.

@gizas
Copy link
Contributor Author

gizas commented Apr 25, 2024

@rdner this looks better now. I tried to upddate the go.mod and align it as well. The failing tests (mainly related to Windows) I think are not related with changes here

Copy link
Contributor

@lalit-satapathy lalit-satapathy left a comment

Choose a reason for hiding this comment

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

Codeowner approval.

@gizas gizas enabled auto-merge (squash) April 25, 2024 14:00
@gizas gizas disabled auto-merge April 25, 2024 14:21
@gizas gizas enabled auto-merge (squash) April 25, 2024 14:22
@gizas gizas merged commit 5d1b442 into main Apr 25, 2024
218 checks passed
@gizas gizas deleted the logshints branch April 25, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Cloudnative-Monitoring Label for the Cloud Native Monitoring team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants