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

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

Open
wants to merge 1 commit into
base: 9.0
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)
@mergify mergify bot requested a review from a team as a code owner March 4, 2025 16:05
@mergify mergify bot added the backport label Mar 4, 2025
@mergify mergify bot requested review from pkoutsovasilis and kaanyalti and removed request for a team March 4, 2025 16:05
@mergify mergify bot assigned cmacknz Mar 4, 2025
@github-actions github-actions bot added enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Mar 4, 2025
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

cc @cmacknz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport enhancement New feature or 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.

2 participants