From 2059ece8cc983ef2ea072bddee0ae997cad28881 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Tue, 31 Mar 2015 08:59:19 +0100 Subject: [PATCH 01/50] Fix crash where both send and receive threads try to report an error at the same time (race condition) Fixes #143 --- lib/log-courier/client_tcp.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/log-courier/client_tcp.rb b/lib/log-courier/client_tcp.rb index 5a5860f8..3537df11 100644 --- a/lib/log-courier/client_tcp.rb +++ b/lib/log-courier/client_tcp.rb @@ -65,10 +65,18 @@ def connect(io_control) @send_paused = false @send_thread = Thread.new do - run_send io_control + begin + run_send io_control + rescue ShutdownSignal + return + end end @recv_thread = Thread.new do - run_recv io_control + begin + run_recv io_control + rescue ShutdownSignal + return + end end return end @@ -145,8 +153,6 @@ def run_send(io_control) @logger.warn 'Write error', :error => e.message unless @logger.nil? io_control << ['F'] return - rescue ShutdownSignal - return rescue StandardError, NativeException => e @logger.warn e, :hint => 'Unknown write error' unless @logger.nil? io_control << ['F'] @@ -188,8 +194,6 @@ def run_recv(io_control) @logger.warn 'Connection closed by server' unless @logger.nil? io_control << ['F'] return - rescue ShutdownSignal - return rescue => e @logger.warn e, :hint => 'Unknown read error' unless @logger.nil? io_control << ['F'] From 9f493a01808921b7416a047b2cc6c9137cd44e03 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Tue, 31 Mar 2015 09:07:17 +0100 Subject: [PATCH 02/50] Update plugin installation docs Fixes #121 (Actually earlier commit fixed it, just now finalising docs after confirming) --- README.md | 5 ++++- docs/LogstashIntegration.md | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f60658e5..6cab5009 100644 --- a/README.md +++ b/README.md @@ -137,11 +137,14 @@ beyond the lumberjack protocol allows. You may install the input plugin using the Logstash 1.5 Plugin manager. cd /path/to/logstash - bin/logstash plugin install logstash-input-log-courier + bin/plugin install logstash-input-log-courier Detailed instructions, including integration with Logstash 1.4.x, can be found on the [Logstash Integration](docs/LogstashIntegration.md) page. +*Note: If you receive a Plugin Conflict error, try updating the zeromq output +plugin first using `bin/plugin update logstash-output-zeromq`* + ## Generating Certificates and Keys Log Courier provides two commands to help generate SSL certificates and Curve diff --git a/docs/LogstashIntegration.md b/docs/LogstashIntegration.md index 42f7048c..79725491 100644 --- a/docs/LogstashIntegration.md +++ b/docs/LogstashIntegration.md @@ -27,11 +27,14 @@ Log Courier plugins. If you are only receiving events, you only need to install the input plugin. cd /path/to/logstash - bin/logstash plugin install logstash-input-log-courier - bin/logstash plugin install logstash-output-log-courier + bin/plugin install logstash-input-log-courier + bin/plugin install logstash-output-log-courier Once the installation is complete, you can start using the plugins! +*Note: If you receive a Plugin Conflict error, try updating the zeromq output +plugin first using `bin/plugin update logstash-output-zeromq`* + ### Manual installation For Logstash 1.4.x the plugins and dependencies need to be installed manually. From c96782021512b0cae47e904518d64aa615b1e827 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Tue, 31 Mar 2015 09:30:05 +0100 Subject: [PATCH 03/50] Further fix for #143 - first fix actually made worse and failed tests --- lib/log-courier/client_tcp.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/log-courier/client_tcp.rb b/lib/log-courier/client_tcp.rb index 3537df11..ebc466e2 100644 --- a/lib/log-courier/client_tcp.rb +++ b/lib/log-courier/client_tcp.rb @@ -68,14 +68,12 @@ def connect(io_control) begin run_send io_control rescue ShutdownSignal - return end end @recv_thread = Thread.new do begin run_recv io_control rescue ShutdownSignal - return end end return @@ -153,6 +151,8 @@ def run_send(io_control) @logger.warn 'Write error', :error => e.message unless @logger.nil? io_control << ['F'] return + rescue ShutdownSignal + raise rescue StandardError, NativeException => e @logger.warn e, :hint => 'Unknown write error' unless @logger.nil? io_control << ['F'] @@ -194,7 +194,9 @@ def run_recv(io_control) @logger.warn 'Connection closed by server' unless @logger.nil? io_control << ['F'] return - rescue => e + rescue ShutdownSignal + raise + rescue StandardError, NativeException => e @logger.warn e, :hint => 'Unknown read error' unless @logger.nil? io_control << ['F'] return From 8fc73ab50ffffc0abb72d97c06452eddf5b0a7bd Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Fri, 3 Apr 2015 12:47:36 +0100 Subject: [PATCH 04/50] Update documentation on Logstash integration Fixes #139 --- README.md | 3 ++- docs/LogstashIntegration.md | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6cab5009..644bb86c 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,8 @@ Log Courier does not utilise the lumberjack Logstash plugin and instead uses its own custom plugin. This allows significant enhancements to the integration far beyond the lumberjack protocol allows. -You may install the input plugin using the Logstash 1.5 Plugin manager. +You may install the input plugin using the Logstash 1.5 Plugin manager. Run the +following as the user Logstash was installed with. cd /path/to/logstash bin/plugin install logstash-input-log-courier diff --git a/docs/LogstashIntegration.md b/docs/LogstashIntegration.md index 79725491..a724e624 100644 --- a/docs/LogstashIntegration.md +++ b/docs/LogstashIntegration.md @@ -22,9 +22,9 @@ Log Courier is built to work seamlessly with [Logstash](http://logstash.net) Logstash 1.5 introduces a new plugin manager that makes installing additional plugins extremely easy. -Simply run the following commands to install the latest stable version of the -Log Courier plugins. If you are only receiving events, you only need to install -the input plugin. +Simply run the following commands as the user Logstash was installed with to +install the latest stable version of the Log Courier plugins. If you are only +receiving events, you only need to install the input plugin. cd /path/to/logstash bin/plugin install logstash-input-log-courier @@ -46,10 +46,11 @@ be called log-courier-X.X.gem, where X.X is the version of Log Courier you have. cd log-courier make gem -Switch to the Logstash installation directory and install it. Note that because -this is JRuby it may take a minute to finish the install. The ffi-rzmq-core and -ffi-rzmq gems bundled with Logstash will be upgraded during the installation, -which will require an internet connection. +Switch to the Logstash installation directory as the user Logstash was installed +with and install the gem. Note that because this is JRuby it may take a minute +to finish the install. The ffi-rzmq-core and ffi-rzmq gems bundled with Logstash +will be upgraded during the installation, which will require an internet +connection. cd /path/to/logstash export GEM_HOME=vendor/bundle/jruby/1.9 @@ -65,7 +66,8 @@ The remaining step is to manually install the Logstash plugins. If you need to install the gem and plugins on a server without an internet connection, you can download the gem dependencies from the rubygems site and transfer them across. Follow the instructions for Manual Installation and -install the dependency gems before the Log Courier gem. +install the dependency gems first using the same instructions as for the Log +Courier gem. * https://rubygems.org/gems/ffi-rzmq-core * https://rubygems.org/gems/ffi-rzmq From c4f0a19aec9e2e367336053f8d86863402dae876 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Fri, 3 Apr 2015 13:18:48 +0100 Subject: [PATCH 05/50] Split and improve documentation - Move phasing out ZeroMQ to separate file to trim down README - Improve repository details and add instructions for starting the service - Improve from source instructions by specifying how to run it in its simplest form (fixes #138) - Trim down Logstash Integration documentation - Split out generating keys information between README and ZeroMQSupport --- README.md | 95 +++++++++++++------------------------ docs/LogstashIntegration.md | 7 ++- docs/ZeroMQSupport.md | 66 ++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 64 deletions(-) create mode 100644 docs/ZeroMQSupport.md diff --git a/README.md b/README.md index 644bb86c..0edd9540 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,9 @@ with many fixes and behavioural improvements. - [Public Repositories](#public-repositories) - [RPM](#rpm) - [DEB](#deb) -- [Building From Source](#building-from-source) +- [From Source](#from-source) - [Logstash Integration](#logstash-integration) -- [Generating Certificates and Keys](#generating-certificates-and-keys) -- [ZeroMQ support](#zeromq-support) +- [Generating Certificates](#generating-certificates) - [Documentation](#documentation) @@ -76,13 +75,11 @@ to distinguish events send from different instances ### RPM -The author maintains a **COPR** repository with RedHat/CentOS compatible RPMs -that may be installed using `yum`. This repository depends on the widely used -**EPEL** repository for dependencies. - -The **EPEL** repository can be installed automatically on CentOS distributions -by running `yum install epel-release`. Otherwise, you may follow the -instructions on the [EPEL homepage](https://fedoraproject.org/wiki/EPEL). +*The Log Courier repository depends on the **EPEL** repository which can be +installed automatically on CentOS distributions by running +`yum install epel-release`. For other distributions, please follow the +installation instructions on the +[EPEL homepage](https://fedoraproject.org/wiki/EPEL).* To install the Log Courier repository, download the corresponding `.repo` configuration file below, and place it in `/etc/yum.repos.d`. Log Courier may @@ -92,16 +89,18 @@ then be installed using `yum install log-courier`. * **CentOS/RedHat 7.x**: [driskell-log-courier-epel-7.repo](https://copr.fedoraproject.org/coprs/driskell/log-courier/repo/epel-6/driskell-log-courier-epel-7.repo) -***NOTE:*** *The RPM packages versions of Log Courier are built using ZeroMQ 3.2 -and therefore do not support the encrypted `zmq` transport. They do support the -unencrypted `plainzmq` transport.* +Once installed, modify the configuration file at +`/etc/log-courier/log-courier.conf` to suit your needs, then start the Log +Courier service to begin shipping. + + service log-courier start ### DEB A Debian/Ubuntu compatible **PPA** repository is under consideration. At the moment, no such repository exists. -## Building From Source +## From Source Requirements: @@ -118,27 +117,28 @@ package manager.* To build the binaries, simply run `make` as follows. - git clone https://github.com/driskell/log-courier - cd log-courier - make + git clone https://github.com/driskell/log-courier + cd log-courier + make + +The log-courier program can then be found in the 'bin' folder. Service scripts +for various platforms can be found in the +[contrib/initscripts](contrib/initscripts) folder, or it can be run on the +command line: -The log-courier program can then be found in the 'bin' folder. This can be -manually installed anywhere on your system. Startup scripts for various -platforms can be found in the [contrib/initscripts](contrib/initscripts) folder. + bin/log-courier -config /path/to/config.conf *Note: If you receive errors whilst running `make`, try `gmake` instead.* ## Logstash Integration -Log Courier does not utilise the lumberjack Logstash plugin and instead uses its -own custom plugin. This allows significant enhancements to the integration far -beyond the lumberjack protocol allows. +Log Courier communicates with Logstash via an input plugin called "courier". -You may install the input plugin using the Logstash 1.5 Plugin manager. Run the +You may install the plugin using the Logstash 1.5 Plugin manager. Run the following as the user Logstash was installed with. - cd /path/to/logstash - bin/plugin install logstash-input-log-courier + cd /path/to/logstash + bin/plugin install logstash-input-log-courier Detailed instructions, including integration with Logstash 1.4.x, can be found on the [Logstash Integration](docs/LogstashIntegration.md) page. @@ -146,46 +146,16 @@ on the [Logstash Integration](docs/LogstashIntegration.md) page. *Note: If you receive a Plugin Conflict error, try updating the zeromq output plugin first using `bin/plugin update logstash-output-zeromq`* -## Generating Certificates and Keys +## Generating Certificates -Log Courier provides two commands to help generate SSL certificates and Curve -keys, `lc-tlscert` and `lc-curvekey` respectively. Both are bundled with the -packages provided by the public repositories. +Log Courier provides a commands to help generate SSL certificates: `lc-tlscert`. +This utility is also bundled with the packaged versions of Log Courier, and +should be immediately available at the command-line. When building from source, running `make selfsigned` will automatically build and run the `lc-tlscert` utility that can quickly and easily generate a -self-signed certificate for the TLS shipping transport. - -Likewise, running `make curvekey` will automatically build and run the -`lc-curvekey` utility that can quickly and easily generate CurveZMQ key pairs -for the CurveZMQ shipping transport. This tool is only available when Log -Courier is built with ZeroMQ >=4.0. - -## ZeroMQ support - -To use the 'plainzmq' or 'zmq' transports, you will need to install -[ZeroMQ](http://zeromq.org/intro:get-the-software) (>=3.2 for 'plainzmq', >=4.0 -for 'zmq' which supports encryption). - -***Linux\Unix:*** *ZeroMQ >=3.2 is usually available via the package manager. -ZeroMQ >=4.0 may need to be built and installed manually.* -***OS X:*** *ZeroMQ can be installed via [Homebrew](http://brew.sh).* -***Windows:*** *ZeroMQ will need to be built and installed manually.* - -Once the required version of ZeroMQ is installed, run the corresponding `make` -command to build Log Courier with the ZMQ transports. - - # ZeroMQ >=3.2 - cleartext 'plainzmq' transport - make with=zmq3 - # ZeroMQ >=4.0 - both cleartext 'plainzmq' and encrypted 'zmq' transport - make with=zmq4 - -*Note: If you receive errors whilst running `make`, try `gmake` instead.* - -**Please ensure that the versions of ZeroMQ installed on the Logstash hosts and -the Log Courier hosts are of the same major version. A Log Courier host that has -ZeroMQ 4.0.5 will not work with a Logstash host using ZeroMQ 3.2.4 (but will -work with a Logstash host using ZeroMQ 4.0.4.)** +self-signed certificate, along with the corresponding configuration snippets, +for the 'tls' transport. ## Documentation @@ -193,4 +163,5 @@ work with a Logstash host using ZeroMQ 4.0.4.)** * [Command Line Arguments](docs/CommandLineArguments.md) * [Configuration](docs/Configuration.md) * [Logstash Integration](docs/LogstashIntegration.md) +* [ZeroMQ Support](docs/ZeroMQSupport.md) * [Change Log](docs/ChangeLog.md) diff --git a/docs/LogstashIntegration.md b/docs/LogstashIntegration.md index a724e624..6a455bd3 100644 --- a/docs/LogstashIntegration.md +++ b/docs/LogstashIntegration.md @@ -1,7 +1,10 @@ # Logstash Integration -Log Courier is built to work seamlessly with [Logstash](http://logstash.net) -1.4.x. +Log Courier is built to work seamlessly with [Logstash](http://logstash.net). It +communicates via an input plugin called "courier". + +An output plugin is also available to allow Logstash instances to communicate +with each other using the same reliable and efficient protocol as Log Courier. diff --git a/docs/ZeroMQSupport.md b/docs/ZeroMQSupport.md new file mode 100644 index 00000000..1915e9e7 --- /dev/null +++ b/docs/ZeroMQSupport.md @@ -0,0 +1,66 @@ +# ZeroMQ Support + +*NOTICE: ZeroMQ support will no longer be available as of Log Courier version +2.0, where the 'tcp' and 'tls' transports will be able to connect to multiple +Logstash instances. This reduces the benefits of retaining ZeroMQ support +significantly, especially as the new 'tcp' and 'tls' implementation will recover +from instance failures significantly faster. Additionally, the library currently +in use has entered maintenance only support and as such would need replacing to +allow it to continue to take advantage of future ZeroMQ improvements.* + +The ZeroMQ transports allow Log Courier to connect to multiple Logstash +instances simultaenously and load balance events between them in an efficient +and reliable manner. + + + +**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* + +- [Packaged Versions of Log Courier](#packaged-versions-of-log-courier) +- [Building from Source](#building-from-source) +- [Generating Keys for the 'zmq' Transport](#generating-keys-for-the-zmq-transport) + + + +## Packaged Versions of Log Courier + +All current packages are built with support for the cleartext 'plainzmq' +transport. + +Because most distrbutions do not provide packaged versions of ZeroMQ >=4.0, +it is not possible to provide a packaged version of Log Courier that supports +the 'zmq' transport, as this transport requires ZeroMQ >=4.0. + +## Building from Source + +To build with support for the 'plainzmq' or 'zmq' transports, you will need to +install [ZeroMQ](http://zeromq.org/intro:get-the-software) (>=3.2 for +'plainzmq', >=4.0 for 'zmq' which supports encryption). + +***Linux\Unix:*** *ZeroMQ >=3.2 is usually available via the package manager. +ZeroMQ >=4.0 may need to be built and installed manually.* +***OS X:*** *ZeroMQ can be installed via [Homebrew](http://brew.sh).* +***Windows:*** *ZeroMQ will need to be built and installed manually.* + +Once the required version of ZeroMQ is installed, run the corresponding `make` +command to build Log Courier with the ZMQ transports. + + # ZeroMQ >=3.2 - cleartext 'plainzmq' transport + make with=zmq3 + # ZeroMQ >=4.0 - both cleartext 'plainzmq' and encrypted 'zmq' transport + make with=zmq4 + +*Note: If you receive errors whilst running `make`, try `gmake` instead.* + +**Please ensure that the versions of ZeroMQ installed on the Logstash hosts and +the Log Courier hosts are of the same major version. A Log Courier host that has +ZeroMQ 4.0.5 will not work with a Logstash host using ZeroMQ 3.2.4 (but will +work with a Logstash host using ZeroMQ 4.0.4.)** + +## Generating Keys for the 'zmq' Transport + +Log Courier provides a command to help generate Curve keys: `lc-curvekey`. + +Running `make curvekey` will automatically build and run the `lc-curvekey` +utility that will quickly and easily generate Curve key pairs, along with the +corresponding configuration snippets, for the 'zmq' shipping transport. From acbbdbb1dcc8e506f42855254fdf00b02da07218 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Fri, 3 Apr 2015 13:26:04 +0100 Subject: [PATCH 06/50] Put From Source back to Building from Source Fix some markdown issues and improve some others such as tabs to space conversions --- README.md | 12 +++--- docs/AdministrationUtility.md | 46 +++++++++++----------- docs/Configuration.md | 72 +++++++++++++++++------------------ docs/LogstashIntegration.md | 36 +++++++++--------- docs/ZeroMQSupport.md | 8 ++-- 5 files changed, 87 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index 0edd9540..a2404f4c 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ with many fixes and behavioural improvements. - [Public Repositories](#public-repositories) - [RPM](#rpm) - [DEB](#deb) -- [From Source](#from-source) +- [Building from Source](#building-from-source) - [Logstash Integration](#logstash-integration) - [Generating Certificates](#generating-certificates) - [Documentation](#documentation) @@ -75,7 +75,7 @@ to distinguish events send from different instances ### RPM -*The Log Courier repository depends on the **EPEL** repository which can be +*The Log Courier repository depends on the __EPEL__ repository which can be installed automatically on CentOS distributions by running `yum install epel-release`. For other distributions, please follow the installation instructions on the @@ -100,7 +100,7 @@ Courier service to begin shipping. A Debian/Ubuntu compatible **PPA** repository is under consideration. At the moment, no such repository exists. -## From Source +## Building from Source Requirements: @@ -109,10 +109,10 @@ Requirements: 1. [git](http://git-scm.com) 1. GNU make -***Linux/Unix:*** *Most requirements can usually be installed by your favourite +*__Linux/Unix:__ Most requirements can usually be installed by your favourite package manager.* -***OS X:*** *Git and GNU make are provided automatically by XCode.* -***Windows:*** *GNU make for Windows can be found +*__OS X:__ Git and GNU make are provided automatically by XCode.* +*__Windows:__ GNU make for Windows can be found [here](http://gnuwin32.sourceforge.net/packages/make.htm).* To build the binaries, simply run `make` as follows. diff --git a/docs/AdministrationUtility.md b/docs/AdministrationUtility.md index cc9e0861..5cf19311 100644 --- a/docs/AdministrationUtility.md +++ b/docs/AdministrationUtility.md @@ -49,31 +49,31 @@ Displays Log Courier's current shipping status in the requested format. Following is an example of the output this command provides. - "State: /var/log/nginx/access.log (0xc2080681e0)": - Status: Running - Harvester: - Speed (Lps): 20205.40 - Speed (Bps): 1627565.16 - Processed lines: 43024 - Current offset: 3473919 - Last EOF Offset: Never - Status: Alive - Prospector: - Watched files: 1 - Active states: 1 - Publisher: - Status: Connected - Speed (Lps): 8735.15 - Published lines: 23552 - Pending Payloads: 10 - Timeouts: 0 - Retransmissions: 0 + "State: /var/log/nginx/access.log (0xc2080681e0)": + Status: Running + Harvester: + Speed (Lps): 20205.40 + Speed (Bps): 1627565.16 + Processed lines: 43024 + Current offset: 3473919 + Last EOF Offset: Never + Status: Alive + Prospector: + Watched files: 1 + Active states: 1 + Publisher: + Status: Connected + Speed (Lps): 8735.15 + Published lines: 23552 + Pending Payloads: 10 + Timeouts: 0 + Retransmissions: 0 ## Command Line Options The `lc-admin` command accepts the following command line options. - -connect="tcp:127.0.0.1:1234": the Log Courier address to connect to - -quiet=false: quietly execute the command line argument and output only the result - -version=false: display the Log Courier client version - -watch=false: repeat the command specified on the command line every second + -connect="tcp:127.0.0.1:1234": the Log Courier address to connect to + -quiet=false: quietly execute the command line argument and output only the result + -version=false: display the Log Courier client version + -watch=false: repeat the command specified on the command line every second diff --git a/docs/Configuration.md b/docs/Configuration.md index 37fb2789..58263a96 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -63,16 +63,16 @@ to be ignored until an asterisk followed by a forwarder slash is encountered. ``` { - "general": { - # General configuration here - }, - "network": { - # Network configuration here - }, # (these are end-of-line comments) - "files": { - /* File configuration here - (this is a block comment) */ - } + "general": { + # General configuration here + }, + "network": { + # Network configuration here + }, # (these are end-of-line comments) + "files": { + /* File configuration here + (this is a block comment) */ + } } ``` @@ -82,7 +82,7 @@ Log Courier can reload its configuration without the need for a restart. It will do this upon receiving the SIGHUP signal. To send this signal, run the following command replacing 1234 with the Process ID of Log Courier. - kill -HUP 1234 + kill -HUP 1234 Log Courier will reopen its own log file if one has been configured, allowing native log rotation to take place. @@ -141,17 +141,17 @@ http://golang.org/pkg/path/filepath/#Match and is shown below for reference: ``` term: - '*' matches any sequence of non-Separator characters - '?' matches any single non-Separator character - '[' [ '^' ] { character-range } ']' - character class (must be non-empty) - c matches character c (c != '*', '?', '\\', '[') - '\\' c matches character c + '*' matches any sequence of non-Separator characters + '?' matches any single non-Separator character + '[' [ '^' ] { character-range } ']' + character class (must be non-empty) + c matches character c (c != '*', '?', '\\', '[') + '\\' c matches character c character-range: - c matches character c (c != '\\', '-', ']') - '\\' c matches character c - lo '-' hi matches character c for lo <= c <= hi + c matches character c (c != '\\', '-', ']') + '\\' c matches character c + lo '-' hi matches character c for lo <= c <= hi ``` * `"/var/log/*.log"` @@ -244,9 +244,9 @@ unix domain socket. If no transport name is specified, "tcp" is assumed. Examples: - 127.0.0.1:1234 - tcp:127.0.0.1:1234 - unix:/var/run/log-courier/admin.socket + 127.0.0.1:1234 + tcp:127.0.0.1:1234 + unix:/var/run/log-courier/admin.socket ### `"log file"` @@ -515,14 +515,14 @@ The files configuration lists the file groups that contain the logs you wish to ship. It is an array of file group configurations. ``` - [ - { - # First file group - }, - { - # Second file group - } - ] + [ + { + # First file group + }, + { + # Second file group + } + ] ``` In addition to the configuration parameters specified below, each file group may @@ -559,15 +559,15 @@ Examples: Includes should be an array of additional file group configuration files to read. Each configuration file should follow the format of the `"files"` section. - "includes": [ "/etc/log-courier/conf.d/*.conf" ] + "includes": [ "/etc/log-courier/conf.d/*.conf" ] A file at `/etc/log-courier/conf.d/apache.conf` could then contain the following. - [ { - "paths": [ "/var/log/httpd/access.log" ], - "fields": { "type": "access_log" } - } ] + [ { + "paths": [ "/var/log/httpd/access.log" ], + "fields": { "type": "access_log" } + } ] ## `"stdin"` diff --git a/docs/LogstashIntegration.md b/docs/LogstashIntegration.md index 6a455bd3..0198f69c 100644 --- a/docs/LogstashIntegration.md +++ b/docs/LogstashIntegration.md @@ -29,9 +29,9 @@ Simply run the following commands as the user Logstash was installed with to install the latest stable version of the Log Courier plugins. If you are only receiving events, you only need to install the input plugin. - cd /path/to/logstash - bin/plugin install logstash-input-log-courier - bin/plugin install logstash-output-log-courier + cd /path/to/logstash + bin/plugin install logstash-input-log-courier + bin/plugin install logstash-output-log-courier Once the installation is complete, you can start using the plugins! @@ -45,9 +45,9 @@ For Logstash 1.4.x the plugins and dependencies need to be installed manually. First build the Log Courier gem the plugins require. The file you will need will be called log-courier-X.X.gem, where X.X is the version of Log Courier you have. - git clone https://github.com/driskell/log-courier - cd log-courier - make gem + git clone https://github.com/driskell/log-courier + cd log-courier + make gem Switch to the Logstash installation directory as the user Logstash was installed with and install the gem. Note that because this is JRuby it may take a minute @@ -55,14 +55,14 @@ to finish the install. The ffi-rzmq-core and ffi-rzmq gems bundled with Logstash will be upgraded during the installation, which will require an internet connection. - cd /path/to/logstash - export GEM_HOME=vendor/bundle/jruby/1.9 - java -jar vendor/jar/jruby-complete-1.7.11.jar -S gem install /path/to/the.gem + cd /path/to/logstash + export GEM_HOME=vendor/bundle/jruby/1.9 + java -jar vendor/jar/jruby-complete-1.7.11.jar -S gem install /path/to/the.gem The remaining step is to manually install the Logstash plugins. - cd /path/to/log-courier - cp -rvf lib/logstash /path/to/logstash/lib + cd /path/to/log-courier + cp -rvf lib/logstash /path/to/logstash/lib ### Local-only Installation @@ -81,13 +81,13 @@ Courier gem. The 'courier' input and output plugins will now be available. An example configuration for the input plugin follows. - input { - courier { - port => 12345 - ssl_certificate => "/opt/logstash/ssl/logstash.cer" - ssl_key => "/opt/logstash/ssl/logstash.key" - } - } + input { + courier { + port => 12345 + ssl_certificate => "/opt/logstash/ssl/logstash.cer" + ssl_key => "/opt/logstash/ssl/logstash.key" + } + } The following options are available for the input plugin: diff --git a/docs/ZeroMQSupport.md b/docs/ZeroMQSupport.md index 1915e9e7..21daa1f2 100644 --- a/docs/ZeroMQSupport.md +++ b/docs/ZeroMQSupport.md @@ -45,10 +45,10 @@ ZeroMQ >=4.0 may need to be built and installed manually.* Once the required version of ZeroMQ is installed, run the corresponding `make` command to build Log Courier with the ZMQ transports. - # ZeroMQ >=3.2 - cleartext 'plainzmq' transport - make with=zmq3 - # ZeroMQ >=4.0 - both cleartext 'plainzmq' and encrypted 'zmq' transport - make with=zmq4 + # ZeroMQ >=3.2 - cleartext 'plainzmq' transport + make with=zmq3 + # ZeroMQ >=4.0 - both cleartext 'plainzmq' and encrypted 'zmq' transport + make with=zmq4 *Note: If you receive errors whilst running `make`, try `gmake` instead.* From 6fba48fe5be4e0af3f9df99e5d4728d67868d419 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 12 Apr 2015 20:40:21 +0100 Subject: [PATCH 07/50] Report an error and exit if no server is specified Fixes #149 --- src/lc-lib/core/config.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lc-lib/core/config.go b/src/lc-lib/core/config.go index 65eb05ca..dc11d429 100644 --- a/src/lc-lib/core/config.go +++ b/src/lc-lib/core/config.go @@ -351,6 +351,11 @@ func (c *Config) Load(path string) (err error) { } } + if len(c.Network.Servers) == 0 { + err = fmt.Errorf("No network servers were specified (/network/servers)") + return + } + if c.Network.Transport == "" { c.Network.Transport = default_NetworkConfig_Transport } From 3acf794e55f51fe9b0aa1908ab66ba8b9de5a379 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 12 Apr 2015 20:50:29 +0100 Subject: [PATCH 08/50] Report an error if the configuration file is empty Fixes #148 --- src/lc-lib/core/config.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lc-lib/core/config.go b/src/lc-lib/core/config.go index dc11d429..f9dc6dda 100644 --- a/src/lc-lib/core/config.go +++ b/src/lc-lib/core/config.go @@ -136,6 +136,10 @@ func (c *Config) loadFile(path string) (stripped *bytes.Buffer, err error) { err = fmt.Errorf("Stat failed for config file: %s", err) return } + if stat.Size() == 0 { + err = fmt.Errorf("Empty configuration file") + return + } if stat.Size() > (10 << 20) { err = fmt.Errorf("Config file too large (%s)", stat.Size()) return @@ -218,6 +222,11 @@ func (c *Config) loadFile(path string) (stripped *bytes.Buffer, err error) { stripped.Write(buffer[s:p]) } + if stripped.Len() == 0 { + err = fmt.Errorf("Empty configuration file") + return + } + return } From 11e96073d858493e29cf0043626361840ad4b89b Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 12 Apr 2015 21:13:07 +0100 Subject: [PATCH 09/50] Do not crash if configuration file has single new line --- src/lc-lib/core/config.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lc-lib/core/config.go b/src/lc-lib/core/config.go index f9dc6dda..3a1ba84d 100644 --- a/src/lc-lib/core/config.go +++ b/src/lc-lib/core/config.go @@ -247,7 +247,14 @@ func (c *Config) parseSyntaxError(js []byte, err error) error { line, pos := bytes.Count(js[:start], []byte("\n")), int(json_err.Offset) - start - 1 - return fmt.Errorf("%s on line %d\n%s\n%s^", err, line, js[start:end], strings.Repeat(" ", pos)) + var posStr string + if pos > 0 { + posStr = strings.Repeat(" ", pos) + } else { + posStr = "" + } + + return fmt.Errorf("%s on line %d\n%s\n%s^", err, line, js[start:end], posStr) } // TODO: Config from a TOML? Maybe a custom one From 58b3cf6b4bbd70a70e714d9b99e77cac075b9d5f Mon Sep 17 00:00:00 2001 From: Matthew Newton Date: Tue, 24 Feb 2015 12:01:15 +0000 Subject: [PATCH 10/50] Add debian packaging for the log-courier daemon. Fixes #127 --- debian/README | 18 ++++++++ debian/changelog | 23 +++++++++++ debian/compat | 1 + debian/control | 16 ++++++++ debian/log-courier.conf | 23 +++++++++++ debian/log-courier.default | 3 ++ debian/log-courier.dirs | 4 ++ debian/log-courier.init | 84 ++++++++++++++++++++++++++++++++++++++ debian/rules | 18 ++++++++ debian/source/format | 1 + 10 files changed, 191 insertions(+) create mode 100644 debian/README create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/log-courier.conf create mode 100644 debian/log-courier.default create mode 100644 debian/log-courier.dirs create mode 100644 debian/log-courier.init create mode 100755 debian/rules create mode 100644 debian/source/format diff --git a/debian/README b/debian/README new file mode 100644 index 00000000..58c53984 --- /dev/null +++ b/debian/README @@ -0,0 +1,18 @@ +To build the debian package on wheezy +===================================== + +The version of 'go' available in the golang-go package available in Debian +wheezy is not recent enough to build this package. The following procedure +can be followed as a workaround. + +First, grab the latest go from https://golang.org/ and install as standard in +/usr/local/go (debian's current packaged version is not new enough). + +Add go to the PATH + + $ export PATH=/usr/local/go/bin:$PATH + +Build the packages + + $ dpkg-buildpackage + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..5612c53c --- /dev/null +++ b/debian/changelog @@ -0,0 +1,23 @@ +log-courier (1.6) UNRELEASED; urgency=low + + * Update to release 1.6 + + -- Matthew Newton Mon, 13 Apr 2015 13:36:22 +0100 + +log-courier (1.3.9.g32f6cc4) UNRELEASED; urgency=low + + * Update to release 1.3.9.g32f6cc4 + + -- Matthew Newton Wed, 11 Feb 2015 14:00:00 +0000 + +log-courier (1.3) UNRELEASED; urgency=low + + * Update to release 1.3 + + -- Matthew Newton Mon, 12 Jan 2015 11:55:20 +0000 + +log-courier (0.15) UNRELEASED; urgency=low + + * Initial release + + -- Matthew Newton Fri, 26 Sep 2014 14:48:48 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..7450511e --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: log-courier +Section: admin +Priority: optional +Standards-Version: 3.9.2 +Maintainer: Matthew Newton +Build-Depends: debhelper (>= 9), golang-go + +Package: log-courier +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Log file shipper + Log Courier is a tool created to transmit log files speedily and securely to + remote Logstash instances for processing whilst using small amounts of local + resources. The project is an enhanced fork of Logstash Forwarder 0.3.1 with + many enhancements and behavioural improvements. + diff --git a/debian/log-courier.conf b/debian/log-courier.conf new file mode 100644 index 00000000..e6df0b5a --- /dev/null +++ b/debian/log-courier.conf @@ -0,0 +1,23 @@ +{ + "general": { + "persist directory": "/var/lib/log-courier", + "log syslog": true, + "log stdout": false, + "admin listen address": "unix:/var/run/log-courier/admin.socket" + }, + "network": { + "transport": "tcp", + "reconnect": 10, + "servers": [ "localhost:5043" ] + }, + "files": [ + { +# "paths": [ "/var/log/syslog", "/var/log/syslog.1" ], + "fields": { + "type": "syslog" + }, + "dead time": "12h" + } + ] +} + diff --git a/debian/log-courier.default b/debian/log-courier.default new file mode 100644 index 00000000..86d83413 --- /dev/null +++ b/debian/log-courier.default @@ -0,0 +1,3 @@ +# log-courier options + +LOG_COURIER_ARGS="-config=/etc/log-courier/log-courier.conf -from-beginning=true" diff --git a/debian/log-courier.dirs b/debian/log-courier.dirs new file mode 100644 index 00000000..0fa0ea4f --- /dev/null +++ b/debian/log-courier.dirs @@ -0,0 +1,4 @@ +usr/bin +usr/share/doc/log-courier +etc/log-courier +var/lib/log-courier diff --git a/debian/log-courier.init b/debian/log-courier.init new file mode 100644 index 00000000..d633efd6 --- /dev/null +++ b/debian/log-courier.init @@ -0,0 +1,84 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: log-courier +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Log Courier +# Description: Sends logs over the network to a log collector +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="log-courier" +NAME=log-courier +DAEMON=/usr/bin/log-courier +LOG_COURIER_ARGS="-config=/etc/log-courier/log-courier.conf -from-beginning=true" +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME + +[ -r /etc/default/$NAME ] && . /etc/default/$NAME +. /lib/init/vars.sh +. /lib/lsb/init-functions + +do_start() { + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec /bin/sh --test > /dev/null || return 1 + start-stop-daemon --start --quiet --make-pidfile --background --pidfile $PIDFILE --exec "$DAEMON" -- $LOG_COURIER_ARGS || return 2 +} + +do_stop() +{ + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + rm -f $PIDFILE + return "$RETVAL" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + restart|force-reload) + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..cb9d446c --- /dev/null +++ b/debian/rules @@ -0,0 +1,18 @@ +#!/usr/bin/make -f + +%: + dh $@ + +override_dh_auto_build: + make + +override_dh_auto_test: + +override_dh_auto_install: + install -m 0755 bin/log-courier debian/log-courier/usr/bin/log-courier + install -m 0755 bin/lc-admin debian/log-courier/usr/bin/lc-admin + install -m 0755 bin/lc-tlscert debian/log-courier/usr/bin/lc-tlscert + install -m 0755 debian/log-courier.conf debian/log-courier/etc/log-courier/log-courier.conf + cp -av docs/* debian/log-courier/usr/share/doc/log-courier/ + install -m 0644 LICENSE debian/log-courier/usr/share/doc/log-courier/copyright + diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 00000000..89ae9db8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) From b7f138b2f68ebac644a0def0f4d7def440d6361a Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Tue, 21 Apr 2015 22:44:46 +0100 Subject: [PATCH 11/50] Don't allow a file configuration with empty paths Fixes #153 --- src/lc-lib/core/config.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lc-lib/core/config.go b/src/lc-lib/core/config.go index 3a1ba84d..80ab6a9f 100644 --- a/src/lc-lib/core/config.go +++ b/src/lc-lib/core/config.go @@ -399,6 +399,11 @@ func (c *Config) Load(path string) (err error) { } for k := range c.Files { + if len(c.Files[k].Paths) == 0 { + err = fmt.Errorf("No paths specified for /files[%d]/", k) + return + } + if err = c.initStreamConfig(fmt.Sprintf("/files[%d]/codec/", k), &c.Files[k].StreamConfig); err != nil { return } From 54c92855f6c71daa4eec6f01e9c73dddb1c49bca Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Tue, 21 Apr 2015 22:52:25 +0100 Subject: [PATCH 12/50] Use cygwin for Windows compilation. Fixes #145 --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a2404f4c..d92db24b 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ moment, no such repository exists. Requirements: -1. Linux, Unix, OS X or Windows +1. Linux, Unix, OS X or Windows with [Cygwin](https://cygwin.com) 1. The [golang](http://golang.org/doc/install) compiler tools (1.2-1.4) 1. [git](http://git-scm.com) 1. GNU make @@ -112,8 +112,7 @@ Requirements: *__Linux/Unix:__ Most requirements can usually be installed by your favourite package manager.* *__OS X:__ Git and GNU make are provided automatically by XCode.* -*__Windows:__ GNU make for Windows can be found -[here](http://gnuwin32.sourceforge.net/packages/make.htm).* +*__Windows:__ Git and GNU make are available as Cygwin packages.* To build the binaries, simply run `make` as follows. From e9af6e926c3d69850431f0b1b5100a11a286d39a Mon Sep 17 00:00:00 2001 From: Cameron Davison Date: Wed, 13 May 2015 16:56:36 -0500 Subject: [PATCH 13/50] fix stream configuration anchor name --- docs/Configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index 58263a96..d5ff38cf 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -572,6 +572,6 @@ following. ## `"stdin"` The stdin configuration contains the -[Stream Configuration](#streamconfiguration) parameters that should be used when +[Stream Configuration](#stream-configuration) parameters that should be used when Log Courier is set to read log data from stdin using the [`-stdin`](CommandLineArguments.md#stdin) command line entry. From c2ecf1a82beb52b12a62524b13cad8186a62f5d9 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sat, 16 May 2015 20:19:44 +0100 Subject: [PATCH 14/50] Fix synchronisation of event_queue in JRuby The builtin Queue within JRuby uses Java synchronisation The MRI Queue which this is based on, ignores synchronisation for properties, likely due to the GIL providing the necessary synchronisation (?) --- lib/log-courier/event_queue.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/log-courier/event_queue.rb b/lib/log-courier/event_queue.rb index c65fe9c4..a2198b7d 100644 --- a/lib/log-courier/event_queue.rb +++ b/lib/log-courier/event_queue.rb @@ -135,14 +135,18 @@ def pop(*args) # Returns +true+ if the queue is empty. # def empty? - @que.empty? + @mutex.synchronize do + return @que.empty? + end end # # Removes all objects from the queue. # def clear - @que.clear + @mutex.synchronize do + @que.clear + end self end @@ -150,7 +154,9 @@ def clear # Returns the length of the queue. # def length - @que.length + @mutex.synchronize do + return @que.length + end end # @@ -162,7 +168,9 @@ def length # Returns the number of threads waiting on the queue. # def num_waiting - @num_waiting + @num_enqueue_waiting + @mutex.synchronize do + return @num_waiting + @num_enqueue_waiting + end end private From 477acf2be9e296b4b73494bcae36578c0dbd9546 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sat, 16 May 2015 20:21:04 +0100 Subject: [PATCH 15/50] Fix rare transport failures when null-byte suffixes appear on the nonce --- lib/log-courier/client.rb | 2 +- lib/log-courier/server.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/log-courier/client.rb b/lib/log-courier/client.rb index 8ebc63fc..58598570 100644 --- a/lib/log-courier/client.rb +++ b/lib/log-courier/client.rb @@ -440,7 +440,7 @@ def process_ackn(message) fail ProtocolError, "ACKN message size invalid (#{message.length})" if message.length != 20 # Grab nonce - nonce, sequence = message.unpack('A16N') + nonce, sequence = message.unpack('a16N') if !@logger.nil? && @logger.debug? nonce_str = nonce.each_byte.map do |b| diff --git a/lib/log-courier/server.rb b/lib/log-courier/server.rb index d5d06de7..f6adb589 100644 --- a/lib/log-courier/server.rb +++ b/lib/log-courier/server.rb @@ -191,7 +191,7 @@ def process_jdat(message, comm, event_queue) # Full pipeline, partial ack # NOTE: comm.send can raise a Timeout::Error of its own @logger.debug 'Partially acknowledging message', :nonce => nonce_str.join, :sequence => sequence if !@logger.nil? && @logger.debug? - comm.send 'ACKN', [nonce, sequence].pack('A*N') + comm.send 'ACKN', [nonce, sequence].pack('a*N') ack_timeout = Time.now.to_i + 5 retry end From 0327789a6a74b307350ea5685e598792f637f7f3 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sat, 16 May 2015 20:46:15 +0100 Subject: [PATCH 16/50] Fix pending payload limit being exceeded when a timeout occurs --- src/lc-lib/publisher/publisher.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lc-lib/publisher/publisher.go b/src/lc-lib/publisher/publisher.go index 469f97d0..a1720826 100644 --- a/src/lc-lib/publisher/publisher.go +++ b/src/lc-lib/publisher/publisher.go @@ -152,6 +152,7 @@ func (p *Publisher) Run() { var retry_payload *pendingPayload var err error var reload int + var hold bool timer := time.NewTimer(keepalive_timeout) stats_timer := time.NewTimer(time.Second) @@ -230,6 +231,7 @@ PublishLoop: p.pending_ping = false input_toggle = nil + hold = false p.can_send = p.transport.CanSend() SelectLoop: @@ -288,8 +290,12 @@ PublishLoop: log.Debug("Send now open: Awaiting events for new payload") - // Enable event wait - input_toggle = p.input + // Too many pending payloads, hold sending more until some are ACK + if p.num_payloads >= p.config.MaxPendingPayloads { + hold = true + } else { + input_toggle = p.input + } case events := <-input_toggle: log.Debug("Sending new payload of %d events", len(events)) @@ -302,8 +308,6 @@ PublishLoop: input_toggle = nil if p.num_payloads >= p.config.MaxPendingPayloads { - // Too many pending payloads, disable send temporarily - p.can_send = nil log.Debug("Pending payload limit of %d reached", p.config.MaxPendingPayloads) } else { log.Debug("%d/%d pending payloads now in transit", p.num_payloads, p.config.MaxPendingPayloads) @@ -354,6 +358,11 @@ PublishLoop: } else { log.Debug("%d payloads still pending, resetting timeout", p.num_payloads) timer.Reset(p.config.Timeout) + + // Release any send hold if we're no longer at the max pending payloads + if hold && p.num_payloads < p.config.MaxPendingPayloads { + input_toggle = p.input + } } case <-timer.C: // If we have pending payloads, we should've received something by now From 3d8117bc8475d4e724b9ab87f3ee87c10613694b Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sat, 16 May 2015 21:02:26 +0100 Subject: [PATCH 17/50] Improve TCP transport shutdown --- src/lc-lib/transports/tcp.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lc-lib/transports/tcp.go b/src/lc-lib/transports/tcp.go index 23639890..042bb3c8 100644 --- a/src/lc-lib/transports/tcp.go +++ b/src/lc-lib/transports/tcp.go @@ -216,6 +216,8 @@ func (t *TransportTcp) Init() error { t.send_chan = make(chan []byte, 1) // Buffer of two for recv_chan since both routines may send an error to it // First error we get back initiates disconnect, thus we must not block routines + // NOTE: This may not be necessary anymore - both recv_chan pushes also select + // on the shutdown channel, which will close on the first error returned t.recv_chan = make(chan interface{}, 2) t.can_send = make(chan int, 1) @@ -269,7 +271,10 @@ SendLoop: break SendLoop } else { // Pass the error back and abort - t.recv_chan <- err + select { + case <-t.shutdown: + case t.recv_chan <- err: + } break SendLoop } } From c01aa8a6af9436581c79786c06102ce21e41c70c Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 17 May 2015 20:17:15 +0100 Subject: [PATCH 18/50] Fix build on Windows Update documentation to use msysGit - the easiest method I could find Fix setup_root to copy instead of link on Windows when creating workspace Fake a .git folder in the workspace to prevent Stale Checkout go get problems with downloaded packages (though git clone is preferred and recommended) - this helps *nix/OSX too --- README.md | 34 ++++++++++++++++++++++++++-------- build/setup_root | 22 +++++++++++++++++++--- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d92db24b..0cb4e36e 100644 --- a/README.md +++ b/README.md @@ -104,22 +104,42 @@ moment, no such repository exists. Requirements: -1. Linux, Unix, OS X or Windows with [Cygwin](https://cygwin.com) -1. The [golang](http://golang.org/doc/install) compiler tools (1.2-1.4) -1. [git](http://git-scm.com) +1. Linux, Unix, OS X or Windows +1. The [Golang](http://golang.org/doc/install) compiler tools (1.2-1.4) +1. git 1. GNU make -*__Linux/Unix:__ Most requirements can usually be installed by your favourite +### Linux / Unix / OS X + +*__Linux / Unix:__ Most requirements can usually be installed by your favourite package manager.* *__OS X:__ Git and GNU make are provided automatically by XCode.* -*__Windows:__ Git and GNU make are available as Cygwin packages.* -To build the binaries, simply run `make` as follows. +Run the following commands to download and build Log Courier. git clone https://github.com/driskell/log-courier cd log-courier make +*Note: If you receive errors whilst running `make`, try `gmake` instead.* + +### Windows + +*Installing [msysGit](http://msysgit.github.io/) will provide you with Git and +GNU make, and a Unix-like environment to build within.* + +Changing the path to Go if necessary (the default is `C:\Go`, which in msys +terms is written as `/c/Go`), run the following commands to download and build +Log Courier. + + export GOROOT=/c/Go + export PATH=$PATH:$GOROOT/bin + git clone https://github.com/driskell/log-courier + cd log-courier + make + +### Results + The log-courier program can then be found in the 'bin' folder. Service scripts for various platforms can be found in the [contrib/initscripts](contrib/initscripts) folder, or it can be run on the @@ -127,8 +147,6 @@ command line: bin/log-courier -config /path/to/config.conf -*Note: If you receive errors whilst running `make`, try `gmake` instead.* - ## Logstash Integration Log Courier communicates with Logstash via an input plugin called "courier". diff --git a/build/setup_root b/build/setup_root index 79e6bedd..5624611e 100755 --- a/build/setup_root +++ b/build/setup_root @@ -1,5 +1,21 @@ #!/bin/bash -# Allow the source code to refer to github.com/driskell/log-courier paths -mkdir -p src/github.com/driskell -ln -nsf ../../.. src/github.com/driskell/log-courier +# Allow 'go get' to see we already have the log-courier packages by setting +# up a rough Go workspace. + +if [ "$OS" = "Windows_NT" ]; then + # Windows lacks symlinks and MinGW 'ln' fails with 'Permission denied' as it + # tries to copy a folder into a subfolder of itself, copying nothing, so 'cp' + # manually. + rm -rf src/github.com/driskell/log-courier + mkdir -p src/github.com/driskell/log-courier + cp -rf {.git,src} src/github.com/driskell/log-courier/ +else + mkdir -p src/github.com/driskell + ln -nsf ../../.. src/github.com/driskell/log-courier +fi + +# Fake a .git folder for downloaded archives to avoid 'go get' 'Stale checkout' +if [ ! -d src/github.com/driskell/log-courier/.git ]; then + mkdir src/github.com/driskell/log-courier/.git +fi From 78a669944dd71d284c1992fcbdda47c7c5c4d61b Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 17 May 2015 20:18:55 +0100 Subject: [PATCH 19/50] Hide a warning message during build on Windows --- build/setup_root | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/setup_root b/build/setup_root index 5624611e..90ff17f0 100755 --- a/build/setup_root +++ b/build/setup_root @@ -9,7 +9,8 @@ if [ "$OS" = "Windows_NT" ]; then # manually. rm -rf src/github.com/driskell/log-courier mkdir -p src/github.com/driskell/log-courier - cp -rf {.git,src} src/github.com/driskell/log-courier/ + # 2>devnull to Hide 'cannot copy src into itself' + cp -rf {.git,src} src/github.com/driskell/log-courier/ 2>/dev/null else mkdir -p src/github.com/driskell ln -nsf ../../.. src/github.com/driskell/log-courier From 2db01f18726a122ffe6c8f28f8b978657fc59236 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 17 May 2015 20:23:09 +0100 Subject: [PATCH 20/50] Update documentation for Windows build This and last 2 commits fix #158 --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0cb4e36e..ab01f31b 100644 --- a/README.md +++ b/README.md @@ -105,15 +105,15 @@ moment, no such repository exists. Requirements: 1. Linux, Unix, OS X or Windows -1. The [Golang](http://golang.org/doc/install) compiler tools (1.2-1.4) -1. git 1. GNU make +1. git +1. The [Golang](http://golang.org/doc/install) compiler tools (1.2-1.4) ### Linux / Unix / OS X -*__Linux / Unix:__ Most requirements can usually be installed by your favourite -package manager.* -*__OS X:__ Git and GNU make are provided automatically by XCode.* +*Most requirements are usually available via your operating system +distribution's package manager. On OS X, Git and GNU make are provided +automatically by XCode.* Run the following commands to download and build Log Courier. From 497769f89d711b3a62d452bb455605597aa486f5 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 17 May 2015 20:25:19 +0100 Subject: [PATCH 21/50] Readme tweaks --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ab01f31b..f885c8f4 100644 --- a/README.md +++ b/README.md @@ -111,9 +111,8 @@ Requirements: ### Linux / Unix / OS X -*Most requirements are usually available via your operating system -distribution's package manager. On OS X, Git and GNU make are provided -automatically by XCode.* +*Most requirements are usually available via your distribution's package +manager. On OS X, Git and GNU make are provided automatically by XCode.* Run the following commands to download and build Log Courier. @@ -128,9 +127,9 @@ Run the following commands to download and build Log Courier. *Installing [msysGit](http://msysgit.github.io/) will provide you with Git and GNU make, and a Unix-like environment to build within.* -Changing the path to Go if necessary (the default is `C:\Go`, which in msys -terms is written as `/c/Go`), run the following commands to download and build -Log Courier. +Run the following commands to download and build Log Courier, changing the path +to the Golang installation if necessary (the default is `C:\Go`, which in msys +terms is `/c/Go`.) export GOROOT=/c/Go export PATH=$PATH:$GOROOT/bin From 1ee3f8c60412946d8c9b73de5ab4ffea7146b7cf Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 17 May 2015 22:40:39 +0100 Subject: [PATCH 22/50] WIP debian packaging Add to installed files Add copyright file Add run folder Tweak default config to be inline with log-courier actual default config Only install examples, no config Update standards version Change maintainer Update description --- debian/README | 3 +-- debian/changelog | 6 ++++++ debian/control | 13 +++++-------- debian/copyright | 18 ++++++++++++++++++ debian/log-courier.conf | 23 ----------------------- debian/log-courier.default | 3 +-- debian/log-courier.dirs | 4 +++- debian/rules | 10 +++++++--- 8 files changed, 41 insertions(+), 39 deletions(-) create mode 100644 debian/copyright delete mode 100644 debian/log-courier.conf diff --git a/debian/README b/debian/README index 58c53984..2cffb6d9 100644 --- a/debian/README +++ b/debian/README @@ -14,5 +14,4 @@ Add go to the PATH Build the packages - $ dpkg-buildpackage - + $ dpkg-buildpackage diff --git a/debian/changelog b/debian/changelog index 5612c53c..628e4515 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +log-courier (1.6) UNRELEASED; urgency=low + + * Package for PPA + + -- Jason Woods Sun, 17 May 2015 21:44:00 +0100 + log-courier (1.6) UNRELEASED; urgency=low * Update to release 1.6 diff --git a/debian/control b/debian/control index 7450511e..33f83911 100644 --- a/debian/control +++ b/debian/control @@ -1,16 +1,13 @@ Source: log-courier Section: admin Priority: optional -Standards-Version: 3.9.2 -Maintainer: Matthew Newton +Standards-Version: 3.9.5 +Maintainer: Jason Woods Build-Depends: debhelper (>= 9), golang-go Package: log-courier Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Log file shipper - Log Courier is a tool created to transmit log files speedily and securely to - remote Logstash instances for processing whilst using small amounts of local - resources. The project is an enhanced fork of Logstash Forwarder 0.3.1 with - many enhancements and behavioural improvements. - +Description: Log Courier + Log Courier is a lightweight tool created to ship log files speedily and + securely, with low resource usage, to remote Logstash instances. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..e4947b4f --- /dev/null +++ b/debian/copyright @@ -0,0 +1,18 @@ +Copyright 2014 Jason Woods. + +Log Courier includes code from Logstash Forwarder. +Copyright 2012-2013 Jordan Sissel and contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +/usr/share/common-licenses/Apache-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/debian/log-courier.conf b/debian/log-courier.conf deleted file mode 100644 index e6df0b5a..00000000 --- a/debian/log-courier.conf +++ /dev/null @@ -1,23 +0,0 @@ -{ - "general": { - "persist directory": "/var/lib/log-courier", - "log syslog": true, - "log stdout": false, - "admin listen address": "unix:/var/run/log-courier/admin.socket" - }, - "network": { - "transport": "tcp", - "reconnect": 10, - "servers": [ "localhost:5043" ] - }, - "files": [ - { -# "paths": [ "/var/log/syslog", "/var/log/syslog.1" ], - "fields": { - "type": "syslog" - }, - "dead time": "12h" - } - ] -} - diff --git a/debian/log-courier.default b/debian/log-courier.default index 86d83413..c84d7901 100644 --- a/debian/log-courier.default +++ b/debian/log-courier.default @@ -1,3 +1,2 @@ # log-courier options - -LOG_COURIER_ARGS="-config=/etc/log-courier/log-courier.conf -from-beginning=true" +LOG_COURIER_ARGS="-config=/etc/log-courier/log-courier.conf" diff --git a/debian/log-courier.dirs b/debian/log-courier.dirs index 0fa0ea4f..685f1a62 100644 --- a/debian/log-courier.dirs +++ b/debian/log-courier.dirs @@ -1,4 +1,6 @@ +etc/log-courier +etc/log-courier/examples usr/bin usr/share/doc/log-courier -etc/log-courier var/lib/log-courier +var/run/log-courier diff --git a/debian/rules b/debian/rules index cb9d446c..595e2179 100755 --- a/debian/rules +++ b/debian/rules @@ -9,10 +9,14 @@ override_dh_auto_build: override_dh_auto_test: override_dh_auto_install: + # Install binaries install -m 0755 bin/log-courier debian/log-courier/usr/bin/log-courier install -m 0755 bin/lc-admin debian/log-courier/usr/bin/lc-admin install -m 0755 bin/lc-tlscert debian/log-courier/usr/bin/lc-tlscert - install -m 0755 debian/log-courier.conf debian/log-courier/etc/log-courier/log-courier.conf - cp -av docs/* debian/log-courier/usr/share/doc/log-courier/ - install -m 0644 LICENSE debian/log-courier/usr/share/doc/log-courier/copyright + # Install example configuration + cp -av docs/examples/* debian/log-courier/etc/log-courier/examples/ + + # Install copyright and docs + install -m 0644 debian/copyright debian/log-courier/usr/share/doc/log-courier/copyright + cp -av docs/* debian/log-courier/usr/share/doc/log-courier/ From 3d41588990a988104c074d9ab0ec1823ae6c9def Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 17 May 2015 22:50:19 +0100 Subject: [PATCH 23/50] Normalise redhat and debian sysconfig/default files --- contrib/initscripts/log-courier.sysconfig | 5 ++--- contrib/initscripts/redhat-sysv.init | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/contrib/initscripts/log-courier.sysconfig b/contrib/initscripts/log-courier.sysconfig index 07dbd982..389ed781 100644 --- a/contrib/initscripts/log-courier.sysconfig +++ b/contrib/initscripts/log-courier.sysconfig @@ -1,3 +1,2 @@ -# log-courier config file location -CONFIG_FILE="/etc/log-courier/log-courier.conf" - +# log-courier options +LOG_COURIER_ARGS='-config /etc/log-courier/log-courier.conf' diff --git a/contrib/initscripts/redhat-sysv.init b/contrib/initscripts/redhat-sysv.init index d9223132..532f7aef 100755 --- a/contrib/initscripts/redhat-sysv.init +++ b/contrib/initscripts/redhat-sysv.init @@ -27,8 +27,8 @@ if [ -f /etc/sysconfig/log-courier ]; then fi # set default config file, if $CONFIG_FILE is not set -if [ -z ${CONFIG_FILE} ]; then - CONFIG_FILE='/etc/log-courier/log-courier.conf' +if [ -z ${LOG_COURIER_ARGS} ]; then + LOG_COURIER_ARGS='-config /etc/log-courier/log-courier.conf' fi do_start() { @@ -39,7 +39,7 @@ do_start() { success else cd $DATA_DIR - nohup ${DAEMON} -config="${CONFIG_FILE}" /dev/null & + nohup ${DAEMON} ${LOG_COURIER_ARGS} /dev/null & RC=$? echo $! > ${PID_FILE} [ $RC -eq 0 ] && success || failure From 12bc7534b5b56fce403c976e100fbaa3af9ac14e Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 17 May 2015 22:50:35 +0100 Subject: [PATCH 24/50] Debian packaging - create directories in install command --- debian/log-courier.dirs | 6 ------ debian/rules | 9 +++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) delete mode 100644 debian/log-courier.dirs diff --git a/debian/log-courier.dirs b/debian/log-courier.dirs deleted file mode 100644 index 685f1a62..00000000 --- a/debian/log-courier.dirs +++ /dev/null @@ -1,6 +0,0 @@ -etc/log-courier -etc/log-courier/examples -usr/bin -usr/share/doc/log-courier -var/lib/log-courier -var/run/log-courier diff --git a/debian/rules b/debian/rules index 595e2179..97fd1f2f 100755 --- a/debian/rules +++ b/debian/rules @@ -10,13 +10,22 @@ override_dh_auto_test: override_dh_auto_install: # Install binaries + mkdir -p debian/log-courier/usr/bin install -m 0755 bin/log-courier debian/log-courier/usr/bin/log-courier install -m 0755 bin/lc-admin debian/log-courier/usr/bin/lc-admin install -m 0755 bin/lc-tlscert debian/log-courier/usr/bin/lc-tlscert # Install example configuration + mkdir -p debian/log-courier/etc/log-courier/examples cp -av docs/examples/* debian/log-courier/etc/log-courier/examples/ + # Make the run dir + mkdir -p debian/log-courier/var/run/log-courier + + # Make the state dir + mkdir -p debian/log-courier/var/lib/log-courier + # Install copyright and docs + mkdir -p debian/log-courier/usr/share/doc/log-courier install -m 0644 debian/copyright debian/log-courier/usr/share/doc/log-courier/copyright cp -av docs/* debian/log-courier/usr/share/doc/log-courier/ From 5596570e3716198faba52fab28f4f0ae3c8c9d24 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 17 May 2015 22:57:15 +0100 Subject: [PATCH 25/50] Shellcheck --- contrib/initscripts/redhat-sysv.init | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/contrib/initscripts/redhat-sysv.init b/contrib/initscripts/redhat-sysv.init index 532f7aef..97134506 100755 --- a/contrib/initscripts/redhat-sysv.init +++ b/contrib/initscripts/redhat-sysv.init @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # log-courier Log Courier, a lightweight log shipper with Logstash integration. # @@ -27,22 +27,28 @@ if [ -f /etc/sysconfig/log-courier ]; then fi # set default config file, if $CONFIG_FILE is not set -if [ -z ${LOG_COURIER_ARGS} ]; then +if [ -z "$LOG_COURIER_ARGS" ]; then LOG_COURIER_ARGS='-config /etc/log-courier/log-courier.conf' fi -do_start() { +do_start() +{ echo -n "Starting Log Courier: " status -p $PID_FILE $DAEMON &>/dev/null RC=$? if [ $RC -eq 0 ]; then success else - cd $DATA_DIR - nohup ${DAEMON} ${LOG_COURIER_ARGS} /dev/null & + cd "$DATA_DIR" + # shellcheck disable=SC2086 + nohup "$DAEMON" $LOG_COURIER_ARGS /dev/null & RC=$? - echo $! > ${PID_FILE} - [ $RC -eq 0 ] && success || failure + echo "$!" > "$PID_FILE" + if [ $RC -eq 0 ]; then + success + else + failure + fi fi echo return $? From 3224842eda17b986d7370af10c5a4b2d33a35a59 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 17 May 2015 23:13:38 +0100 Subject: [PATCH 26/50] Move debian folder to contrib for tidiness A future commit MAY bring a `make deb` command to move things back into place for dpkg-buildpackage --- {debian => contrib/deb}/README | 0 {debian => contrib/deb}/changelog | 0 {debian => contrib/deb}/compat | 0 {debian => contrib/deb}/control | 0 {debian => contrib/deb}/copyright | 0 {debian => contrib/deb}/log-courier.default | 0 {debian => contrib/deb}/log-courier.init | 0 {debian => contrib/deb}/rules | 0 {debian => contrib/deb}/source/format | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename {debian => contrib/deb}/README (100%) rename {debian => contrib/deb}/changelog (100%) rename {debian => contrib/deb}/compat (100%) rename {debian => contrib/deb}/control (100%) rename {debian => contrib/deb}/copyright (100%) rename {debian => contrib/deb}/log-courier.default (100%) rename {debian => contrib/deb}/log-courier.init (100%) rename {debian => contrib/deb}/rules (100%) rename {debian => contrib/deb}/source/format (100%) diff --git a/debian/README b/contrib/deb/README similarity index 100% rename from debian/README rename to contrib/deb/README diff --git a/debian/changelog b/contrib/deb/changelog similarity index 100% rename from debian/changelog rename to contrib/deb/changelog diff --git a/debian/compat b/contrib/deb/compat similarity index 100% rename from debian/compat rename to contrib/deb/compat diff --git a/debian/control b/contrib/deb/control similarity index 100% rename from debian/control rename to contrib/deb/control diff --git a/debian/copyright b/contrib/deb/copyright similarity index 100% rename from debian/copyright rename to contrib/deb/copyright diff --git a/debian/log-courier.default b/contrib/deb/log-courier.default similarity index 100% rename from debian/log-courier.default rename to contrib/deb/log-courier.default diff --git a/debian/log-courier.init b/contrib/deb/log-courier.init similarity index 100% rename from debian/log-courier.init rename to contrib/deb/log-courier.init diff --git a/debian/rules b/contrib/deb/rules similarity index 100% rename from debian/rules rename to contrib/deb/rules diff --git a/debian/source/format b/contrib/deb/source/format similarity index 100% rename from debian/source/format rename to contrib/deb/source/format From fd266bc40020c6f41d07c0d49f011d2943a753e5 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Sun, 17 May 2015 23:14:03 +0100 Subject: [PATCH 27/50] Update packaging for readme files Update RPM spec version --- contrib/deb/README | 28 +++++++++++++++++++++++----- contrib/rpm/README | 29 +++++++++++++++++++++++++++++ contrib/rpm/log-courier.spec | 2 +- 3 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 contrib/rpm/README diff --git a/contrib/deb/README b/contrib/deb/README index 2cffb6d9..6d1a869a 100644 --- a/contrib/deb/README +++ b/contrib/deb/README @@ -1,5 +1,17 @@ -To build the debian package on wheezy -===================================== +Packaging Instructions +====================== + +Install required package building packages + + sudo apt-get install devscripts debhelper golang-go + +Copy the contrib/deb folder to the project root. +Then run the packaging command + + dpkg-buildpackage + +Packaging on Wheezy +=================== The version of 'go' available in the golang-go package available in Debian wheezy is not recent enough to build this package. The following procedure @@ -10,8 +22,14 @@ First, grab the latest go from https://golang.org/ and install as standard in Add go to the PATH - $ export PATH=/usr/local/go/bin:$PATH + export PATH=/usr/local/go/bin:$PATH + +Build the packages as normal + +Building a Source DEB +===================== -Build the packages +Follow the instructions for a regular package using the following command +instead of dpkg-buildpackage - $ dpkg-buildpackage + debuild -S -uc diff --git a/contrib/rpm/README b/contrib/rpm/README new file mode 100644 index 00000000..d6bf53c9 --- /dev/null +++ b/contrib/rpm/README @@ -0,0 +1,29 @@ +Packaging Instructions +====================== + +Install the required package building packages: + + sudo yum install rpmbuild golang + +Setup a standard RPM build workspace with the required folders + + mkdir rpmbuild + mkdir rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} + +Copy the .spec file into the SPECS folder. +Download the .zip of Log Courier from GitHub or create your own containing the +full repository, and copy this into SOURCES with the filename vXXX.zip where XXX +is the version number in the .spec file (e.g. v1.6.zip). + +Enter the SPECS folder and then build + + cd SPECS + rpmbuild -ba log-courier.spec + +Building a Source RPM +===================== + +Follow the instructions for a binary package using the following rpmbuild +parameters instead + + rpmbuild -bs log-courier.spec diff --git a/contrib/rpm/log-courier.spec b/contrib/rpm/log-courier.spec index 729217d7..eab19382 100644 --- a/contrib/rpm/log-courier.spec +++ b/contrib/rpm/log-courier.spec @@ -4,7 +4,7 @@ Summary: Log Courier Name: log-courier -Version: 1.5 +Version: 1.6 Release: 1%{dist} License: GPL Group: System Environment/Libraries From b125c9f5aa0ba8d770b6ed78e18197943af36a16 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Mon, 18 May 2015 00:04:30 +0100 Subject: [PATCH 28/50] Debian packaging tweaks Set correct key name Update instructions Set Section and set distribution to experimental for now --- contrib/deb/README | 4 ++++ contrib/deb/changelog | 4 ++-- contrib/deb/control | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/contrib/deb/README b/contrib/deb/README index 6d1a869a..370be810 100644 --- a/contrib/deb/README +++ b/contrib/deb/README @@ -33,3 +33,7 @@ Follow the instructions for a regular package using the following command instead of dpkg-buildpackage debuild -S -uc + +To switch lintian profile during build: + + debuild -S -uc --lintian-opts --profile debian diff --git a/contrib/deb/changelog b/contrib/deb/changelog index 628e4515..6b02695d 100644 --- a/contrib/deb/changelog +++ b/contrib/deb/changelog @@ -1,8 +1,8 @@ -log-courier (1.6) UNRELEASED; urgency=low +log-courier (1.6) experimental; urgency=low * Package for PPA - -- Jason Woods Sun, 17 May 2015 21:44:00 +0100 + -- Jason Woods (Driskell) Sun, 17 May 2015 21:44:00 +0100 log-courier (1.6) UNRELEASED; urgency=low diff --git a/contrib/deb/control b/contrib/deb/control index 33f83911..4ace2945 100644 --- a/contrib/deb/control +++ b/contrib/deb/control @@ -1,8 +1,8 @@ Source: log-courier -Section: admin +Section: contrib/admin Priority: optional Standards-Version: 3.9.5 -Maintainer: Jason Woods +Maintainer: Jason Woods (Driskell) Build-Depends: debhelper (>= 9), golang-go Package: log-courier From 27622ac604bc7d96e92011357eb3369098b7c691 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Mon, 18 May 2015 00:05:41 +0100 Subject: [PATCH 29/50] Switch develop to master branch for better Go toolset compatibility Take travis status for master branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f885c8f4..d823bc2a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Log Courier -[![Build Status](https://img.shields.io/travis/driskell/log-courier/develop.svg)](https://travis-ci.org/driskell/log-courier) +[![Build Status](https://img.shields.io/travis/driskell/log-courier/master.svg)](https://travis-ci.org/driskell/log-courier) [![Latest Release](https://img.shields.io/github/release/driskell/log-courier.svg)](https://github.com/driskell/log-courier/releases/latest) Log Courier is a lightweight tool created to ship log files speedily and From e519297ceaf0fb95510a9b75db2cfe938420ff36 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Tue, 19 May 2015 11:03:37 +0100 Subject: [PATCH 30/50] Distribution must be trusty - use 1.6-2 version to distinguish package rebuilds TODO: 1.6-2 detects as debian native due to source/format - needs looking at --- contrib/deb/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/deb/changelog b/contrib/deb/changelog index 6b02695d..6e90aefa 100644 --- a/contrib/deb/changelog +++ b/contrib/deb/changelog @@ -1,4 +1,4 @@ -log-courier (1.6) experimental; urgency=low +log-courier (1.6-2) trusty; urgency=low * Package for PPA From b3a5b268c347c8cffc46d3094291dea15b4f808f Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Tue, 19 May 2015 20:19:16 +0100 Subject: [PATCH 31/50] Improve packaging guides --- contrib/deb/README | 12 ++++++------ contrib/rpm/README | 11 +++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/contrib/deb/README b/contrib/deb/README index 370be810..e3ab3f35 100644 --- a/contrib/deb/README +++ b/contrib/deb/README @@ -5,9 +5,13 @@ Install required package building packages sudo apt-get install devscripts debhelper golang-go -Copy the contrib/deb folder to the project root. -Then run the packaging command +Run the following commands to get the source, create the required upstream +archive, setup the source for debian building, and build the package. + git clone https://github.com/driskell/log-courier + tar -czf log-courier_VERSION.orig.tar.gz log-courier + cd log-courier + mv contrib/deb debian dpkg-buildpackage Packaging on Wheezy @@ -33,7 +37,3 @@ Follow the instructions for a regular package using the following command instead of dpkg-buildpackage debuild -S -uc - -To switch lintian profile during build: - - debuild -S -uc --lintian-opts --profile debian diff --git a/contrib/rpm/README b/contrib/rpm/README index d6bf53c9..62dde663 100644 --- a/contrib/rpm/README +++ b/contrib/rpm/README @@ -10,14 +10,13 @@ Setup a standard RPM build workspace with the required folders mkdir rpmbuild mkdir rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} -Copy the .spec file into the SPECS folder. -Download the .zip of Log Courier from GitHub or create your own containing the -full repository, and copy this into SOURCES with the filename vXXX.zip where XXX -is the version number in the .spec file (e.g. v1.6.zip). - -Enter the SPECS folder and then build +Run the following commands to download the required source archive, the RPM spec +file and build the package. + cd SOURCES + wget https://github.com/driskell/log-courier/archive/vVERSION.zip cd SPECS + wget https://raw.githubusercontent.com/driskell/log-courier/vVERSION/contrib/rpm/log-courier.spec rpmbuild -ba log-courier.spec Building a Source RPM From 86633749ace6d31d2dd2e8a3ff4387de8e8ad3d2 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Tue, 19 May 2015 20:19:26 +0100 Subject: [PATCH 32/50] Quilt not native --- contrib/deb/source/format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/deb/source/format b/contrib/deb/source/format index 89ae9db8..163aaf8d 100644 --- a/contrib/deb/source/format +++ b/contrib/deb/source/format @@ -1 +1 @@ -3.0 (native) +3.0 (quilt) From 6043829da2c865b5855b66421050af4a1ccf3997 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Tue, 19 May 2015 20:24:59 +0100 Subject: [PATCH 33/50] Update packaging guides --- contrib/deb/README | 6 +++--- contrib/rpm/README | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/deb/README b/contrib/deb/README index e3ab3f35..ceb86cc3 100644 --- a/contrib/deb/README +++ b/contrib/deb/README @@ -1,7 +1,7 @@ Packaging Instructions ====================== -Install required package building packages +Install required package building packages. sudo apt-get install devscripts debhelper golang-go @@ -34,6 +34,6 @@ Building a Source DEB ===================== Follow the instructions for a regular package using the following command -instead of dpkg-buildpackage +instead of dpkg-buildpackage. - debuild -S -uc + debuild -S -sa diff --git a/contrib/rpm/README b/contrib/rpm/README index 62dde663..f7061d32 100644 --- a/contrib/rpm/README +++ b/contrib/rpm/README @@ -1,11 +1,11 @@ Packaging Instructions ====================== -Install the required package building packages: +Install the required package building packages. sudo yum install rpmbuild golang -Setup a standard RPM build workspace with the required folders +Setup a standard RPM build workspace with the required folders. mkdir rpmbuild mkdir rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} @@ -23,6 +23,6 @@ Building a Source RPM ===================== Follow the instructions for a binary package using the following rpmbuild -parameters instead +parameters instead. - rpmbuild -bs log-courier.spec + rpmbuild -bs --sign log-courier.spec From 87e7a3034928c5684105ab7340884c5322dff378 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Tue, 19 May 2015 20:31:11 +0100 Subject: [PATCH 34/50] Match changelog with current PPA version --- contrib/deb/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/deb/changelog b/contrib/deb/changelog index 6e90aefa..66a4a991 100644 --- a/contrib/deb/changelog +++ b/contrib/deb/changelog @@ -1,8 +1,8 @@ -log-courier (1.6-2) trusty; urgency=low +log-courier (1.6-3) trusty; urgency=low * Package for PPA - -- Jason Woods (Driskell) Sun, 17 May 2015 21:44:00 +0100 + -- Jason Woods (Driskell) Tue, 19 May 2015 20:29:00 +0100 log-courier (1.6) UNRELEASED; urgency=low From 51d0880825aa7083f84367eb26ef0af26bda974d Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Tue, 19 May 2015 20:40:45 +0100 Subject: [PATCH 35/50] Fix missing git --- contrib/deb/changelog | 2 +- contrib/deb/control | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/deb/changelog b/contrib/deb/changelog index 66a4a991..17da0875 100644 --- a/contrib/deb/changelog +++ b/contrib/deb/changelog @@ -1,4 +1,4 @@ -log-courier (1.6-3) trusty; urgency=low +log-courier (1.6-4) trusty; urgency=low * Package for PPA diff --git a/contrib/deb/control b/contrib/deb/control index 4ace2945..d966e52c 100644 --- a/contrib/deb/control +++ b/contrib/deb/control @@ -3,7 +3,7 @@ Section: contrib/admin Priority: optional Standards-Version: 3.9.5 Maintainer: Jason Woods (Driskell) -Build-Depends: debhelper (>= 9), golang-go +Build-Depends: debhelper (>= 9), golang-go, git Package: log-courier Architecture: any From 38fd0337e6f2acb991defaa9f39aac94769b7aa0 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Tue, 19 May 2015 21:50:58 +0100 Subject: [PATCH 36/50] Start deb versioning again with fresh PPA --- contrib/deb/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/deb/changelog b/contrib/deb/changelog index 17da0875..c3ad677c 100644 --- a/contrib/deb/changelog +++ b/contrib/deb/changelog @@ -1,4 +1,4 @@ -log-courier (1.6-4) trusty; urgency=low +log-courier (1.6-1) trusty; urgency=low * Package for PPA From c111d117fe1721fb102b9fb9f821006dcaf57d7c Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Wed, 20 May 2015 09:21:45 +0100 Subject: [PATCH 37/50] Ubuntu PPA packaging complete --- Makefile | 2 ++ README.md | 22 ++++++++++++++++------ build/setup_root | 3 ++- contrib/deb/changelog | 20 +++++++++++++++++++- contrib/deb/rules | 6 +++++- 5 files changed, 44 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index c27163de..47595ecc 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,9 @@ vendor/bundle/.GemfileJRubyModT: Gemfile clean: go clean -i ./... ifneq ($(implyclean),yes) +ifneq ($(keepgoget),yes) rm -rf src/github.com +endif rm -rf vendor/bundle rm -f Gemfile.lock rm -f *.gem diff --git a/README.md b/README.md index d823bc2a..e6970289 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ to distinguish events send from different instances ## Public Repositories -### RPM +### Redhat / CentOS *The Log Courier repository depends on the __EPEL__ repository which can be installed automatically on CentOS distributions by running @@ -81,7 +81,7 @@ installed automatically on CentOS distributions by running installation instructions on the [EPEL homepage](https://fedoraproject.org/wiki/EPEL).* -To install the Log Courier repository, download the corresponding `.repo` +To install the Log Courier YUM repository, download the corresponding `.repo` configuration file below, and place it in `/etc/yum.repos.d`. Log Courier may then be installed using `yum install log-courier`. @@ -89,16 +89,26 @@ then be installed using `yum install log-courier`. * **CentOS/RedHat 7.x**: [driskell-log-courier-epel-7.repo](https://copr.fedoraproject.org/coprs/driskell/log-courier/repo/epel-6/driskell-log-courier-epel-7.repo) -Once installed, modify the configuration file at +Once installed, create a configuration file at `/etc/log-courier/log-courier.conf` to suit your needs, then start the Log Courier service to begin shipping. service log-courier start -### DEB +### Ubuntu -A Debian/Ubuntu compatible **PPA** repository is under consideration. At the -moment, no such repository exists. +To install the Log Courier apt-get repository, run the following commands. + + sudo add-apt-repository ppa:devel-k/log-courier + sudo apt-get update + +Log Courier may then be installed using `apt-get install log-courier`. + +Once installed, create a configuration file at +`/etc/log-courier/log-courier.conf` to suit your needs, then start the Log +Courier service to begin shipping. + + service log-courier start ## Building from Source diff --git a/build/setup_root b/build/setup_root index 90ff17f0..aa9d5907 100755 --- a/build/setup_root +++ b/build/setup_root @@ -3,11 +3,12 @@ # Allow 'go get' to see we already have the log-courier packages by setting # up a rough Go workspace. +rm -rf src/github.com/driskell/log-courier + if [ "$OS" = "Windows_NT" ]; then # Windows lacks symlinks and MinGW 'ln' fails with 'Permission denied' as it # tries to copy a folder into a subfolder of itself, copying nothing, so 'cp' # manually. - rm -rf src/github.com/driskell/log-courier mkdir -p src/github.com/driskell/log-courier # 2>devnull to Hide 'cannot copy src into itself' cp -rf {.git,src} src/github.com/driskell/log-courier/ 2>/dev/null diff --git a/contrib/deb/changelog b/contrib/deb/changelog index c3ad677c..03843f56 100644 --- a/contrib/deb/changelog +++ b/contrib/deb/changelog @@ -1,8 +1,26 @@ +log-courier (1.6-4) trusty; urgency=low + + * Fix unsupported symlink in deb source + + -- Jason Woods (Driskell) Wed, 20 May 2015 08:47:00 +0100 + +log-courier (1.6-3) trusty; urgency=low + + * Fix make clean removing bundled go-logging + + -- Jason Woods (Driskell) Sun, 17 May 2015 22:11:00 +0100 + +log-courier (1.6-2) trusty; urgency=low + + * Bundle go-logging and other golang dependencies + + -- Jason Woods (Driskell) Sun, 17 May 2015 21:57:00 +0100 + log-courier (1.6-1) trusty; urgency=low * Package for PPA - -- Jason Woods (Driskell) Tue, 19 May 2015 20:29:00 +0100 + -- Jason Woods (Driskell) Sun, 17 May 2015 21:44:00 +0100 log-courier (1.6) UNRELEASED; urgency=low diff --git a/contrib/deb/rules b/contrib/deb/rules index 97fd1f2f..363a6b2d 100755 --- a/contrib/deb/rules +++ b/contrib/deb/rules @@ -3,10 +3,14 @@ %: dh $@ +override_dh_auto_clean: + $(MAKE) clean keepgoget=yes + override_dh_auto_build: - make + $(MAKE) override_dh_auto_test: + # Maybe tests in future - we'd need to download the ffi gem override_dh_auto_install: # Install binaries From 3efb33c875d02437de08dc7df94f24401f7da96c Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Wed, 20 May 2015 09:24:40 +0100 Subject: [PATCH 38/50] Request feedback on Ubuntu repository --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index e6970289..3d3005f7 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,9 @@ Courier service to begin shipping. service log-courier start +**NOTE:** The Ubuntu packages have had limited testing and you are welcome to give +feedback and raise feature requests or bug reports to help improve them! + ## Building from Source Requirements: From b54acb87844dcdb4a276e3e494f0ea9d70c0345b Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Wed, 20 May 2015 19:59:31 +0100 Subject: [PATCH 39/50] Plugins: Remove deprecated milestone and rename the gems so the version lookup works correctly in Logstash Fixes #164 --- .gitignore | 4 ++-- Makefile | 4 ++-- README.md | 2 +- build/fix_version | 2 +- docs/LogstashIntegration.md | 6 +++--- lib/logstash/inputs/courier.rb | 1 - lib/logstash/outputs/courier.rb | 1 - ...rier.gemspec.tmpl => logstash-input-courier.gemspec.tmpl | 2 +- ...ier.gemspec.tmpl => logstash-output-courier.gemspec.tmpl | 4 ++-- 9 files changed, 12 insertions(+), 14 deletions(-) rename logstash-input-log-courier.gemspec.tmpl => logstash-input-courier.gemspec.tmpl (93%) rename logstash-output-log-courier.gemspec.tmpl => logstash-output-courier.gemspec.tmpl (91%) diff --git a/.gitignore b/.gitignore index dc2c9a9f..a70f47eb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,8 @@ /Gemfile.lock /bin /log-courier.gemspec -/logstash-input-log-courier.gemspec -/logstash-output-log-courier.gemspec +/logstash-input-courier.gemspec +/logstash-output-courier.gemspec /node_modules /pkg /spec/tmp diff --git a/Makefile b/Makefile index c27163de..e1dae5e9 100644 --- a/Makefile +++ b/Makefile @@ -40,8 +40,8 @@ gem: | fix_version gem build log-courier.gemspec gem_plugins: | fix_version - gem build logstash-input-log-courier.gemspec - gem build logstash-output-log-courier.gemspec + gem build logstash-input-courier.gemspec + gem build logstash-output-courier.gemspec push_gems: | gem gem_plugins build/push_gems diff --git a/README.md b/README.md index f60658e5..70136a7e 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ beyond the lumberjack protocol allows. You may install the input plugin using the Logstash 1.5 Plugin manager. cd /path/to/logstash - bin/logstash plugin install logstash-input-log-courier + bin/logstash plugin install logstash-input-courier Detailed instructions, including integration with Logstash 1.4.x, can be found on the [Logstash Integration](docs/LogstashIntegration.md) page. diff --git a/build/fix_version b/build/fix_version index 7b27d0bd..c443cc98 100755 --- a/build/fix_version +++ b/build/fix_version @@ -21,7 +21,7 @@ fi sed "s//${VERSION}/g" src/lc-lib/core/version.go.tmpl > src/lc-lib/core/version.go # Patch the gemspecs -for GEM in log-courier logstash-input-log-courier logstash-output-log-courier; do +for GEM in log-courier logstash-input-courier logstash-output-courier; do sed "s//${VERSION}/g" ${GEM}.gemspec.tmpl > ${GEM}.gemspec done diff --git a/docs/LogstashIntegration.md b/docs/LogstashIntegration.md index 42f7048c..3df430e9 100644 --- a/docs/LogstashIntegration.md +++ b/docs/LogstashIntegration.md @@ -17,7 +17,7 @@ Log Courier is built to work seamlessly with [Logstash](http://logstash.net) ## Installation -### Logstash 1.5 Plugin Manager +### Logstash Plugin Manager Logstash 1.5 introduces a new plugin manager that makes installing additional plugins extremely easy. @@ -27,8 +27,8 @@ Log Courier plugins. If you are only receiving events, you only need to install the input plugin. cd /path/to/logstash - bin/logstash plugin install logstash-input-log-courier - bin/logstash plugin install logstash-output-log-courier + bin/logstash plugin install logstash-input-courier + bin/logstash plugin install logstash-output-courier Once the installation is complete, you can start using the plugins! diff --git a/lib/logstash/inputs/courier.rb b/lib/logstash/inputs/courier.rb index 0efc41c7..4b732501 100644 --- a/lib/logstash/inputs/courier.rb +++ b/lib/logstash/inputs/courier.rb @@ -22,7 +22,6 @@ module Inputs # Receive events over the Log Courier protocol class Courier < LogStash::Inputs::Base config_name 'courier' - milestone 1 default :codec, 'plain' diff --git a/lib/logstash/outputs/courier.rb b/lib/logstash/outputs/courier.rb index a87b1d2f..7de23155 100644 --- a/lib/logstash/outputs/courier.rb +++ b/lib/logstash/outputs/courier.rb @@ -22,7 +22,6 @@ module Outputs # Send events using the Log Courier protocol class Courier < LogStash::Outputs::Base config_name 'courier' - milestone 1 # The list of addresses Log Courier should send to config :hosts, :validate => :array, :required => true diff --git a/logstash-input-log-courier.gemspec.tmpl b/logstash-input-courier.gemspec.tmpl similarity index 93% rename from logstash-input-log-courier.gemspec.tmpl rename to logstash-input-courier.gemspec.tmpl index 520b5364..fe27b9ad 100644 --- a/logstash-input-log-courier.gemspec.tmpl +++ b/logstash-input-courier.gemspec.tmpl @@ -1,5 +1,5 @@ Gem::Specification.new do |gem| - gem.name = 'logstash-input-log-courier' + gem.name = 'logstash-input-courier' gem.version = '' gem.description = 'Log Courier Input Logstash Plugin' gem.summary = 'Receive events from Log Courier and Logstash using the Log Courier protocol' diff --git a/logstash-output-log-courier.gemspec.tmpl b/logstash-output-courier.gemspec.tmpl similarity index 91% rename from logstash-output-log-courier.gemspec.tmpl rename to logstash-output-courier.gemspec.tmpl index 7eb0630d..842bd785 100644 --- a/logstash-output-log-courier.gemspec.tmpl +++ b/logstash-output-courier.gemspec.tmpl @@ -1,5 +1,5 @@ Gem::Specification.new do |gem| - gem.name = 'logstash-output-log-courier' + gem.name = 'logstash-output-courier' gem.version = '' gem.description = 'Log Courier Output Logstash Plugin' gem.summary = 'Transmit events from one Logstash instance to another using the Log Courier protocol' @@ -13,7 +13,7 @@ Gem::Specification.new do |gem| lib/logstash/outputs/courier.rb ) - gem.metadata = { 'logstash_plugin' => 'true', 'logstash_group' => 'input' } + gem.metadata = { 'logstash_plugin' => 'true', 'logstash_group' => 'output' } gem.add_runtime_dependency 'logstash-core', '~> 1.4' gem.add_runtime_dependency 'log-courier', '= ' From 2ddb86c6411c3abbb5f06f2b7ccf8cf31b9ce0b7 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Wed, 20 May 2015 19:59:44 +0100 Subject: [PATCH 40/50] Plugins: Fix pre release versioning and push of the gems --- build/fix_version | 2 +- build/push_gems | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/fix_version b/build/fix_version index c443cc98..71c1b35f 100755 --- a/build/fix_version +++ b/build/fix_version @@ -11,7 +11,7 @@ elif [ ! -d '.git' ]; then else # Describe version from Git, and ensure the only "-xxx" is the git revision # This ensures that gem builds only add one ".pre" tag automatically - VERSION="$(git describe | sed 's/-\([0-9][0-9]*\)-\([0-9a-z][0-9a-z]*\)$/.\1.\2/g')" + VERSION="$(git describe | sed 's/-\([0-9][0-9]*\)-\([0-9a-z][0-9a-z]*\)$/-\1.\2/g')" VERSION="${VERSION#v}" VERSION_SHORT=$(git describe --abbrev=0) VERSION_SHORT="${VERSION_SHORT#v}" diff --git a/build/push_gems b/build/push_gems index 365aa577..2d468ee5 100755 --- a/build/push_gems +++ b/build/push_gems @@ -1,6 +1,6 @@ #!/bin/bash -for GEM in *-$(cat version_short.txt).gem; do +for GEM in *-$(cat version_short.txt)*.gem; do echo "- ${GEM}" gem push $GEM done From ab747726a8c0e5f26632524da03ba68b409a7d53 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Thu, 21 May 2015 09:19:11 +0100 Subject: [PATCH 41/50] Implement server shuffing Fixes #161 --- src/lc-lib/transports/address_pool.go | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/lc-lib/transports/address_pool.go b/src/lc-lib/transports/address_pool.go index 719a5467..bf544a2c 100644 --- a/src/lc-lib/transports/address_pool.go +++ b/src/lc-lib/transports/address_pool.go @@ -46,17 +46,20 @@ func NewAddressPool(servers []string) *AddressPool { servers: servers, } - // Randomise the initial host - after this it will round robin - // Round robin after initial attempt ensures we don't retry same host twice, - // and also ensures we try all hosts one by one - rnd := rand.Intn(len(servers)) - if rnd != 0 { - ret.servers = append(append(make([]string, 0), servers[rnd:]...), servers[:rnd]...) - } + ret.shuffleServers() return ret } +func (p *AddressPool) shuffleServers() { + var newList []string + oldList := p.servers + for _, v := range rand.Perm(len(oldList)) { + newList = append(newList, oldList[v]) + } + p.servers = newList +} + func (p *AddressPool) SetRfc2782(enabled bool, service string) { p.rfc2782 = enabled p.rfc2782Service = service @@ -119,8 +122,14 @@ func (p *AddressPool) Host() string { } func (p *AddressPool) populateAddresses() (error) { + // If we've iterated all servers, shuffle them again + if p.roundrobin >= len(p.servers) { + p.shuffleServers() + p.roundrobin = 0 + } + // Round robin to the next server - selected := p.servers[p.roundrobin%len(p.servers)] + selected := p.servers[p.roundrobin] p.roundrobin++ // @hostname means SRV record where the host and port are in the record From c3eac064457487877ff6a15cabe25d9a6c98835d Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Thu, 21 May 2015 09:29:08 +0100 Subject: [PATCH 42/50] Update change log for 1.7 --- docs/ChangeLog.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index 4d150587..66ae9cc3 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -4,6 +4,7 @@ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* +- [1.7](#17) - [1.6](#16) - [1.5](#15) - [1.3](#13) @@ -21,6 +22,52 @@ +## 1.7 + +*21st May 2015* + +***Important notice regarding the Logstash Plugins*** + +The Logstash plugin installation identifier has been changed from +"logstash-xxxxx-log-courier" to "logstash-xxxxx-courier" in order to meet the +specification set by the GA release of Logstash 1.5, which is for the identifier +to match the format "logstash--". The configuration name is +unchanged and remains "courier" - configurations do not need to be changed. + +If you are using Logstash 1.5 and would like to update the plugin you will need +to uninstall the previous plugin using the previous name before installing the +new version using the new name. + + ./bin/plugin uninstall logstash-input-log-courier + ./bin/plugin uninstall logstash-output-log-courier + ./bin/plugin install logstash-input-courier + ./bin/plugin install logstash-output-courier + +*Log Courier* + +* Report a configuration error if no servers are specified instead of continuing +and crashing during startup (#149) +* Report a configuration error if the configuration file is empty or contains +only whitespace instead of crashing during startup (#148) +* Report a configuration error when a files entry is specified without any paths +instead of continuing and ignoring it (#153) +* Implement server shuffling when multiple servers are specified to prevent +site-wide convergence of Log Courier instances towards a single server (#161) +* Fix pending payload limit being exceeded if a disconnect and reconnect occurs +* Fix a rare race condition in the tcp and tls transport that could cause Log +Courier to stop sending events after a connection failure +* Improve build process to work seamlessly with msysGit on Windows + +*Logstash Plugins* + +* Rename to logstash-input-courier and logstash-output-courier to meet the +latest plugin specified and fix the "This plugin isn't well supported" warnings +in Logstash 1.5 (#164) +* Remove deprecated milestone declaration to fix a Logstash 1.5 warning (#164) +* Fix a crash in the output plugin that can sometimes occur if a connection +fails (#143) +* Fix rare transport failures caused by payload identifiers ending in NUL bytes + ## 1.6 *22nd March 2015* From 403d9648252fc103871536942a8fb60db49e431c Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Thu, 21 May 2015 09:29:18 +0100 Subject: [PATCH 43/50] Update ToCs --- README.md | 7 +++++-- docs/LogstashIntegration.md | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dd6d153d..1f72a5d4 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,12 @@ with many fixes and behavioural improvements. - [Main Features](#main-features) - [Differences to Logstash Forwarder](#differences-to-logstash-forwarder) - [Public Repositories](#public-repositories) - - [RPM](#rpm) - - [DEB](#deb) + - [Redhat / CentOS](#redhat--centos) + - [Ubuntu](#ubuntu) - [Building from Source](#building-from-source) + - [Linux / Unix / OS X](#linux--unix--os-x) + - [Windows](#windows) + - [Results](#results) - [Logstash Integration](#logstash-integration) - [Generating Certificates](#generating-certificates) - [Documentation](#documentation) diff --git a/docs/LogstashIntegration.md b/docs/LogstashIntegration.md index 5c2ba432..ae10aa09 100644 --- a/docs/LogstashIntegration.md +++ b/docs/LogstashIntegration.md @@ -11,7 +11,7 @@ with each other using the same reliable and efficient protocol as Log Courier. **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* - [Installation](#installation) - - [Logstash 1.5 Plugin Manager](#logstash-15-plugin-manager) + - [Logstash Plugin Manager](#logstash-plugin-manager) - [Manual installation](#manual-installation) - [Local-only Installation](#local-only-installation) - [Configuration](#configuration) From 3ecae03724120289e2f11a0f72064f73718cbd76 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Thu, 21 May 2015 09:43:28 +0100 Subject: [PATCH 44/50] Update readme with goals and add at-least-one delivery goal Fixed #157 --- README.md | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1f72a5d4..3ca8cf58 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,8 @@ with many fixes and behavioural improvements. **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* -- [Main Features](#main-features) +- [Features](#features) +- [Philosophy](#philosophy) - [Differences to Logstash Forwarder](#differences-to-logstash-forwarder) - [Public Repositories](#public-repositories) - [Redhat / CentOS](#redhat--centos) @@ -28,26 +29,34 @@ with many fixes and behavioural improvements. -## Main Features +## Features -* Read events from a file or over a Unix pipeline +* [Logstash Integration](docs/LogstashIntegration.md) with an input and output +plugin +* Read events from a file or a Unix pipeline * Follow log file rotations and movements -* Close files after inactivity, reopening if they change +* Close files after inactivity, reopening on change, to keep resource usage low * Add [extra fields](docs/Configuration.md#fields) to events prior to shipping * [Reload configuration](docs/Configuration.md#reloading) without restarting -* Ship events securely using TLS with server (and optionally client) certificate -verification -* Ship events securely to multiple Logstash instances using ZeroMQ with Curve -security (requires ZeroMQ 4+) -* Ship events in plaintext using TCP -* Ship events in plaintext using ZeroMQ (requires ZeroMQ 3+) * Monitor shipping speed and status with the [Administration utility](docs/AdministrationUtility.md) * Pre-process events using codecs (e.g. [Multiline](docs/codecs/Multiline.md), [Filter](docs/codecs/Filter.md)) -* [Logstash Integration](docs/LogstashIntegration.md) with an input and output -plugin -* Very low resource usage +* Ship events securely using TLS with server (and optionally client) certificate +verification +* Ship events in plaintext using TCP + +## Philosophy + +* Aim to guarantee at-least-once delivery of events to the Logstash pipeline - a +Log Courier crash should never lose events [1] +* Be efficient and reliable +* Keep resource usage low + +[1] A *Logstash* crash or output failure will still lose some events until +Logstash itself implements delivery guarantees or persistence - see +elastic/logstash#2609 and elastic/logstash#2605. Log Courier aims to provide +complete compatibility with theses features as they develop. ## Differences to Logstash Forwarder From bda78e6f9a64211469f44404d813b5b904d598ca Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Thu, 21 May 2015 09:50:45 +0100 Subject: [PATCH 45/50] Fix goals section formatting and links --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3ca8cf58..48dbb9c3 100644 --- a/README.md +++ b/README.md @@ -49,14 +49,16 @@ verification ## Philosophy * Aim to guarantee at-least-once delivery of events to the Logstash pipeline - a -Log Courier crash should never lose events [1] +Log Courier crash should never lose events *[1]* * Be efficient and reliable * Keep resource usage low -[1] A *Logstash* crash or output failure will still lose some events until +*[1] A __Logstash__ crash or output failure will still lose some events until Logstash itself implements delivery guarantees or persistence - see -elastic/logstash#2609 and elastic/logstash#2605. Log Courier aims to provide -complete compatibility with theses features as they develop. +[elastic/logstash#2609](https://github.com/elastic/logstash/issues/2609) and +[elastic/logstash#2605](https://github.com/elastic/logstash/issues/2605). Log +Courier aims to provide complete compatibility with theses features as they +develop.* ## Differences to Logstash Forwarder From e588d98d86b70a16f6e250989fde637ce28e2352 Mon Sep 17 00:00:00 2001 From: Luar Roji Date: Fri, 29 May 2015 16:56:31 +0300 Subject: [PATCH 46/50] Fixed typo --- docs/LogstashIntegration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/LogstashIntegration.md b/docs/LogstashIntegration.md index ae10aa09..8ae60960 100644 --- a/docs/LogstashIntegration.md +++ b/docs/LogstashIntegration.md @@ -120,7 +120,7 @@ be used at the moment) * ssl_key_passphrase - Password for ssl_key (optional) * spool_size - Maximum number of events to spool before a flush is forced (default 1024) -* idle_timeout - Maxmimum time in seconds to wait for a full spool before +* idle_timeout - Maximum time in seconds to wait for a full spool before flushing anyway (default 5) NOTE: The tcp, plainzmq and zmq transports are not implemented in the output From e251405f7b820d8d986f32fd5c94b312452c9895 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Wed, 3 Jun 2015 17:35:46 +0100 Subject: [PATCH 47/50] Workaround a Windows patch in Logstash <= 1.5.0 (elastic/logstash#3364) Fixes #169 --- lib/log-courier/server_tcp.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/log-courier/server_tcp.rb b/lib/log-courier/server_tcp.rb index e17a80b1..44f55561 100644 --- a/lib/log-courier/server_tcp.rb +++ b/lib/log-courier/server_tcp.rb @@ -34,7 +34,13 @@ def initialise # Save the peer def accept sock = super - peer = sock.peeraddr(:numeric) + # Prevent reverse lookup by passing false + begin + peer = sock.peeraddr(false) + rescue ArgumentError + # Logstash <= 1.5.0 has a patch that blocks parameters (elastic/logstash#3364) + peer = sock.peeraddr + end @peer = "#{peer[2]}:#{peer[1]}" return sock end From 5f612fcb1e57ebf877bff3dd67755fffdc36ef04 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Wed, 3 Jun 2015 17:37:07 +0100 Subject: [PATCH 48/50] Fix adding data to @logger as it adds it for all plugins and even Logstash core Fixes misleading message reported in #176 --- lib/log-courier/client.rb | 1 - lib/log-courier/server.rb | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib/log-courier/client.rb b/lib/log-courier/client.rb index 58598570..10649216 100644 --- a/lib/log-courier/client.rb +++ b/lib/log-courier/client.rb @@ -103,7 +103,6 @@ def initialize(options = {}) }.merge!(options) @logger = @options[:logger] - @logger['plugin'] = 'output/courier' unless @logger.nil? case @options[:transport] when 'tcp', 'tls' diff --git a/lib/log-courier/server.rb b/lib/log-courier/server.rb index f6adb589..c24c9cae 100644 --- a/lib/log-courier/server.rb +++ b/lib/log-courier/server.rb @@ -40,7 +40,6 @@ def initialize(options = {}) }.merge!(options) @logger = @options[:logger] - @logger['plugin'] = 'input/courier' unless @logger.nil? case @options[:transport] when 'tcp', 'tls' @@ -55,7 +54,6 @@ def initialize(options = {}) # Grab the port back and update the logger context @port = @server.port - @logger['port'] = @port unless @logger.nil? # Load the json adapter @json_adapter = MultiJson.adapter.instance From 180997fb302bd9ec354116e3e2734aed7d0ece1c Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Wed, 3 Jun 2015 17:38:07 +0100 Subject: [PATCH 49/50] Release version 1.7 --- version_short.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version_short.txt b/version_short.txt index 810ee4e9..d3bdbdf1 100644 --- a/version_short.txt +++ b/version_short.txt @@ -1 +1 @@ -1.6 +1.7 From 2790137ccdda822e70f1e3e384dbfc2b811cb416 Mon Sep 17 00:00:00 2001 From: Jason Woods Date: Wed, 3 Jun 2015 17:45:05 +0100 Subject: [PATCH 50/50] Update Change log for 1.7 --- docs/ChangeLog.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index 66ae9cc3..b7089b59 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -24,7 +24,7 @@ ## 1.7 -*21st May 2015* +*3rd June 2015* ***Important notice regarding the Logstash Plugins*** @@ -66,6 +66,10 @@ in Logstash 1.5 (#164) * Remove deprecated milestone declaration to fix a Logstash 1.5 warning (#164) * Fix a crash in the output plugin that can sometimes occur if a connection fails (#143) +* Fix a crash on Windows caused by a Logstash patch to Ruby stdlib +(elastic/logstash#3364) (#169) +* Fix confusing log messages that appear to come from Log Courier plugin but +in fact come from another plugin or Logstash itself (#176) * Fix rare transport failures caused by payload identifiers ending in NUL bytes ## 1.6