mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
First pass at cleaning out logstash web
All internal references, flags, kibana, vendor, everything must go! If it referenced kibana or logstash-web, it is deprecated, and removed! Operators are standing by... Fixes #2661
This commit is contained in:
parent
1699ba8324
commit
945e184e67
17 changed files with 22 additions and 789 deletions
12
README.md
12
README.md
|
@ -1,9 +1,7 @@
|
|||
# Logstash [](https://codeclimate.com/github/elasticsearch/logstash) [](https://coveralls.io/r/elasticsearch/logstash?branch=origin%2Fmaster)
|
||||
|
||||
Logstash is a tool for managing events and logs. You can use it to collect
|
||||
logs, parse them, and store them for later use (like, for searching). Speaking
|
||||
of searching, Logstash comes with a web interface for searching and drilling
|
||||
into all of your logs.
|
||||
logs, parse them, and store them for later use (like, for searching).
|
||||
|
||||
It is fully free and fully open source. The license is Apache 2.0, meaning you
|
||||
are pretty much free to use it however you want in whatever way.
|
||||
|
@ -16,7 +14,7 @@ For more info, see <http://logstash.net/>
|
|||
Since version **1.5.0 beta1 (and current master)** of Logstash, *all* plugins have been separated into their own
|
||||
repositories under the [logstash-plugins](https://github.com/logstash-plugins) github organization. Each plugin is now a self-contained Ruby gem which
|
||||
gets published to RubyGems.org. Logstash has added plugin infrastructure to easily maintain the lifecyle of the plugin.
|
||||
For more details and rationale behind these changes, see our [blogpost](http://www.elasticsearch.org/blog/plugin-ecosystem-changes/).
|
||||
For more details and rationale behind these changes, see our [blogpost](http://www.elasticsearch.org/blog/plugin-ecosystem-changes/).
|
||||
|
||||
[Elasticsearch logstash-contrib repo](https://github.com/elasticsearch/logstash-contrib) is deprecated. We
|
||||
have moved all of the plugins that existed there into their own repositories. We are migrating all of the pull requests
|
||||
|
@ -27,7 +25,7 @@ For more info on developing and testing these plugins, please see the [README](h
|
|||
### Plugin Issues and Pull Requests
|
||||
|
||||
We are migrating all of the existing pull requests to their respective repositories. Rest assured, we will maintain
|
||||
all of the git history for these requests.
|
||||
all of the git history for these requests.
|
||||
|
||||
**Please open new issues and pull requests for plugins under its own repository**
|
||||
|
||||
|
@ -49,7 +47,7 @@ To get started, you'll need ruby version 1.9.x or above and it should come with
|
|||
Here's how to get started with Logstash development:
|
||||
|
||||
rake bootstrap
|
||||
|
||||
|
||||
Other commands:
|
||||
|
||||
# to use Logstash gems or libraries in irb, use the following
|
||||
|
@ -65,7 +63,7 @@ own ruby you must set `USE_RUBY=1` in your environment.
|
|||
|
||||
## Drip Launcher
|
||||
|
||||
[Drip](https://github.com/ninjudd/drip) is a launcher for the Java Virtual Machine that provides much faster startup times than the `java` command. The drip script is intended to be a drop-in replacement for the java command, only faster. We recommend using drip during development.
|
||||
[Drip](https://github.com/ninjudd/drip) is a launcher for the Java Virtual Machine that provides much faster startup times than the `java` command. The drip script is intended to be a drop-in replacement for the java command, only faster. We recommend using drip during development.
|
||||
|
||||
To tell Logstash to use drip, either set the `USE_DRIP=1` environment variable or set `` JAVACMD=`which drip` ``.
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
basedir=$(cd `dirname $0`/..; pwd)
|
||||
exec $basedir/bin/logstash web "$@"
|
|
@ -19,32 +19,19 @@ The Logstash agent has the following flags. (You can use the '--help' flag to di
|
|||
--watchdog-timeout TIMEOUT
|
||||
Set watchdog timeout value in seconds. Default is 10.
|
||||
|
||||
-l, --log FILE
|
||||
Log to a given path. Default is to log to stdout
|
||||
-l, --log FILE
|
||||
Log to a given path. Default is to log to stdout
|
||||
|
||||
--verbose
|
||||
--verbose
|
||||
Increase verbosity to the first level, less verbose.
|
||||
|
||||
--debug
|
||||
--debug
|
||||
Increase verbosity to the last level, more verbose.
|
||||
|
||||
-v
|
||||
-v
|
||||
*DEPRECATED: see --verbose/debug* Increase verbosity. There are multiple levels of verbosity available with
|
||||
'-vv' currently being the highest
|
||||
'-vv' currently being the highest
|
||||
|
||||
--pluginpath PLUGIN_PATH
|
||||
A colon-delimited path to find other Logstash plugins in
|
||||
--pluginpath PLUGIN_PATH
|
||||
A colon-delimited path to find other Logstash plugins in
|
||||
----------------------------------
|
||||
|
||||
[float]
|
||||
=== Web
|
||||
|
||||
[source,js]
|
||||
----------------------------------
|
||||
-a, --address ADDRESS
|
||||
Address on which to start webserver. Default is 0.0.0.0.
|
||||
|
||||
-p, --port PORT
|
||||
Port on which to start webserver. Default is 9292.
|
||||
----------------------------------
|
||||
|
||||
|
|
|
@ -56,31 +56,6 @@ a search for `*` (all):
|
|||
|
||||
curl 'http://localhost:9200/_search?pretty=1&q=*'
|
||||
|
||||
## Step 4 - Logstash web
|
||||
|
||||
The previous step is good, but a better frontend on elasticsearch would help!
|
||||
|
||||
The same config as step 3 is used.
|
||||
|
||||
### Run it:
|
||||
|
||||
bin/logstash agent -f hello-search.conf web
|
||||
|
||||
The above runs both the agent and the Logstash web interface in the same
|
||||
process. Useful for simple deploys.
|
||||
|
||||
### Use it:
|
||||
|
||||
Go to the Logstash web interface in browser: <http://localhost:9292/>
|
||||
|
||||
Type stuff on `STDIN` on the agent, then search for it in the web interface.
|
||||
|
||||
## Step 5 - real world example
|
||||
|
||||
Let's backfill some old Apache logs. First, let's use grok.
|
||||
|
||||
Use the ['grok'](../../filters/grok) Logstash filter to parse logs.
|
||||
|
||||
### Download
|
||||
|
||||
* [apache-parse.conf](apache-parse.conf)
|
||||
|
@ -107,18 +82,13 @@ Same as the previous step, but we'll output to ElasticSearch now.
|
|||
|
||||
### Run it
|
||||
|
||||
bin/logstash agent -f apache-elasticsearch.conf web
|
||||
bin/logstash agent -f apache-elasticsearch.conf
|
||||
|
||||
Logstash should be all set for you now. Start feeding it logs:
|
||||
|
||||
bzip2 -d apache_log.2.bz2
|
||||
|
||||
nc localhost 3333 < apache_log.2
|
||||
|
||||
Go to the Logstash web interface in browser: <http://localhost:9292/>
|
||||
|
||||
Try some search queries. To see all the data, search for `*` (no quotes). Click
|
||||
on some results, drill around in some logs.
|
||||
nc localhost 3333 < apache_log.2
|
||||
|
||||
## Want more?
|
||||
|
||||
|
@ -126,6 +96,6 @@ For further learning, try these:
|
|||
|
||||
* [Watch a presentation on logstash](http://www.youtube.com/embed/RuUFnog29M4)
|
||||
* [Getting started 'standalone' guide](http://logstash.net/docs/%VERSION%/tutorials/getting-started-simple)
|
||||
* [Getting started 'centralized' guide](http://logstash.net/docs/%VERSION%/tutorials/getting-started-centralized) -
|
||||
* [Getting started 'centralized' guide](http://logstash.net/docs/%VERSION%/tutorials/getting-started-centralized) -
|
||||
learn how to build out your logstash infrastructure and centralize your logs.
|
||||
* [Dive into the docs](http://logstash.net/docs/%VERSION%/)
|
||||
|
|
|
@ -22,7 +22,6 @@ require "rspec/core/runner"
|
|||
require "logstash/namespace"
|
||||
require "logstash/program"
|
||||
require "logstash/agent"
|
||||
require "logstash/kibana"
|
||||
require "logstash/util"
|
||||
require "logstash/errors"
|
||||
require "logstash/pipeline"
|
||||
|
|
|
@ -16,11 +16,11 @@ class LogStash::Inputs::Base < LogStash::Plugin
|
|||
# Types are used mainly for filter activation.
|
||||
#
|
||||
# The type is stored as part of the event itself, so you can
|
||||
# also use the type to search for it in the web interface.
|
||||
# also use the type to search for it in Kibana.
|
||||
#
|
||||
# If you try to set a type on an event that already has one (for
|
||||
# example when you send an event from a shipper to an indexer) then
|
||||
# a new input will not override the existing type. A type set at
|
||||
# a new input will not override the existing type. A type set at
|
||||
# the shipper stays with that event for its life even
|
||||
# when sent to another Logstash server.
|
||||
config :type, :validate => :string
|
||||
|
@ -100,7 +100,7 @@ class LogStash::Inputs::Base < LogStash::Plugin
|
|||
end # def tag
|
||||
|
||||
protected
|
||||
def to_event(raw, source)
|
||||
def to_event(raw, source)
|
||||
raise LogStash::ThisMethodWasRemoved("LogStash::Inputs::Base#to_event - you should use codecs now instead of to_event. Not sure what this means? Get help on logstash-users@googlegroups.com!")
|
||||
end # def to_event
|
||||
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
# encoding: utf-8
|
||||
require "rack/handler/ftw" # gem ftw
|
||||
require "ftw" # gem ftw
|
||||
require "sinatra/base" # gem sinatra
|
||||
require "optparse"
|
||||
require "mime/types"
|
||||
|
||||
class Rack::Handler::FTW
|
||||
alias_method :handle_connection_, :handle_connection
|
||||
def handle_connection(connection)
|
||||
#require "pry"; binding.pry
|
||||
return handle_connection_(connection)
|
||||
end
|
||||
end
|
||||
|
||||
module LogStash::Kibana
|
||||
class App < Sinatra::Base
|
||||
set :logging, true
|
||||
|
||||
use Rack::CommonLogger
|
||||
use Rack::ShowExceptions
|
||||
|
||||
get "/" do
|
||||
redirect "index.html"
|
||||
end
|
||||
|
||||
# Sinatra has problems serving static files from
|
||||
# jar files, so let's hack this by hand.
|
||||
#set :public, "#{File.dirname(__FILE__)}/public"
|
||||
get "/config.js" do static_file end
|
||||
get "/index.html" do static_file end
|
||||
get "/app/*" do static_file end
|
||||
get "/css/*" do static_file end
|
||||
get "/font/*" do static_file end
|
||||
get "/img/*" do static_file end
|
||||
get "/vendor/*" do static_file end
|
||||
|
||||
def static_file
|
||||
# request.path_info is the full path of the request.
|
||||
docroot = File.expand_path(File.join(File.dirname(__FILE__), "../../vendor/kibana"))
|
||||
path = File.join(docroot, *request.path_info.split("/"))
|
||||
if File.exists?(path)
|
||||
ext = path.split(".").last
|
||||
content_type MIME::Types.type_for(ext).first.to_s
|
||||
body File.new(path, "rb").read
|
||||
else
|
||||
status 404
|
||||
content_type "text/plain"
|
||||
body "File not found: #{path}"
|
||||
end
|
||||
end # def static_file
|
||||
end # class App
|
||||
|
||||
class Runner
|
||||
Settings = Struct.new(:logfile, :address, :port, :backend)
|
||||
|
||||
public
|
||||
def run(args)
|
||||
settings = Settings.new
|
||||
settings.address = "0.0.0.0"
|
||||
settings.port = 9292
|
||||
settings.backend = "localhost"
|
||||
|
||||
progname = File.basename($0)
|
||||
|
||||
opts = OptionParser.new do |opts|
|
||||
opts.banner = "Usage: #{progname} [options]"
|
||||
opts.on("-a", "--address ADDRESS", "Address on which to start webserver. Default is 0.0.0.0.") do |address|
|
||||
settings.address = address
|
||||
end
|
||||
|
||||
opts.on("-p", "--port PORT", "Port on which to start webserver. Default is 9292.") do |port|
|
||||
settings.port = port.to_i
|
||||
end
|
||||
|
||||
#opts.on("-b", "--backend host",
|
||||
#"The backend host to use. Default is 'localhost'") do |host|
|
||||
#settings.backend = host
|
||||
#end
|
||||
end
|
||||
|
||||
begin
|
||||
args = opts.parse(args)
|
||||
rescue SystemExit
|
||||
# if you ask for --help, optparse will exit.
|
||||
# capture it and return normally
|
||||
return []
|
||||
end
|
||||
|
||||
@thread = Thread.new do
|
||||
Cabin::Channel.get.info("Starting web server", :settings => settings)
|
||||
ftw = Rack::Handler::FTW.new(LogStash::Kibana::App.new,
|
||||
:Host => settings.address,
|
||||
:Port => settings.port)
|
||||
trap_id = Stud::trap("INT") do
|
||||
puts "Stopping web..."
|
||||
ftw.stop rescue nil
|
||||
raise SystemExit
|
||||
end
|
||||
|
||||
ftw.run
|
||||
end
|
||||
|
||||
return args
|
||||
end # def run
|
||||
|
||||
public
|
||||
def wait
|
||||
@thread.join if @thread
|
||||
return 0
|
||||
end # def wait
|
||||
end
|
||||
end
|
|
@ -97,12 +97,6 @@ class LogStash::Runner
|
|||
end
|
||||
return LogStash::Agent.run($0, agent_args)
|
||||
end,
|
||||
"web" => lambda do
|
||||
# Give them kibana.
|
||||
require "logstash/kibana"
|
||||
kibana = LogStash::Kibana::Runner.new
|
||||
return kibana.run(args)
|
||||
end,
|
||||
"rspec" => lambda do
|
||||
require "rspec/core/runner"
|
||||
require "rspec"
|
||||
|
@ -186,7 +180,6 @@ For example: logstash agent --help
|
|||
Available commands:
|
||||
agent - runs the logstash agent
|
||||
version - emits version info about this logstash
|
||||
web - runs the logstash web ui (called Kibana)
|
||||
rspec - runs tests
|
||||
]
|
||||
#$stderr.puts commands.keys.map { |s| " #{s}" }.join("\n")
|
||||
|
|
12
pkg/build.sh
12
pkg/build.sh
|
@ -13,7 +13,7 @@ DESCRIPTION="An extensible logging pipeline"
|
|||
|
||||
if [ "$#" -ne 2 ] ; then
|
||||
echo "Usage: $0 <os> <release>"
|
||||
echo
|
||||
echo
|
||||
echo "Example: $0 ubuntu 12.10"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -55,8 +55,6 @@ case $os@$release in
|
|||
install -m644 logrotate.conf $destdir/etc/logrotate.d/logstash
|
||||
install -m644 logstash.default $destdir/etc/sysconfig/logstash
|
||||
install -m755 logstash.sysv $destdir/etc/init.d/logstash
|
||||
install -m644 logstash-web.default $destdir/etc/sysconfig/logstash
|
||||
install -m755 logstash-web.sysv $destdir/etc/init.d/logstash-web
|
||||
;;
|
||||
ubuntu@*|debian@*)
|
||||
mkdir -p $destdir/etc/logstash/conf.d
|
||||
|
@ -71,11 +69,8 @@ case $os@$release in
|
|||
install -m644 logstash.default $destdir/etc/default/logstash
|
||||
install -m755 logstash.upstart.ubuntu $destdir/etc/init/logstash.conf
|
||||
install -m755 logstash.sysv $destdir/etc/init.d/logstash
|
||||
install -m644 logstash-web.default $destdir/etc/default/logstash-web
|
||||
install -m755 logstash-web.upstart.ubuntu $destdir/etc/init/logstash-web.conf
|
||||
install -m755 logstash-web.sysv $destdir/etc/init.d/logstash-web
|
||||
;;
|
||||
*)
|
||||
*)
|
||||
echo "Unknown OS: $os $release"
|
||||
exit 1
|
||||
;;
|
||||
|
@ -83,7 +78,7 @@ esac
|
|||
|
||||
description="logstash is a system for managing and processing events and logs"
|
||||
case $os in
|
||||
centos|fedora|redhat|sl)
|
||||
centos|fedora|redhat|sl)
|
||||
fpm -s dir -t rpm -n logstash -v "$RELEASE" \
|
||||
-a noarch --iteration "1_${RPM_REVISION}" \
|
||||
--url "$URL" \
|
||||
|
@ -120,7 +115,6 @@ case $os in
|
|||
--before-remove $os/before-remove.sh \
|
||||
--after-install $os/after-install.sh \
|
||||
--config-files /etc/default/logstash \
|
||||
--config-files /etc/default/logstash-web \
|
||||
--config-files /etc/logrotate.d/logstash \
|
||||
-f -C $destdir .
|
||||
;;
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
###############################
|
||||
# Default settings for logstash
|
||||
###############################
|
||||
|
||||
# Override Java location
|
||||
#JAVACMD=/usr/bin/java
|
||||
|
||||
# Set a home directory
|
||||
#LS_HOME=/var/lib/logstash
|
||||
|
||||
# Arguments to pass to java
|
||||
#LS_HEAP_SIZE="256m"
|
||||
#LS_JAVA_OPTS="-Djava.io.tmpdir=$HOME"
|
||||
|
||||
# Logstash filter worker threads
|
||||
#LS_WORKER_THREADS=1
|
||||
|
||||
# pidfiles aren't used for upstart; this is for sysv users.
|
||||
#LS_PIDFILE=/var/run/logstash.pid
|
||||
|
||||
# user id to be invoked as; for upstart: edit /etc/init/logstash.conf
|
||||
#LS_USER=logstash
|
||||
|
||||
# logstash logging
|
||||
#LS_LOG_FILE=/var/log/logstash/logstash-web.log
|
||||
#LS_USE_GC_LOGGING="true"
|
||||
|
||||
# logstash configuration directory
|
||||
#LS_CONF_DIR=/etc/logstash/conf.d
|
||||
|
||||
# Open file limit; cannot be overridden in upstart
|
||||
#LS_OPEN_FILES=2048
|
||||
|
||||
# Nice level
|
||||
#LS_NICE=0
|
|
@ -1,149 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Init script for logstash Webserver
|
||||
# Maintained by Elasticsearch
|
||||
# Generated by pleaserun.
|
||||
# Implemented based on LSB Core 3.1:
|
||||
# * Sections: 20.2, 20.3
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: logstash-web
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description:
|
||||
# Description: Starts Logstash webserveras a daemon.
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
export PATH
|
||||
|
||||
if [ `id -u` -ne 0 ]; then
|
||||
echo "You need root privileges to run this script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
name=logstash-web
|
||||
pidfile="/var/run/$name.pid"
|
||||
|
||||
LS_USER=logstash
|
||||
LS_GROUP=logstash
|
||||
LS_HOME=/var/lib/logstash
|
||||
LS_HEAP_SIZE="500m"
|
||||
LS_JAVA_OPTS="-Djava.io.tmpdir=${LS_HOME}"
|
||||
LS_LOG_FILE=/var/log/logstash/$name.log
|
||||
LS_CONF_DIR=/etc/logstash/conf.d
|
||||
LS_OPEN_FILES=16384
|
||||
LS_NICE=19
|
||||
LS_OPTS=""
|
||||
LS_WEB_ADDRESS="0.0.0.0"
|
||||
LS_WEB_PORT=9292
|
||||
|
||||
[ -r /etc/default/$name ] && . /etc/default/$name
|
||||
[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name
|
||||
|
||||
program=/opt/logstash/bin/logstash
|
||||
args="web -a ${LS_WEB_ADDRESS} -p ${LS_WEB_PORT}"
|
||||
|
||||
start() {
|
||||
|
||||
|
||||
JAVA_OPTS=${LS_JAVA_OPTS}
|
||||
export PATH HOME JAVA_OPTS LS_HEAP_SIZE LS_JAVA_OPTS LS_USE_GC_LOGGING
|
||||
# Run the program!
|
||||
chroot --userspec $LS_USER:$LS_GROUP / sh -c "
|
||||
cd $LS_HOME
|
||||
nice ${LS_NICE}
|
||||
ulimit -n ${LS_OPEN_FILES}
|
||||
exec \"$program\" $args
|
||||
" > /var/log/logstash/$name.stdout 2> /var/log/logstash/$name.err &
|
||||
|
||||
# Generate the pidfile from here. If we instead made the forked process
|
||||
# generate it there will be a race condition between the pidfile writing
|
||||
# and a process possibly asking for status.
|
||||
echo $! > $pidfile
|
||||
|
||||
echo "$name started."
|
||||
return 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
# Try a few times to kill TERM the program
|
||||
if status ; then
|
||||
pid=`cat "$pidfile"`
|
||||
echo "Killing $name (pid $pid) with SIGTERM"
|
||||
kill -TERM $pid
|
||||
# Wait for it to exit.
|
||||
for i in 1 2 3 4 5 ; do
|
||||
echo "Waiting $name (pid $pid) to die..."
|
||||
status || break
|
||||
sleep 1
|
||||
done
|
||||
if status ; then
|
||||
echo "$name stop failed; still running."
|
||||
else
|
||||
echo "$name stopped."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
status() {
|
||||
if [ -f "$pidfile" ] ; then
|
||||
pid=`cat "$pidfile"`
|
||||
if kill -0 $pid > /dev/null 2> /dev/null ; then
|
||||
# process by this pid is running.
|
||||
# It may not be our pid, but that's what you get with just pidfiles.
|
||||
# TODO(sissel): Check if this process seems to be the same as the one we
|
||||
# expect. It'd be nice to use flock here, but flock uses fork, not exec,
|
||||
# so it makes it quite awkward to use in this case.
|
||||
return 0
|
||||
else
|
||||
return 2 # program is dead but pid file exists
|
||||
fi
|
||||
else
|
||||
return 3 # program is not running
|
||||
fi
|
||||
}
|
||||
|
||||
force_stop() {
|
||||
if status ; then
|
||||
stop
|
||||
status && kill -KILL `cat "$pidfile"`
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
status
|
||||
code=$?
|
||||
if [ $code -eq 0 ]; then
|
||||
echo "$name is already running"
|
||||
else
|
||||
start
|
||||
fi
|
||||
exit $code
|
||||
;;
|
||||
stop) stop ;;
|
||||
force-stop) force_stop ;;
|
||||
status)
|
||||
status
|
||||
code=$?
|
||||
if [ $code -eq 0 ] ; then
|
||||
echo "$name is running"
|
||||
else
|
||||
echo "$name is not running"
|
||||
fi
|
||||
exit $code
|
||||
;;
|
||||
restart)
|
||||
|
||||
stop && start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|force-stop|status|restart}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $?
|
|
@ -1,183 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# /etc/init.d/logstash-web -- startup script for LogStash web server.
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: logstash-web
|
||||
# Required-Start: $all
|
||||
# Required-Stop: $all
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Starts logstash-web
|
||||
# Description: Starts logstash web server using start-stop-daemon
|
||||
### END INIT INFO
|
||||
|
||||
set -e
|
||||
|
||||
NAME=logstash-web
|
||||
DESC="Logstash Web Server"
|
||||
DEFAULT=/etc/default/$NAME
|
||||
|
||||
if [ `id -u` -ne 0 ]; then
|
||||
echo "You need root privileges to run this script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
if [ -r /etc/default/rcS ]; then
|
||||
. /etc/default/rcS
|
||||
fi
|
||||
|
||||
# The following variables can be overwritten in $DEFAULT
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||
|
||||
# See contents of file named in $DEFAULT for comments
|
||||
LS_USER=logstash
|
||||
LS_GROUP=logstash
|
||||
LS_HOME=/var/lib/logstash
|
||||
LS_HEAP_SIZE="500m"
|
||||
LS_JAVA_OPTS="-Djava.io.tmpdir=${LS_HOME}"
|
||||
LS_LOG_FILE=""
|
||||
LS_CONF_DIR=/etc/logstash/conf.d
|
||||
LS_OPEN_FILES=2048
|
||||
LS_NICE=19
|
||||
LS_OPTS=""
|
||||
LS_PIDFILE=/var/run/$NAME.pid
|
||||
|
||||
# End of variables that can be overwritten in $DEFAULT
|
||||
|
||||
# overwrite settings from default file
|
||||
if [ -f "$DEFAULT" ]; then
|
||||
. "$DEFAULT"
|
||||
fi
|
||||
|
||||
# Define other required variables
|
||||
[ -n "${LS_LOG_FILE}" ] && LS_OPTS="${LSOPTS} -l ${LS_LOG_FILE}"
|
||||
PID_FILE=${LS_PIDFILE}
|
||||
DAEMON=/opt/logstash/bin/logstash
|
||||
DAEMON_OPTS="web ${LS_OPTS}"
|
||||
|
||||
# Check DAEMON exists
|
||||
if ! test -e $DAEMON; then
|
||||
log_failure_msg "Script $DAEMON doesn't exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if [ -z "$DAEMON" ]; then
|
||||
log_failure_msg "no logstash script found - $DAEMON"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if a config file exists
|
||||
if [ ! "$(ls -A $LS_CONF_DIR/*.conf 2> /dev/null)" ]; then
|
||||
log_failure_msg "There aren't any configuration files in $LS_CONF_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_daemon_msg "Starting $DESC"
|
||||
|
||||
# Parse the actual JAVACMD from the process' environment, we don't care about errors.
|
||||
JAVA=$(cat /proc/$(cat ${PID_FILE} 2>/dev/null)/environ 2>/dev/null | awk -F= 'BEGIN {RS="\0"} /JAVACMD/ {print $2}')
|
||||
if start-stop-daemon --test --start --pidfile "$PID_FILE" \
|
||||
--user "$LS_USER" --exec "$JAVA" \
|
||||
>/dev/null; then
|
||||
# Prepare environment
|
||||
HOME="${HOME:-$LS_HOME}"
|
||||
JAVA_OPTS="${LS_JAVA_OPTS}"
|
||||
ulimit -n ${LS_OPEN_FILES}
|
||||
cd "${LS_HOME}"
|
||||
export PATH HOME JAVACMD JAVA_OPTS LS_HEAP_SIZE LS_JAVA_OPTS LS_USE_GC_LOGGING
|
||||
|
||||
# Start Daemon
|
||||
start-stop-daemon --start -b --user "$LS_USER" -c "$LS_USER":"$LS_GROUP" \
|
||||
-d "$LS_HOME" --nicelevel "$LS_NICE" --pidfile "$PID_FILE" --make-pidfile \
|
||||
--exec $DAEMON -- $DAEMON_OPTS
|
||||
|
||||
sleep 1
|
||||
|
||||
# Parse the actual JAVACMD from the process' environment, we don't care about errors.
|
||||
JAVA=$(cat /proc/$(cat ${PID_FILE} 2>/dev/null)/environ 2>/dev/null | awk -F= 'BEGIN {RS="\0"} /JAVACMD/ {print $2}')
|
||||
if start-stop-daemon --test --start --pidfile "$PID_FILE" \
|
||||
--user "$LS_USER" --exec "$JAVA" \
|
||||
>/dev/null; then
|
||||
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
rm -f "$PID_FILE"
|
||||
fi
|
||||
|
||||
log_end_msg 1
|
||||
else
|
||||
log_end_msg 0
|
||||
fi
|
||||
else
|
||||
log_progress_msg "(already running)"
|
||||
log_end_msg 0
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
log_daemon_msg "Stopping $DESC"
|
||||
|
||||
set +e
|
||||
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
start-stop-daemon --stop --pidfile "$PID_FILE" \
|
||||
--user "$LS_USER" \
|
||||
--retry=TERM/20/KILL/5 >/dev/null
|
||||
|
||||
if [ $? -eq 1 ]; then
|
||||
log_progress_msg "$DESC is not running but pid file exists, cleaning up"
|
||||
elif [ $? -eq 3 ]; then
|
||||
PID="`cat $PID_FILE`"
|
||||
log_failure_msg "Failed to stop $DESC (pid $PID)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f "$PID_FILE"
|
||||
else
|
||||
log_progress_msg "(not running)"
|
||||
fi
|
||||
|
||||
log_end_msg 0
|
||||
set -e
|
||||
;;
|
||||
status)
|
||||
set +e
|
||||
|
||||
# Parse the actual JAVACMD from the process' environment, we don't care about errors.
|
||||
JAVA=$(cat /proc/$(cat ${PID_FILE} 2>/dev/null)/environ 2>/dev/null | awk -F= 'BEGIN {RS="\0"} /JAVACMD/ {print $2}')
|
||||
start-stop-daemon --test --start --pidfile "$PID_FILE" \
|
||||
--user "$LS_USER" --exec "$JAVA" \
|
||||
>/dev/null 2>&1
|
||||
|
||||
if [ "$?" = "0" ]; then
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
log_success_msg "$DESC is not running, but pid file exists."
|
||||
exit 1
|
||||
else
|
||||
log_success_msg "$DESC is not running."
|
||||
exit 3
|
||||
fi
|
||||
else
|
||||
log_success_msg "$DESC is running with pid `cat $PID_FILE`"
|
||||
fi
|
||||
|
||||
set -e
|
||||
;;
|
||||
restart|force-reload)
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
$0 stop
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
$0 start
|
||||
;;
|
||||
*)
|
||||
log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
|
@ -1,134 +0,0 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# /etc/rc.d/init.d/logstash-web
|
||||
#
|
||||
# Starts Logstash Web Server as a daemon
|
||||
#
|
||||
# chkconfig: 2345 90 10
|
||||
# description: Starts Logstash Web Server as a daemon.
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: logstash-web
|
||||
# Required-Start: $local_fs $remote_fs
|
||||
# Required-Stop: $local_fs $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: S 0 1 6
|
||||
# Short-Description: Logstash-Web
|
||||
# Description: Starts Logstash Web Server as a daemon.
|
||||
### END INIT INFO
|
||||
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
NAME=logstash-web
|
||||
DESC="Logstash Web Daemon"
|
||||
DEFAULT=/etc/sysconfig/$NAME
|
||||
|
||||
if [ `id -u` -ne 0 ]; then
|
||||
echo "You need root privileges to run this script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The following variables can be overwritten in $DEFAULT
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||
|
||||
# See contents of file named in $DEFAULT for comments
|
||||
LS_USER=logstash
|
||||
LS_GROUP=logstash
|
||||
LS_HOME=/var/lib/logstash
|
||||
LS_HEAP_SIZE="500m"
|
||||
LS_JAVA_OPTS="-Djava.io.tmpdir=${LS_HOME}"
|
||||
LS_LOG_FILE=
|
||||
LS_CONF_DIR=/etc/logstash/conf.d
|
||||
LS_OPEN_FILES=2048
|
||||
LS_NICE=19
|
||||
LS_OPTS=""
|
||||
LS_PIDFILE=/var/run/$NAME/$NAME.pid
|
||||
|
||||
# End of variables that can be overwritten in $DEFAULT
|
||||
|
||||
if [ -f "$DEFAULT" ]; then
|
||||
. "$DEFAULT"
|
||||
fi
|
||||
|
||||
# Define other required variables
|
||||
PID_FILE=${LS_PIDFILE}
|
||||
test -n "${LS_LOG_FILE}" && LS_OPTS="${LS_OPTS} -l ${LS_LOG_FILE}"
|
||||
|
||||
DAEMON="/opt/logstash/bin/logstash"
|
||||
DAEMON_OPTS="web ${LS_OPTS}"
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
do_start()
|
||||
{
|
||||
|
||||
if [ -z "$DAEMON" ]; then
|
||||
echo "not found - $DAEMON"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if pidofproc -p "$PID_FILE" >/dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Prepare environment
|
||||
HOME="${HOME:-$LS_HOME}"
|
||||
JAVA_OPTS="${LS_JAVA_OPTS}"
|
||||
ulimit -n ${LS_OPEN_FILES}
|
||||
cd "${LS_HOME}"
|
||||
export PATH HOME JAVA_OPTS LS_HEAP_SIZE LS_JAVA_OPTS LS_USE_GC_LOGGING
|
||||
test -n "${JAVACMD}" && export JAVACMD
|
||||
|
||||
nice -n ${LS_NICE} runuser -s /bin/sh -c "exec $DAEMON $DAEMON_OPTS" ${LS_USER} > /dev/null 2>&1 < /dev/null &
|
||||
|
||||
RETVAL=$?
|
||||
local PID=$!
|
||||
# runuser forks rather than execing our process.
|
||||
usleep 500000
|
||||
JAVA_PID=$(ps axo ppid,pid | awk -v "ppid=$PID" '$1==ppid {print $2}')
|
||||
PID=${JAVA_PID:-$PID}
|
||||
echo $PID > $PID_FILE
|
||||
[ "$PID" = "$JAVA_PID" ] && success
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_stop()
|
||||
{
|
||||
killproc -p $PID_FILE $DAEMON
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL = 0 ] && rm -f ${PID_FILE}
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting $DESC: "
|
||||
do_start
|
||||
touch /var/run/logstash/$NAME
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping $DESC: "
|
||||
do_stop
|
||||
rm /var/run/logstash/$NAME
|
||||
;;
|
||||
restart|reload)
|
||||
echo -n "Restarting $DESC: "
|
||||
do_stop
|
||||
do_start
|
||||
;;
|
||||
status)
|
||||
echo -n "$DESC"
|
||||
status -p $PID_FILE
|
||||
exit $?
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
echo
|
||||
exit 0
|
|
@ -1,48 +0,0 @@
|
|||
# logstash-web - web instance
|
||||
#
|
||||
|
||||
description "logstash-web agent"
|
||||
|
||||
start on virtual-filesystems
|
||||
stop on runlevel [06]
|
||||
|
||||
# Respawn it if the process exits
|
||||
respawn
|
||||
|
||||
# We're setting high here, we'll re-limit below.
|
||||
limit nofile 65550 65550
|
||||
|
||||
setuid logstash
|
||||
setgid logstash
|
||||
|
||||
# You need to chdir somewhere writable because logstash needs to unpack a few
|
||||
# temporary files on startup.
|
||||
console log
|
||||
script
|
||||
# Defaults
|
||||
PATH=/bin:/usr/bin
|
||||
LS_HOME=/var/lib/logstash
|
||||
LS_HEAP_SIZE="500m"
|
||||
LS_JAVA_OPTS="-Djava.io.tmpdir=${LS_HOME}"
|
||||
LS_LOG_FILE=/var/log/logstash/logstash.log
|
||||
LS_USE_GC_LOGGING=""
|
||||
LS_CONF_DIR=/etc/logstash/conf.d
|
||||
LS_OPEN_FILES=2048
|
||||
LS_NICE=19
|
||||
LS_OPTS=""
|
||||
|
||||
# Override our defaults with user defaults:
|
||||
[ -f /etc/default/logstash-web ] && . /etc/default/logstash-web
|
||||
|
||||
HOME="${HOME:-$LS_HOME}"
|
||||
JAVA_OPTS="${LS_JAVA_OPTS}"
|
||||
# Reset filehandle limit
|
||||
ulimit -n ${LS_OPEN_FILES}
|
||||
cd "${LS_HOME}"
|
||||
|
||||
# Export variables
|
||||
export PATH HOME JAVA_OPTS LS_HEAP_SIZE LS_JAVA_OPTS LS_USE_GC_LOGGING
|
||||
test -n "${JAVACMD}" && export JAVACMD
|
||||
|
||||
exec nice -n ${LS_NICE} /opt/logstash/bin/logstash web ${LS_OPTS}
|
||||
end script
|
|
@ -1,7 +1,6 @@
|
|||
namespace "vendor" do
|
||||
VERSIONS = {
|
||||
"jruby" => { "version" => "1.7.17", "sha1" => "e4621bbcc51242061eaa9b62caee69c2a2b433f0" },
|
||||
"kibana" => { "version" => "3.1.2", "sha1" => "a59ea4abb018a7ed22b3bc1c3bcc6944b7009dc4" },
|
||||
}
|
||||
|
||||
def vendor(*args)
|
||||
|
@ -105,25 +104,6 @@ namespace "vendor" do
|
|||
end
|
||||
task "all" => "jruby"
|
||||
|
||||
task "kibana" do |task, args|
|
||||
name = task.name.split(":")[1]
|
||||
info = VERSIONS[name]
|
||||
version = info["version"]
|
||||
url = "https://download.elasticsearch.org/kibana/kibana/kibana-#{version}.tar.gz"
|
||||
download = file_fetch(url, info["sha1"])
|
||||
|
||||
parent = vendor(name).gsub(/\/$/, "")
|
||||
directory parent => "vendor" do
|
||||
FileUtils.mkdir(parent)
|
||||
end.invoke unless Rake::Task.task_defined?(parent)
|
||||
|
||||
prefix_re = /^#{Regexp.quote("kibana-#{version}/")}/
|
||||
untar(download) do |entry|
|
||||
vendor(name, entry.full_name.gsub(prefix_re, ""))
|
||||
end # untar
|
||||
end # task kibana
|
||||
task "all" => "kibana"
|
||||
|
||||
task "system_gem", :jruby_bin, :name, :version do |task, args|
|
||||
jruby_bin = args[:jruby_bin]
|
||||
name = args[:name]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
require "spec_helper"
|
||||
require "logstash/runner"
|
||||
require "logstash/kibana"
|
||||
require "stud/task"
|
||||
|
||||
class NullRunner
|
||||
|
@ -36,18 +35,6 @@ describe LogStash::Runner do
|
|||
expect(subject.run(args).wait).to eq(1)
|
||||
end
|
||||
|
||||
it "should run agent help and not run following commands" do
|
||||
expect(subject).to receive(:show_help).once.and_return(nil)
|
||||
args = ["agent", "-h", "web"]
|
||||
expect(subject.run(args).wait).to eq(0)
|
||||
end
|
||||
|
||||
it "should not run agent and web" do
|
||||
expect(Stud::Task).to receive(:new).once
|
||||
args = ["agent", "-e", "", "web"]
|
||||
args = subject.run(args)
|
||||
expect(args).to eq(nil)
|
||||
|
||||
expect(LogStash::Kibana::Runner).to_not receive(:new)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe "web tests" do
|
||||
context "rack rubygem" do
|
||||
it "must be available" do
|
||||
require "rack"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue