Skip to content

Uninstalling or reinstalling the Elastic Agent is not possible when it has been started with an invalid configuration. #8675

@VihasMakwana

Description

@VihasMakwana

When we try installing agent with following inputs config:

inputs:
  - type: system/metrics
    id: unique-system-metrics-input
    data_stream.namespace: default
    use_output: default
    streams:
      - metricsets:
        - cpu
        data_stream.dataset: system.cpu
      - metricsets:
        - memory
        data_stream.dataset: system.memory

  - type: system/metrics
    id: unique-system-metrics-input
    data_stream.namespace: default
    use_output: default
    streams:
      - metricsets:
        - network
        data_stream.dataset: system.network
      - metricsets:
        - filesystem
        data_stream.dataset: system.filesystem

the agent installs successfully but fails to run with

Invalid component model: failed to render components: invalid 'inputs.1.id', has a duplicate id "unique-system-metrics-input". Please add a unique value for the 'id' key to each input in the agent policy

becasue both the inputs have same id.

However, when we try to reinstall agent with correct configuration , it fails with following logs:

# command

sudo ./elastic-agent install --develop --unprivileged --force 

# output

Unprivileged installation mode enabled; this feature is currently in beta.
Installing into development namespace; this is an experimental and currently unsupported feature.

[    ] Uninstalling current Elastic Agent - Development  [0s] 
[    ] Stopping service  [0s] 
                              

[    ] Successfully stopped service  [0s] 
                                          

[   =] Stopping upgrade watcher; none found  [0s] 
                                                  

[   =] Failed to uninstall agent  [0s] Error uninstalling. Printing logs
2025-06-25T12:07:34.937Z	DEBUG	[uninstall]	Loaded configuration from /Library/Elastic/Agent-Development/elastic-agent.yml
2025-06-25T12:07:34.937Z	DEBUG	[uninstall]	Merged configuration from /Library/Elastic/Agent-Development/elastic-agent.yml into result
2025-06-25T12:07:34.937Z	DEBUG	[uninstall]	Merged all configuration files from [/Library/Elastic/Agent-Development/elastic-agent.yml], no external input files
2025-06-25T12:07:35.051Z	DEBUG	[uninstall]	Loaded configuration from /Library/Elastic/Agent-Development/elastic-agent.yml
2025-06-25T12:07:35.051Z	DEBUG	[uninstall]	Merged configuration from /Library/Elastic/Agent-Development/elastic-agent.yml into result
2025-06-25T12:07:35.051Z	DEBUG	[uninstall]	Merged all configuration files from [/Library/Elastic/Agent-Development/elastic-agent.yml], no external input files
2025-06-25T12:07:35.051Z	DEBUG	[uninstall.composable]	Starting controller for composable inputs
2025-06-25T12:07:35.051Z	DEBUG	[uninstall.composable]	Started controller for composable inputs
2025-06-25T12:07:35.051Z	DEBUG	[uninstall.composable]	Computing new variable state for composable inputs
2025-06-25T12:07:35.051Z	DEBUG	[uninstall.composable]	Stopping controller for composable inputs
2025-06-25T12:07:35.051Z	DEBUG	[uninstall.composable]	Stopped controller for composable inputs
Error: error uninstalling agent: error uninstalling components: error creating service components: failed to render components: invalid 'inputs.1.id', has a duplicate id "unique-system-metrics-input". Please add a unique value for the 'id' key to each input in the agent policy
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/9.1/fleet-troubleshooting.html

                                                              

[  ==] Uninstall failed  [0s] Error: failed to uninstall elastic-agent: exit status 1
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/9.1/fleet-troubleshooting.html

Workaround on MacOS

The workaround is to manually remove the daemon file and also remove the agent directory:

rm -rf /Library/Elastic/Agent-Development
rm /Library/LaunchDaemons/co.elastic.elastic-agent-Development.plist

I believe the user would need to perform similar manual steps for other OS'.

I think we should handle this scenario while uninstalling the agent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions