Skip to content

Commit

Permalink
Fix lookup issues with inputs.d fragment yml (#840)
Browse files Browse the repository at this point in the history
* Fix lookup issues with inputs.d fragment yml

The Elastic Agent was looking next to the binary for the `inputs.d`
folder instead it should look up into the `Home` folder where
the Elastic Agent symlink is located.

Fixes: #663

* Changelog

* Fix input.d path, tie to the agent Config() directory

* Update CHANGELOG to reflect that the agent configuration directory is used to locate the inputs.d directory

Co-authored-by: Aleksandr Maus <[email protected]>
  • Loading branch information
ph and aleksmaus authored Aug 31, 2022
1 parent f3852cf commit 2522be4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
- Allow the / char in variable names in eql and transpiler. {issue}715[715] {pull}718[718]
- Fix data duplication for standalone agent on Kubernetes using the default manifest {issue-beats}31512[31512] {pull}742[742]
- Agent updates will clean up unneeded artifacts. {issue}693[693] {issue}694[694] {pull}752[752]
- Use the Elastic Agent configuration directory as the root of the `inputs.d` folder. {issues}663[663]
- Fix a panic caused by a race condition when installing the Elastic Agent. {issues}806[806]

==== New features
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/application/local_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func newLocal(
}

func externalConfigsGlob() string {
return filepath.Join(paths.Config(), configuration.ExternalInputsPattern)
return filepath.Join(paths.AgentInputsDPath(), "*.yml")
}

// Routes returns a list of routes handled by agent.
Expand Down
8 changes: 8 additions & 0 deletions internal/pkg/agent/application/paths/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const defaultAgentStateStoreYmlFile = "state.yml"
// defaultAgentStateStoreFile is the file that will contain the action that can be replayed after restart encrypted.
const defaultAgentStateStoreFile = "state.enc"

// defaultInputDPath return the location of the inputs.d.
const defaultInputsDPath = "inputs.d"

// AgentConfigYmlFile is a name of file used to store agent information
func AgentConfigYmlFile() string {
return filepath.Join(Config(), defaultAgentFleetYmlFile)
Expand Down Expand Up @@ -82,3 +85,8 @@ func AgentStateStoreYmlFile() string {
func AgentStateStoreFile() string {
return filepath.Join(Home(), defaultAgentStateStoreFile)
}

// AgentInputsDPath is directory that contains the fragment of inputs yaml for K8s deployment.
func AgentInputsDPath() string {
return filepath.Join(Config(), defaultInputsDPath)
}
5 changes: 0 additions & 5 deletions internal/pkg/agent/configuration/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
package configuration

import (
"path/filepath"

"github.com/elastic/elastic-agent/internal/pkg/artifact"
monitoringCfg "github.com/elastic/elastic-agent/internal/pkg/core/monitoring/config"
"github.com/elastic/elastic-agent/internal/pkg/core/process"
Expand All @@ -15,9 +13,6 @@ import (
"github.com/elastic/elastic-agent/pkg/core/server"
)

// ExternalInputsPattern is a glob that matches the paths of external configuration files.
var ExternalInputsPattern = filepath.Join("inputs.d", "*.yml")

// SettingsConfig is an collection of agent settings configuration.
type SettingsConfig struct {
DownloadConfig *artifact.Config `yaml:"download" config:"download" json:"download"`
Expand Down

0 comments on commit 2522be4

Please sign in to comment.