Merge lp:~paulcz/charms/precise/logstash-indexer/trunk into lp:charms/logstash-indexer

Proposed by Paul Czarkowski
Status: Merged
Merged at revision: 7
Proposed branch: lp:~paulcz/charms/precise/logstash-indexer/trunk
Merge into: lp:charms/logstash-indexer
Diff against target: 276 lines (+133/-32)
9 files modified
README.md (+20/-20)
files/charm/50-filters.conf (+40/-0)
files/charm/logstash-indexer.conf (+1/-1)
hooks/amqp-relation-changed (+43/-0)
hooks/amqp-relation-joined (+10/-0)
hooks/common.sh (+5/-3)
hooks/install (+8/-6)
metadata.yaml (+5/-1)
revision (+1/-1)
To merge this branch: bzr merge lp:~paulcz/charms/precise/logstash-indexer/trunk
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Approve
Review via email: mp+188244@code.launchpad.net

Description of the change

* Updated to support logstash 1.2.x

To post a comment you must log in.
8. By Paul Czarkowski

amqp relationship

9. By Paul Czarkowski

filters

10. By Paul Czarkowski

remove dropping message

Revision history for this message
Marco Ceppi (marcoceppi) wrote :

LGTM +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2012-11-18 22:27:48 +0000
3+++ README.md 2013-10-18 15:38:52 +0000
4@@ -19,37 +19,37 @@
5 example 1 - Just the Indexer + Kibana
6 =====================================
7
8-juju deploy --repository=logstash local:precise/logstash-indexer
9-juju deploy --repository=logstash local:precise/kibana
10-juju add-relation kibana logstash-indexer:rest
11-juju expose kibana
12+ juju deploy --repository=logstash local:precise/logstash-indexer
13+ juju deploy --repository=logstash local:precise/kibana
14+ juju add-relation kibana logstash-indexer:rest
15+ juju expose kibana
16
17 http://ip-of-kibana
18
19 example 2 - Indexer + 2 x ElasticSearch + Kibana
20 ============================================
21
22-juju deploy --repository=logstash local:precise/elasticsearch
23-juju add-unit elasticsearch
24-juju deploy --repository=logstash local:precise/logstash-indexer
25-juju add-relation logstash-indexer elasticsearch:cluster
26-juju deploy --repository=logstash local:precise/kibana
27-juju add-relation kibana elasticsearch:rest
28-juju expose kibana
29+ juju deploy --repository=logstash local:precise/elasticsearch
30+ juju add-unit elasticsearch
31+ juju deploy --repository=logstash local:precise/logstash-indexer
32+ juju add-relation logstash-indexer elasticsearch:cluster
33+ juju deploy --repository=logstash local:precise/kibana
34+ juju add-relation kibana elasticsearch:rest
35+ juju expose kibana
36
37 http://ip-of-kibana
38
39 example 3 - Agent + Indexer + 2 x ElasticSearch + Kibana
40 =============================================
41
42-juju deploy --repository=logstash local:precise/elasticsearch
43-juju add-unit elasticsearch
44-juju deploy --repository=logstash local:precise/logstash-indexer
45-juju add-relation logstash-indexer elasticsearch:cluster
46-juju deploy --repository=logstash local:precise/kibana
47-juju add-relation kibana elasticsearch:rest
48-juju expose kibana
49-juju deploy --repository=logstash local:precise/logstash-agent
50-juju add-relation logstash-agent logstash-indexer:input
51+ juju deploy --repository=logstash local:precise/elasticsearch
52+ juju add-unit elasticsearch
53+ juju deploy --repository=logstash local:precise/logstash-indexer
54+ juju add-relation elasticsearch:cluster logstash-indexer
55+ juju deploy --repository=logstash local:precise/kibana
56+ juju add-relation elasticsearch:rest kibana
57+ juju expose kibana
58+ juju deploy --repository=logstash local:precise/logstash-agent
59+ juju add-relation logstash-agent logstash-indexer:input
60
61 http://ip-of-kibana
62\ No newline at end of file
63
64=== added file 'files/charm/50-filters.conf'
65--- files/charm/50-filters.conf 1970-01-01 00:00:00 +0000
66+++ files/charm/50-filters.conf 2013-10-18 15:38:52 +0000
67@@ -0,0 +1,40 @@
68+filter {
69+
70+ if [type] == "sensu" {
71+ date {
72+ match => ["timestamp", "ISO8601"]
73+ }
74+ mutate {
75+ remove_field => [ "timestamp" ]
76+ }
77+ }
78+
79+ if [type] == "web-access" {
80+ grok {
81+ match => ["message", "%{COMBINEDAPACHELOG}"]
82+ }
83+ date {
84+ match => [ "timestamp", "dd/MMM/yyyy:HH:mm:ss Z", "dd/MMM/yyyy:HH:mm:ss" ]
85+ }
86+ geoip {
87+ source => "clientip"
88+ }
89+ mutate {
90+ remove_field => [ "timestamp" ]
91+ }
92+ }
93+
94+ if [type] == "syslog" {
95+ grok {
96+ overwrite => "message"
97+ match => {
98+ "message" => "%{SYSLOGTIMESTAMP:timestamp} %{IPORHOST:host} (?:%{PROG:program}(?:\[%{POSINT:pid}\])?: )?%{GREEDYDATA:message}"
99+ }
100+ }
101+ syslog_pri { }
102+ date {
103+ match => [ "timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss", "ISO8601" ]
104+ }
105+ }
106+
107+}
108\ No newline at end of file
109
110=== modified file 'files/charm/logstash-indexer.conf'
111--- files/charm/logstash-indexer.conf 2012-11-18 22:27:48 +0000
112+++ files/charm/logstash-indexer.conf 2013-10-18 15:38:52 +0000
113@@ -18,5 +18,5 @@
114 console log
115
116 script
117- java -jar BASEPATH/bin/logstash-monolithic.jar agent -f BASEPATH/conf.d/ --log BASEPATH/logstash-indexer.log -v
118+ java -jar BASEPATH/bin/logstash.jar agent -f BASEPATH/conf.d/ --log BASEPATH/logstash-indexer.log
119 end script
120\ No newline at end of file
121
122=== added file 'hooks/amqp-relation-changed'
123--- hooks/amqp-relation-changed 1970-01-01 00:00:00 +0000
124+++ hooks/amqp-relation-changed 2013-10-18 15:38:52 +0000
125@@ -0,0 +1,43 @@
126+#!/bin/bash
127+
128+set -eux # -x for verbose logging to juju debug-log
129+HOME=`dirname $0`
130+. $HOME/common.sh
131+
132+juju-log "logstash_agent - Relationship Advice -> $JUJU_REMOTE_UNIT"
133+juju-log Relation settings:
134+relation-get
135+juju-log Relation members:
136+relation-list
137+
138+RABBIT_HOST=$(relation-get private-address)
139+RABBIT_PASS=$(relation-get password)
140+
141+if [[ -z $RABBIT_HOST ]] || [[ -z $RABBIT_PASS ]] ; then
142+ juju-log "logstash_agent - amqp_changed: rabbit_host||rabbit_password not set."
143+ exit 0
144+fi
145+
146+
147+clustered=$(relation-get clustered)
148+if [[ -n "$clustered" ]] ; then
149+ juju-log "logstash_agent - ampq_changed: Configuring for access to haclustered rabbitmq service."
150+ RABBIT_VIP=$(relation-get vip)
151+ [[ -z "$vip" ]] && juju-log "logstash_agent - amqp_changed: Clustered but no vip." && exit 0
152+ RABBIT_HOST="$RABBIT_VIP"
153+fi
154+
155+
156+cat > ${BASEPATH}/conf.d/input_rabbit.conf << EOF
157+input {
158+ rabbitmq {
159+ exchange => "logstash"
160+ host => "${RABBIT_HOST}"
161+ user => "${RABBIT_USER}"
162+ password => "${RABBIT_PASS}"
163+ vhost => "${RABBIT_VHOST}"
164+ }
165+}
166+EOF
167+
168+[ "$(initctl status logstash-indexer | grep running)" ] && initctl restart logstash-indexer || initctl start logstash-indexer
169
170=== added file 'hooks/amqp-relation-joined'
171--- hooks/amqp-relation-joined 1970-01-01 00:00:00 +0000
172+++ hooks/amqp-relation-joined 2013-10-18 15:38:52 +0000
173@@ -0,0 +1,10 @@
174+#!/bin/bash
175+
176+set -eux # -x for verbose logging to juju debug-log
177+HOME=`dirname $0`
178+. $HOME/common.sh
179+
180+relation-set username=${RABBIT_USER}
181+relation-set vhost=${RABBIT_VHOST}
182+
183+juju-log "logstash-indexer - amqp_joined: requesting credentials for $RABBIT_USER"
184\ No newline at end of file
185
186=== modified file 'hooks/common.sh'
187--- hooks/common.sh 2012-11-18 22:27:48 +0000
188+++ hooks/common.sh 2013-10-18 15:38:52 +0000
189@@ -3,13 +3,15 @@
190 #set -eux # -x for verbose logging to juju debug-log
191
192 # Set CONFIG constants
193-VERSION="1.1.4"
194-BASEURL="https://logstash.objects.dreamhost.com/release"
195-CHECKSUM="68ac6c953aad026752f69ae7c15b13f4"
196+VERSION="1.2.1"
197+BASEURL="https://download.elasticsearch.org/logstash/logstash"
198+CHECKSUM="863272192b52bccf1fc2cf839a888eaf"
199 BASEPATH="/opt/logstash"
200 USER="logstash"
201 HOST=`unit-get private-address`
202 CLUSTER_NAME="elasticsearch"
203+RABBIT_USER="logstash"
204+RABBIT_VHOST="logstash"
205
206 # Grab CONFIG variables
207 # Example :
208
209=== modified file 'hooks/install'
210--- hooks/install 2012-11-18 22:27:48 +0000
211+++ hooks/install 2013-10-18 15:38:52 +0000
212@@ -7,7 +7,7 @@
213 juju-log "Installing required Packages via apt-get - java"
214 # was giving errors trying to install jre without update first.
215 apt-get update
216-apt-get -y install default-jre-headless curl redis-server
217+apt-get -y install openjdk-7-jre-headless curl redis-server
218 # set redis listener
219 sed -i.bak -e "s/bind 127.0.0.1/#bind ${HOST}/" /etc/redis/redis.conf
220 juju-log "Install upstart init script"
221@@ -21,14 +21,14 @@
222 mkdir -p ${BASEPATH}/data
223 juju-log "install logstash and create config files"
224 # Check if a local copy of the jar exists
225-if [ -f ${HOME}/../files/charm/logstash-${VERSION}-monolithic.jar ]
226+if [ -f ${HOME}/../files/charm/logstash-${VERSION}-flatjar.jar ] logstash-1.2.1-flatjar.jar
227 then
228- install -o root -g root -m 0644 ${HOME}/../files/charm/logstash-${VERSION}-monolithic.jar ${BASEPATH}/bin/logstash-monolithic.jar
229+ install -o root -g root -m 0644 ${HOME}/../files/charm/logstash-${VERSION}.jar ${BASEPATH}/bin/logstash.jar
230 else
231 # Download logstash monolithic jar and checksum
232- wget -q -O ${BASEPATH}/bin/logstash-monolithic.jar ${BASEURL}/logstash-${VERSION}-monolithic.jar
233- if [[ $(md5sum "${BASEPATH}/bin/logstash-monolithic.jar" | cut -d " " -f 1) != ${CHECKSUM} ]]; then
234- juju-log --log-level CRITICAL "Checksum of ${BASEPATH}/bin/logstash-monolithic.jar failed"
235+ wget -q -O ${BASEPATH}/bin/logstash.jar ${BASEURL}/logstash-${VERSION}-flatjar.jar
236+ if [[ $(md5sum "${BASEPATH}/bin/logstash.jar" | cut -d " " -f 1) != ${CHECKSUM} ]]; then
237+ juju-log --log-level CRITICAL "Checksum of ${BASEPATH}/bin/logstash.jar failed"
238 exit 1
239 fi
240 fi
241@@ -36,6 +36,8 @@
242 echo 'input { redis { host => "127.0.0.1" data_type => "list" type => "redis" tags => ["redis"] key => "logstash" message_format => "json_event" } } ' > ${BASEPATH}/conf.d/input-redis.conf
243 echo 'output { elasticsearch { embedded => true } }' > ${BASEPATH}/conf.d/output-elasticsearch.conf
244
245+install -o root -g root -m 0644 ${HOME}/../files/charm/50-filters.conf ${BASEPATH}/conf.d/50-filters.conf
246+
247 juju-log "create log file and pwn it"
248 touch /var/log/logstash-indexer.log
249 chown ${USER}. /var/log/logstash-indexer.log
250
251=== modified file 'metadata.yaml'
252--- metadata.yaml 2012-11-18 22:27:48 +0000
253+++ metadata.yaml 2013-10-18 15:38:52 +0000
254@@ -4,10 +4,14 @@
255 description: |
256 Installs the logstash indexer. Initially stand alone version,
257 but would like to add charms and hooks for ElasticSearch,
258- Kibana, and other stuffs.
259+ Kibana, and other stuffs.
260+categories:
261+ - applications
262 requires:
263 cluster:
264 interface: elasticsearch
265+ amqp:
266+ interface: rabbitmq
267 provides:
268 input:
269 interface: redis
270
271=== modified file 'revision'
272--- revision 2012-11-01 04:07:22 +0000
273+++ revision 2013-10-18 15:38:52 +0000
274@@ -1,1 +1,1 @@
275-0
276+1

Subscribers

People subscribed via source and target branches

to all changes: