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

[8.17](backport #7029) Add the full set of ECS metadata sent to Fleet to Diagnostics #7179

Open
wants to merge 2 commits into
base: 8.17
Choose a base branch
from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Mar 4, 2025

What does this PR do?

Adds the full set of ECS metadata that is sent to Fleet when the agent checks in to diagnostics. If you don't know what that is, it's this:

ecsMeta, err := info.Metadata(ctx, f.log)
if err != nil {
f.log.Error(errors.New("failed to load metadata", err))
}

// ECSMeta is a collection of agent related metadata in ECS compliant object form.
type ECSMeta struct {
Elastic *ElasticECSMeta `json:"elastic"`
Host *HostECSMeta `json:"host"`
OS *SystemECSMeta `json:"os"`
}

Why is it important?

When all providers were enabled by default, you were able to get the information about the host from the host provider (hostname, OS version, etc) in the variables.yaml file. Now that providers are only enabled when referenced explicitly in the policy, the content of the variables.yaml file is by default:

variables:
    - {}

This makes sure that detailed information about the host is available in diagnostics all the time separately from providers. This is useful if you are say, debugging why you can't find agent by the hostname you think it should have in Fleet. The format of the agent-info.yaml file now looks like:

headers: {}
log_level: info
log_level_raw: info
metadata:
    elastic:
        agent:
            buildoriginal: '9.1.0-SNAPSHOT (build: d2047ac48df2f4536ca69a86ad4922b3e264501a at 2025-02-25 21:52:49 +0000 UTC)'
            complete: false
            id: 9ba45d59-e33f-42c7-a47d-50a9a37705ef
            loglevel: info
            snapshot: true
            unprivileged: false
            upgradeable: true
            version: 9.1.0
    host:
        arch: arm64
        hostname: Craigs-Macbook-Pro.local
        id: 48DA13D6-B83B-5C71-A4F3-494E674F9F37
        ip:
            - 127.0.0.1/8
            - ...
        mac:
            - ...
        name: craigs-macbook-pro.local
    os:
        family: darwin
        fullname: macOS(14.7.3)
        kernel: 23.6.0
        name: macOS
        platform: darwin
        version: 14.7.3

Disruptive User Impact

I removed some of the duplicated keys from the top level of agent-info.yaml. I am assuming nobody was relying on this in a critical way.

How to test this PR locally

elastic-development-agent diagnostics and then read the agent-info.yaml file.


This is an automatic backport of pull request #7029 done by [Mergify](https://mergify.com).

* Add metadata to diagnostics

* Add changelog.

* Update agent info mock.

* Add missing method to manual mock.

(cherry picked from commit d668787)

# Conflicts:
#	testing/mocks/internal_/pkg/agent/application/info/agent_mock.go
@mergify mergify bot requested a review from a team as a code owner March 4, 2025 16:04
@mergify mergify bot added backport conflicts There is a conflict in the backported pull request labels Mar 4, 2025
@mergify mergify bot requested review from swiatekm and pchila and removed request for a team March 4, 2025 16:04
@mergify mergify bot assigned cmacknz Mar 4, 2025
Copy link
Contributor Author

mergify bot commented Mar 4, 2025

Cherry-pick of d668787 has failed:

On branch mergify/bp/8.17/pr-7029
Your branch is up to date with 'origin/8.17'.

You are currently cherry-picking commit d6687876c.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   changelog/fragments/1740521494-diagnostics-include-all-metadata-that-is-sent-to-Fleet-by-default.yaml
	modified:   internal/pkg/agent/application/coordinator/coordinator.go
	modified:   internal/pkg/agent/application/coordinator/diagnostics_test.go
	modified:   internal/pkg/agent/application/info/agent_info.go
	modified:   pkg/component/runtime/runtime_comm_test.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   testing/mocks/internal_/pkg/agent/application/info/agent_mock.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Mar 4, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@elasticmachine
Copy link
Contributor

elasticmachine commented Mar 4, 2025

⏳ Build in-progress, with failures

Failed CI Steps

History

cc @cmacknz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport conflicts There is a conflict in the backported pull request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants