Git Product home page Git Product logo

cookbook-elk-stack's Introduction

ELK Stack

This is an attempt to create infrastructure that will allow us to easily visualize and analyze test metrics, log files, etc using the ELK stack.

The solution at the moment is elasticsearch with kibana running on a single Ubuntu node for data storage and visualization.

The data feed can come from a logstash instance or by implementing data push plugins in our CI infrastructure.

Usage

You can use it via the provided Vagrantfile as an example, simply run vagrant up elk-stack:

The local0 log facility (for both the elk-stack and the log-client VM) is configured to forward all syslog messages via tcp, e.g.:

  • log in using vagrant ssh elk-stack (or, if you want to test it from a remote VM use vagrant ssh log-client)
  • now you can log something via local0 in the VM: logger -p local0.info 'here goes my message!'
  • ...and you should see it arrive in Kibana: http://192.168.33.15/

Development

You need ChefDK, Vagrant and either VMWare Workstation + Vagrant VMWare plugin or just VirtualBox.

First, you need to install the required gems:

$ bundle install
...

Next, you can look at the predefined Rake tasks:

$ rake -T
rake chefspec     # run chefspec examples
rake foodcritic   # run foodcritic lint checks
rake integration  # run test-kitchen integration tests
rake rubocop      # check Ruby code style with rubocop
rake unit         # run all unit-level tests

Now create a new branch, make your changes, add test, send us a pull request...

Testing

We use the "standard" set of chef testing frameworks:

For example, you can run rake test to run all the unit level spec tests and linting checks.

$ rake test
...

Or you run rake integration to run all the test-kitchen integration tests.

$ rake integration
...

Elasticsearch data

This vm comes preconfigured with a logstash config for feeding elasticsearch with the logfiles of this vm.

Adjust these accordingly.

Have a look at cookbooks/vm/templates/default/logstash/ .

cookbook-elk-stack's People

Contributors

tknerr avatar damphyr avatar a-zen avatar

Watchers

Jonathan Rothwell avatar Filip Ristić avatar Paul Cadman avatar  avatar Jan Beilicke avatar Peter Gfader avatar Sarah Usher avatar Sebastian avatar  avatar Daniel Rosendorf avatar Dr Milan Milanović avatar Dominic Langenegger avatar Matthias Rueedlinger avatar Andre L. avatar Henning Groß avatar James Cloos avatar Florian Lüscher avatar Quintin Balsdon avatar  avatar Klaus Alfert avatar Raul Rodriguez avatar Wolfgang Giersche avatar Carsten Kind avatar Christian Abegg avatar Ivo de Concini avatar Tobias Rudolphi avatar  avatar Miroslav Sobotka avatar Hendrik Schöneberg avatar Robin avatar Peter Lachenmaier avatar Marius M. avatar Markus Leder avatar Nicolas Oeschger avatar Kai avatar Bruno Hunziker avatar  avatar Christian Kohler avatar Achilles Portarinos avatar Michael Probst avatar  avatar Fredy Setz avatar Loris Reiff avatar Oliver Brack avatar Christian Eder avatar  avatar Alexander Derenbach avatar Barry Norman avatar Jahn F. avatar  avatar Kerry W. Lothrop avatar Adrian Seceleanu avatar Iwan Bolzern avatar  avatar Sven Bayer avatar Henrik Puls avatar Sebastian Büttner avatar Irina Catalina avatar Luke avatar Lukas Frei avatar  avatar Raphael Reischuk avatar Maximilian Voss avatar Morgan Kita avatar Arne Mertz avatar Mario Sabbatella avatar Simon  Birrer avatar  avatar  avatar Malte avatar  avatar Christian Empting avatar  avatar Martin Mosler avatar skosito avatar  avatar Marcel Lambacher avatar  avatar  avatar  avatar  avatar Leo avatar  avatar Benjamin Schwitter avatar  avatar Jonas De la Marche avatar Pavle Prica avatar  avatar

Forkers

gmmurugan

cookbook-elk-stack's Issues

