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

Directory layout and data path #1371

Closed
14 tasks done
tsg opened this issue Apr 11, 2016 · 3 comments
Closed
14 tasks done

Directory layout and data path #1371

tsg opened this issue Apr 11, 2016 · 3 comments
Labels
enhancement in progress Pull request is currently in progress. meta

Comments

@tsg
Copy link
Contributor

tsg commented Apr 11, 2016

This a meta issue for the tasks required to support a "data path" in Beats.

The end goal is to have:

  • A clear location for the Filebeat/Winlogbeat registry files. This fixes the issue where the registry file was created in the home directory of the user.
  • Make it possible to load the template when running as a service in Windows. Fixes issue: Loading the template by default doesn't work on Windows when running as a serivce #1315
  • Provide a path for a persistent UUID, which we will need when implementing configuration management.
  • Have a clear location for storing the Kibana dashboards

The following configurable "paths" are introduced:

Description Default
path.home It’s the default folder for everything that doesn't fit in the categories before {binary directory}
path.data Contains things that are expected to change often during normal operations (“registry” files, UUID file, etc.) {path.home}/data
path.config Configuration file location {path.home}
path.logs Default path for log files. {path.home}/logs

This is modeled after Elasticsearch directory layout with some differences:

  • Not all path types are present. We might introduce more as we feel the need.
  • path.config has the same default as path.home. This is because in beats we don't have a config/ folder, and introducing one would be difficult because we have a config package.

Directory layouts

Illustrating these with Filebeat.

ZIP / TAR.GZ / TGZ

When running directly under the tarball archives, everything is relative to the binary location. This also matches the organization of the source code repository, so things should work the same when running from a source checkout.

    filebeat      
    filebeat.yml
    filebeat.template.json
    data/
       registry.json
       filebeat.uuid
    kibana/
      load.sh
      searches/
      visualisations/
      dashboards/
      index-patterns/

To run, you typically just start with: ./filebeat

DEB/RPM

Debian/Centos packages have their home path set to /usr/share/filebeat and their data path set to /var/lib/filebeat, to match current installations.

/usr/share/filebeat/
   bin/
     filebeat-god
     filebeat
   kibana/
        load.sh
        searches/
        visualisations/
        dashboards/
        index-patterns/
/etc/filebeat/
    filebeat.yml
    filebeat.template.json
/var/lib/filebeat/
    registry.json
    filebeat.uuid

The init scripts, start filebeat with:

   /usr/share/filebeat/filebeat --path.data /var/lib/filebeat
                                             --path.config /etc/filebeat/

The downside of moving the binary out of /usr/bin is that it gets a bit more complex to run in foreground from an installed system. This is because the binary is not in the system PATH anymore and because the data path and config paths need to be set correctly. We could mitigate this by providing a shell script in /usr/bin.

Windows

On Windows there are two options. Either run directly from the unzipped directory, in which case everything works as for the tar/zip case, or you install as a service. If you install as a service, the data path is set to c:\ProgramData\filebeat, so the we have the following structure:

{extractpath}/
   filebeat
   filebeat.template.json
   filebeat.yml
   dashboards/
        load.sh
        searches/
        visualisations/
c:\programdata\filebeat
   registry.json
   filebeat.uuid

The service will start filebeat with:

  $extractpath/filebeat -path.data c:\programdata\filebeat

This is not ideal yet, but matches pretty much what we have so far, fixes the automatic template loading and can be improved when we get a real Windows installer.

Required changes

@ruflin
Copy link
Member

ruflin commented Apr 11, 2016

I like the proposal. You state path.config has the same default as path.data, this should be path.home, right?

Could it make sense to add these also as configuration option to the config file? This would allow to run beat -c path/config.yml and the other paths would be read from the config file.

For the data directory, should we add it to the git repository but ignore all files inside?

@tsg
Copy link
Contributor Author

tsg commented Apr 11, 2016

I like the proposal. You state path.config has the same default as path.data, this should be path.home, right?

Yep, fixed :-).

Could it make sense to add these also as configuration option to the config file? This would allow to run beat -c path/config.yml and the other paths would be read from the config file.

Yeah, they are configuration options, see #1373. The plan is that after elastic/go-ucfg#15 is implemented, they will only be configuration file options, which can be overwritten from the command line.

For the data directory, should we add it to the git repository but ignore all files inside?

I'll add /data/ to .gitignore. The beats are creating the path automatically if it doesn't exist.

tsg pushed a commit to tsg/beats that referenced this issue Apr 13, 2016
* Follows the layout as defined in elastic#1371, setting path.home, path.config
  and path.data
* This removes the need to adjust the configuration file
@tsg tsg mentioned this issue Apr 13, 2016
tsg pushed a commit to tsg/beats that referenced this issue Apr 20, 2016
This adds the `-path.logs` CLI flag and corresponding config file
setting. By default it's set to `{path.home}/logs`. The rotating
file writer now writes to this path by default.

For DEB/RPM, the logs path is set to `/var/log/{beatname}` which
matches the previous default location. However, this is a breaking
change because the previous default was to send the logs to syslog.

Part of elastic#1371.
tsg pushed a commit to tsg/beats that referenced this issue Apr 21, 2016
For Deb and Rpm installations. This makes it easy to run the Beat
in foreground, while still being executed with the write paths.
Part of elastic#1371.
ruflin pushed a commit that referenced this issue Apr 21, 2016
This adds the `-path.logs` CLI flag and corresponding config file
setting. By default it's set to `{path.home}/logs`. The rotating
file writer now writes to this path by default.

For DEB/RPM, the logs path is set to `/var/log/{beatname}` which
matches the previous default location. However, this is a breaking
change because the previous default was to send the logs to syslog.

* Added path.logs and made logging to files the default
* Updated CHANGELOG
* Removed unreachable code

Part of #1371.
ruflin pushed a commit that referenced this issue Apr 21, 2016
For Deb and Rpm installations. This makes it easy to run the Beat in foreground, while still being executed with the write paths.

* Fix postinst script
* Added beatname.sh in /usr/bin

Part of #1371.
@monicasarbu monicasarbu added the in progress Pull request is currently in progress. label Apr 21, 2016
@tsg
Copy link
Contributor Author

tsg commented Apr 22, 2016

All PRs merged, yohoo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement in progress Pull request is currently in progress. meta
Projects
None yet
Development

No branches or pull requests

3 participants