Added logstash.service and logstash.conf.
Change-Id: Ic362bd2dae91cc0bca3bef5bcf31ad85ee869e39
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5461
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,28 @@ |
| 0 |
+input {
|
|
| 1 |
+ tcp {
|
|
| 2 |
+ port => 5000 |
|
| 3 |
+ type => syslog |
|
| 4 |
+ } |
|
| 5 |
+ udp {
|
|
| 6 |
+ port => 5000 |
|
| 7 |
+ type => syslog |
|
| 8 |
+ } |
|
| 9 |
+} |
|
| 10 |
+ |
|
| 11 |
+filter {
|
|
| 12 |
+ if [type] == "syslog" {
|
|
| 13 |
+ grok {
|
|
| 14 |
+ match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
|
|
| 15 |
+ add_field => [ "received_at", "%{@timestamp}" ]
|
|
| 16 |
+ add_field => [ "received_from", "%{host}" ]
|
|
| 17 |
+ } |
|
| 18 |
+ date {
|
|
| 19 |
+ match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ] |
|
| 20 |
+ } |
|
| 21 |
+ } |
|
| 22 |
+} |
|
| 23 |
+ |
|
| 24 |
+output {
|
|
| 25 |
+ elasticsearch { hosts => "localhost" }
|
|
| 26 |
+ stdout { codec => rubydebug }
|
|
| 27 |
+} |
| 0 | 28 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,15 @@ |
| 0 |
+[Unit] |
|
| 1 |
+Description=Logstash |
|
| 2 |
+Documentation=https://www.elastic.co/products/logstash |
|
| 3 |
+After=network.target |
|
| 4 |
+ConditionPathExists=/etc/logstash/logstash.conf |
|
| 5 |
+ |
|
| 6 |
+[Service] |
|
| 7 |
+ExecStart=/bin/bash /usr/share/logstash/bin/logstash -f /etc/logstash/logstash.conf |
|
| 8 |
+ExecReload=/usr/bin/kill -HUP $MAINPID |
|
| 9 |
+KillSignal=SIGINT |
|
| 10 |
+User=logstash |
|
| 11 |
+Group=logstash |
|
| 12 |
+ |
|
| 13 |
+[Install] |
|
| 14 |
+WantedBy=multi-user.target |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
Summary: Logstash is a tool for managing events and logs. |
| 2 | 2 |
Name: logstash |
| 3 | 3 |
Version: 6.3.0 |
| 4 |
-Release: 1%{?dist}
|
|
| 4 |
+Release: 2%{?dist}
|
|
| 5 | 5 |
License: Apache License Version 2.0 |
| 6 | 6 |
Group: Applications/System |
| 7 | 7 |
Vendor: VMware, Inc. |
| ... | ... |
@@ -9,10 +9,14 @@ Distribution: Photon |
| 9 | 9 |
URL: https://github.com/elastic/logstash/archive/v%{version}.tar.gz
|
| 10 | 10 |
Source0: %{name}-%{version}.tar.gz
|
| 11 | 11 |
%define sha1 %{name}-%{version}.tar.gz=4140da67b1609b8664122e331cb8820ae786b3a6
|
| 12 |
+Source1: %{name}.service
|
|
| 13 |
+Source2: %{name}.conf
|
|
| 12 | 14 |
BuildRequires: openjdk |
| 13 | 15 |
BuildRequires: ruby |
| 14 | 16 |
Requires: openjdk |
| 15 | 17 |
Requires: ruby |
| 18 |
+Requires: systemd |
|
| 19 |
+Requires: elasticsearch |
|
| 16 | 20 |
|
| 17 | 21 |
%description |
| 18 | 22 |
Logstash is a tool to collect, process, and forward events and log messages. Collection is accomplished via configurable input plugins including raw socket/packet communication, file tailing, and several message bus clients. Once an input plugin has collected data it can be processed by any number of filters which modify and annotate the event data. Finally logstash routes events to output plugins which can forward the events to a variety of external programs including Elasticsearch, local files and several message bus implementations. |
| ... | ... |
@@ -38,6 +42,7 @@ install -vdm 755 %{buildroot}/var/log/%{name}
|
| 38 | 38 |
install -vdm 750 %{buildroot}%{_datadir}/%{name}/bin
|
| 39 | 39 |
install -vdm 775 %{buildroot}%{_datadir}/%{name}/data
|
| 40 | 40 |
install -vdm 750 %{buildroot}%{_datadir}/%{name}/lib
|
| 41 |
+install -vdm 750 %{buildroot}%{_datadir}/%{name}/config
|
|
| 41 | 42 |
install -vdm 750 %{buildroot}%{_datadir}/%{name}/logstash-core
|
| 42 | 43 |
install -vdm 750 %{buildroot}%{_datadir}/%{name}/logstash-core-plugin-api
|
| 43 | 44 |
install -vdm 750 %{buildroot}%{_datadir}/%{name}/modules
|
| ... | ... |
@@ -45,7 +50,12 @@ install -vdm 750 %{buildroot}%{_datadir}/%{name}/tools
|
| 45 | 45 |
install -vdm 755 %{buildroot}%{_datadir}/%{name}/tools/ingest-converter
|
| 46 | 46 |
install -vdm 750 %{buildroot}%{_datadir}/%{name}/vendor
|
| 47 | 47 |
|
| 48 |
-cp -r config/* %{buildroot}%{_sysconfdir}/%{name}/conf.d
|
|
| 48 |
+install -vdm 755 %{buildroot}/usr/lib/systemd/system
|
|
| 49 |
+install -p -m 0644 %{SOURCE1} %{buildroot}/usr/lib/systemd/system/
|
|
| 50 |
+ |
|
| 51 |
+cp -r config/* %{buildroot}%{_sysconfdir}/%{name}
|
|
| 52 |
+cp -r config/* %{buildroot}%{_datadir}/%{name}/config
|
|
| 53 |
+install -p -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/%{name}/
|
|
| 49 | 54 |
|
| 50 | 55 |
cp -r bin/* %{buildroot}%{_datadir}/%{name}/bin
|
| 51 | 56 |
rm -rf %{buildroot}%{_datadir}/%{name}/bin/bundle
|
| ... | ... |
@@ -73,14 +83,45 @@ install -p -m 0640 Gemfile.lock %{buildroot}%{_datadir}/%{name}
|
| 73 | 73 |
install -p -m 0664 LICENSE.txt %{buildroot}%{_datadir}/%{name}
|
| 74 | 74 |
install -p -m 0640 NOTICE.TXT %{buildroot}%{_datadir}/%{name}
|
| 75 | 75 |
|
| 76 |
+%pre |
|
| 77 |
+if ! getent group %{name} >/dev/null; then
|
|
| 78 |
+ groupadd %{name}
|
|
| 79 |
+fi |
|
| 80 |
+if ! getent passwd %{name} >/dev/null; then
|
|
| 81 |
+ useradd -c "Logstash" -d /var/lib/%{name} -g %{name} -s /bin/false %{name}
|
|
| 82 |
+fi |
|
| 83 |
+exit 0 |
|
| 84 |
+ |
|
| 85 |
+%post |
|
| 86 |
+%systemd_post %{name}.service
|
|
| 87 |
+ |
|
| 88 |
+%postun |
|
| 89 |
+if [ $1 -eq 0 ]; then |
|
| 90 |
+ # this is delete operation |
|
| 91 |
+ if getent passwd %{name} >/dev/null; then
|
|
| 92 |
+ userdel %{name}
|
|
| 93 |
+ fi |
|
| 94 |
+ if getent group %{name} >/dev/null; then
|
|
| 95 |
+ groupdel %{name}
|
|
| 96 |
+ fi |
|
| 97 |
+fi |
|
| 98 |
+%systemd_postun_with_restart %{name}.service
|
|
| 99 |
+ |
|
| 100 |
+%preun |
|
| 101 |
+%systemd_preun %{name}.service
|
|
| 102 |
+ |
|
| 76 | 103 |
%files |
| 77 | 104 |
%defattr(-,root,root) |
| 78 | 105 |
%dir %{_datadir}/%{name}
|
| 79 |
-%{_datadir}/%{name}
|
|
| 106 |
+%attr(-,logstash,logstash) %{_datadir}/%{name}
|
|
| 80 | 107 |
%{_sysconfdir}/%{name}
|
| 81 |
-/var/lib/%{name}
|
|
| 82 |
-/var/log/%{name}
|
|
| 108 |
+%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
|
|
| 109 |
+/usr/lib/systemd/system/%{name}.service
|
|
| 110 |
+%attr(-,logstash,logstash) /var/lib/%{name}
|
|
| 111 |
+%attr(-,logstash,logstash) /var/log/%{name}
|
|
| 83 | 112 |
|
| 84 | 113 |
%changelog |
| 114 |
+* Mon Aug 06 2018 Ankit Jain <ankitja@vmware.com> 6.3.0-2 |
|
| 115 |
+- Added logstash.service and logstash.conf |
|
| 85 | 116 |
* Thu Jul 19 2018 Ankit Jain <ankitja@vmware.com> 6.3.0-1 |
| 86 | 117 |
- Initial Version. |