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

[Elastic-Agent] Use data subfolder as default for process logs #17960

Merged
merged 13 commits into from
Apr 29, 2020
Prev Previous commit
Next Next commit
var run to data path
michalpristas committed Apr 29, 2020
commit 83cec32fef9df20fb489fdcac826506252ea267f
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ const (
logFileFormatWin = "%s\\logs\\%s\\%s"

// args: pipeline name, application name
mbEndpointFileFormat = "unix:///var/run/elastic-agent/%s/%s/%s.sock"
mbEndpointFileFormat = "unix://%s/run/%s/%s/%s.sock"
// args: pipeline name, application name
mbEndpointFileFormatWin = `npipe:///%s-%s`
)
@@ -27,7 +27,7 @@ func getMonitoringEndpoint(program, operatingSystem, pipelineID string) string {
return fmt.Sprintf(mbEndpointFileFormatWin, pipelineID, program)
}

return fmt.Sprintf(mbEndpointFileFormat, pipelineID, program, program)
return fmt.Sprintf(mbEndpointFileFormat, paths.Data(), pipelineID, program, program)
}

func getLoggingFile(program, operatingSystem, installPath, pipelineID string) string {
8 changes: 2 additions & 6 deletions x-pack/elastic-agent/pkg/core/plugin/app/start.go
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import (

"gopkg.in/yaml.v2"

"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/paths"
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors"
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/authority"
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/process"
@@ -210,12 +211,7 @@ func (a *Application) checkGrpcHTTP(ctx context.Context, address string, ca *aut
}

func injectDataPath(args []string, pipelineID, id string) []string {
wd := ""
if w, err := os.Getwd(); err == nil {
wd = w
}

dataPath := filepath.Join(wd, "data", pipelineID, id)
dataPath := filepath.Join(paths.Data(), pipelineID, id)
return append(args, "-E", "path.data="+dataPath)
}