Add Instructions how to use it from an "foreign" Vagrantfile

Right now we only describe how to use it with the example Vagrantfile in this repo, but not how to use it from a Vagrantfile that lives in another repo (e.g. an "infrastructure repository")

Some options:

  • using the vagrant-toplevel-cookbooks plugin
  • using from the supermarket (does this respect the berkshelf git deps?!?)
  • using a tarball uploaded to github releases for this repo with all deps included (just an idea - is that possible at all?!?)

'/var/run/elk-stack.firstrun'

   Running handlers:
   [2017-03-19T17:51:09+00:00] ERROR: Running exception handlers
   Running handlers complete
   [2017-03-19T17:51:09+00:00] ERROR: Exception handlers complete
   Chef Client failed. 1 resources updated in 07 seconds
   [2017-03-19T17:51:09+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   [2017-03-19T17:51:09+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
   [2017-03-19T17:51:09+00:00] ERROR: resource file[/var/run/elk-stack.firstrun] is configured to notify resource runit_service[kibana] with action restart, but runit_service[kibana] cannot be found in the resource collection. file[/var/run/elk-stack.firstrun] is defined in /tmp/kitchen/cache/cookbooks/elk-stack/recipes/default.rb:77:in `from_file'
   
   [2017-03-19T17:51:09+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

------Exception-------
Class: Kitchen::ActionFailed
Message: 1 actions failed.
Converge failed on instance . Please see .kitchen/logs/default-ubuntu-1604.log for more details

Please see .kitchen/logs/kitchen.log for more details
Also try running kitchen diagnose --all for configuration

Fix CircleCI build / make it run in Docker

During #5 I got stuck while enabling the automated build on CircleCI, where the test-kitchen integration tests are failing / timing out when being run with the vagrant-docker provider

See here for the failed test runs:
https://circleci.com/gh/Zuehlke/cookbook-elk-stack/tree/cookbook-structure

I tried to a little bit of troubleshooting on the circleci branch, but without success so far.

Idea is to try this in linus-kitchen where docker is the default vagrant provider and where you can debug locally.

The underlying issue is discussed in chef-cookbooks/runit#148, but it still does not work with the basebox we are using

vagrant up requirements not documented

Berkshelf is used but a standard Vagrant installation (e.g. brew install vagrant on OS X) does not have the plugin installed. This results in

14:08 $ vagrant up
Vagrantfile:9:in `block (2 levels) in <top (required)>': the required plugin 'vagrant-berkshelf' is not installed! (RuntimeError)
    from cookbook-elk-stack/Vagrantfile:7:in `each'
    from cookbook-elk-stack/Vagrantfile:7:in `block in <top (required)>'

Kibana should log to file, not stdout

might be resolved via #15, but currently with kibana 4.1.2 there is no logfile written by kibana.

It needs to be added to /opt/kibana/config/kibana.yml:

...
log_file: "/var/log/kibana/kibana.log"

Also, /var/log/kibana needs to exist and owned by kibana:kibana in that case

See also:
https://www.elastic.co/guide/en/kibana/current/kibana-server-properties.html

And: log rotation does not happen automatically, i.e. needs to be set up via logrotate:
https://discuss.elastic.co/t/does-kibana-4-configuration-supports-logrotation/26618
elastic/kibana#4407

elasticsearch not accessible

Running on virtualbox. Fixed port forwarding in #3

Kibana runs but elasticsearch and the plugin are not accessible over port 9200.

Make it public :-)

Once we have reviewed / merged the open issues and PRs we should consider making it public

Permissions for provisioning script not correct

Fresh virtual box installation, git clone and then vagrant up:

13:35 $ vagrant up
Bringing machine 'elastic-test' up with 'virtualbox' provider...
==> elastic-test: Box 'boxcutter/ubuntu1404' could not be found. Attempting to find and install...
    elastic-test: Box Provider: virtualbox
    elastic-test: Box Version: >= 0
==> elastic-test: Loading metadata for box 'boxcutter/ubuntu1404'
    elastic-test: URL: https://atlas.hashicorp.com/boxcutter/ubuntu1404
==> elastic-test: Adding box 'boxcutter/ubuntu1404' (v2.0.7) for provider: virtualbox
    elastic-test: Downloading: https://atlas.hashicorp.com/boxcutter/boxes/ubuntu1404/versions/2.0.7/providers/virtualbox.box
==> elastic-test: Successfully added box 'boxcutter/ubuntu1404' (v2.0.7) for 'virtualbox'!
==> elastic-test: Importing base box 'boxcutter/ubuntu1404'...
==> elastic-test: Matching MAC address for NAT networking...
==> elastic-test: Checking if box 'boxcutter/ubuntu1404' is up to date...
==> elastic-test: Setting the name of the VM: cookbook-elk-stack_elastic-test_1446900630892_18238
==> elastic-test: Clearing any previously set network interfaces...
==> elastic-test: Preparing network interfaces based on configuration...
    elastic-test: Adapter 1: nat
==> elastic-test: Forwarding ports...
    elastic-test: 22 => 2223 (adapter 1)
    elastic-test: 80 => 8080 (adapter 1)
==> elastic-test: Running 'pre-boot' VM customizations...
==> elastic-test: Booting VM...
==> elastic-test: Waiting for machine to boot. This may take a few minutes...
    elastic-test: SSH address: 127.0.0.1:2223
    elastic-test: SSH username: vagrant
    elastic-test: SSH auth method: private key
    elastic-test: Warning: Connection timeout. Retrying...
    elastic-test:
    elastic-test: Vagrant insecure key detected. Vagrant will automatically replace
    elastic-test: this with a newly generated keypair for better security.
    elastic-test:
    elastic-test: Inserting generated public key within guest...
    elastic-test: Removing insecure key from the guest if it's present...
    elastic-test: Key inserted! Disconnecting and reconnecting using new SSH key...
==> elastic-test: Machine booted and ready!
==> elastic-test: Checking for guest additions in VM...
==> elastic-test: Setting hostname...
==> elastic-test: Mounting shared folders...
    elastic-test: /vagrant => /Users/var/Projects/Z/Zuehlke/GitHub/cookbook-elk-stack
==> elastic-test: Running provisioner: shell...
    elastic-test: Running: inline script
==> elastic-test: /tmp/vagrant-shell: line 1: /vagrant/scripts/update-vm.sh: Permission denied
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Provisioner error in Vagrantfile

OS X, Vagrant 1.8.1 and ChefDK 0.10.0

$ vagrant up
Bringing machine 'elastic-test' up with 'virtualbox' provider...
==> elastic-test: Box 'bento/ubuntu-14.04' could not be found. Attempting to find and install...
    elastic-test: Box Provider: virtualbox
    elastic-test: Box Version: >= 0
==> elastic-test: Loading metadata for box 'bento/ubuntu-14.04'
    elastic-test: URL: https://atlas.hashicorp.com/bento/ubuntu-14.04
==> elastic-test: Adding box 'bento/ubuntu-14.04' (v2.2.3) for provider: virtualbox
    elastic-test: Downloading: https://atlas.hashicorp.com/bento/boxes/ubuntu-14.04/versions/2.2.3/providers/virtualbox.box
==> elastic-test: Successfully added box 'bento/ubuntu-14.04' (v2.2.3) for 'virtualbox'!
There are errors in the configuration of this machine. Please fix
the following errors and try again:

chef zero provisioner:
* Missing required value for `chef.nodes_path'.

Berkshelf crashes on OS X

After getting all the plugins and installing ChefDK 0.10

Git error: command `git reset --hard b38d2381b1e4e40b4674be47c105e88f38f47fbd` failed. If this error persists, try removing the cache directory at '.berkshelf/.cache/git/7f10b9ff6ae4c9fbcf8f1fdaa1bc8959b12ec92e'.Output from the command:

fatal: Could not parse object 'b38d2381b1e4e40b4674be47c105e88f38f47fbd'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.