File logreduce.spec of Package logreduce
#
# spec file for package python-logreduce
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: logreduce
Version: 0.4.0
Release: 0
Summary: Log file anomaly extractor
License: Apache-2.0
Group: Development/Languages/Python
URL: https://logreduce.softwarefactory-project.io/
Source: https://files.pythonhosted.org/packages/source/l/logreduce/logreduce-%{version}.tar.gz
Source1: node_modules.tar.gz
Source10: logreduce-server.service
Source11: logreduce-worker.service
Source99: create_node_modules_deps.sh
BuildRequires: apache2
BuildRequires: nodejs
BuildRequires: python3-pbr
BuildRequires: python3-setuptools
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Provides: log-classify = %version
Requires: python3-CherryPy
Requires: python3-PyYAML
Requires: python3-SQLAlchemy
Requires: python3-aiohttp
Requires: python3-alembic
Requires: python3-gear
Requires: python3-numpy
Requires: python3-requests
Requires: python3-scikit-learn
Requires: python3-scipy
Requires: python3-voluptuous
BuildArch: noarch
# SECTION test requirements
BuildRequires: python3-CherryPy
BuildRequires: python3-PyYAML
BuildRequires: python3-SQLAlchemy
BuildRequires: python3-aiohttp
BuildRequires: python3-alembic
BuildRequires: python3-gear
BuildRequires: python3-mock
BuildRequires: python3-nose
BuildRequires: python3-numpy
BuildRequires: python3-pytest
BuildRequires: python3-requests
BuildRequires: python3-routes
BuildRequires: python3-scikit-learn
BuildRequires: python3-scipy
BuildRequires: python3-voluptuous
%description
Based on success logs, logreduce highlights useful text in failed logs.
The goal is to save time in finding a failure's root cause.
On average, learning run at 2000 lines per second, and
testing run at 1300 lines per seconds.
logreduce uses a *model* to learn successful logs and detect novelties in
failed logs:
* Random words are manually removed using regular expression
* Then lines are converted to a matrix of token occurrences
(using **HashingVectorizer**),
* An unsupervised learner implements neighbor searches
(using **NearestNeighbors**).
%package server
Summary: The logreduce server component
Requires: %name = %version
Requires: python3-logreduce = %version
%description server
Based on success logs, logreduce highlights useful text in failed logs.
The goal is to save time in finding a failure's root cause.
This subpackage provides the server component.
%package webui
Summary: The logreduce WEB UI component
Requires: %name = %version
Requires: python3-logreduce = %version
%description webui
Based on success logs, logreduce highlights useful text in failed logs.
The goal is to save time in finding a failure's root cause.
This subpackage provides the WEB UI component.
%package worker
Summary: The logreduce worker component
Requires: %name = %version
Requires: python3-logreduce = %version
%description worker
Based on success logs, logreduce highlights useful text in failed logs.
The goal is to save time in finding a failure's root cause.
This subpackage provides the worker component.
%package -n python3-logreduce
Summary: logreduce python modules
%description -n python3-logreduce
Based on success logs, logreduce highlights useful text in failed logs.
The goal is to save time in finding a failure's root cause.
This subpackage provides the python components.
%prep
%setup -q -n logreduce-%{version} -a 1
sed -i -e 's,flake8.*,,' test-requirements.txt
%build
python3 setup.py build
pushd web
export PATH=$PWD/../node_modules/.bin/:$PATH
PUBLIC_URL="/log-classify/" yarn build
popd
%install
python3 setup.py install -O1 --skip-build --force --root %{buildroot} --prefix %_prefix
install -p -d -m 0755 %{buildroot}/%{_datadir}/log-classify
mv web/build/* %{buildroot}/%{_datadir}/log-classify
install -p -D -m 444 %{SOURCE10} %{buildroot}%{_unitdir}/logreduce-server.service
install -p -D -m 444 %{SOURCE11} %{buildroot}%{_unitdir}/logreduce-worker.service
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rclogreduce-server
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rclogreduce-worker
sed -i -e 's,/var/www,/srv/www,' etc/logreduce/config.yaml etc/httpd/log-classify.conf
install -p -D -m 644 etc/logreduce/config.yaml %{buildroot}%{_sysconfdir}/logreduce/config.yaml
install -p -D -m 644 etc/httpd/log-classify.conf %{buildroot}/etc/apache2/conf.d/log-classify.conf
install -p -d -m 750 %{buildroot}%{_sharedstatedir}/logreduce
install -p -d -m 700 %{buildroot}%{_localstatedir}/log/logreduce
install -p -d -m 755 %{buildroot}/srv/www/logreduce/anomalies
install -p -d -m 755 %{buildroot}/srv/www/logreduce/logs
%check
python3 -m pytest -v
%pre
getent group logreduce >/dev/null || %{_sbindir}/groupadd -r logreduce
getent passwd logreduce || %{_sbindir}/useradd -r -g logreduce -d %{_localstatedir}/logreduce -s /usr/bin/false logreduce
%pre server
%service_add_pre logreduce-worker.service
%pre worker
%service_add_pre logreduce-server.service
%post server
%service_add_post logreduce-server.service
%post worker
%service_add_post logreduce-worker.service
%preun server
%service_del_preun logreduce-server.service
%preun worker
%service_del_preun logreduce-worker.service
%postun server
%service_del_postun logreduce-server.service
%postun worker
%service_del_postun logreduce-worker.service
%files
%{_bindir}/logreduce
%{_bindir}/logreduce-client
%dir %{_sysconfdir}/logreduce
%config(noreplace) %attr(0640, root, logreduce) %{_sysconfdir}/logreduce/config.yaml
%dir %attr(0750, logreduce, logreduce) %{_sharedstatedir}/logreduce
%dir %attr(0750, logreduce, logreduce) %{_localstatedir}/log/logreduce
%files -n python3-logreduce
%license LICENSE
%doc ChangeLog README.rst
%{python3_sitelib}/logreduce*
%files server
%{_bindir}/logreduce-server
%config(noreplace) /etc/apache2/conf.d/log-classify.conf
%{_sbindir}/rclogreduce-server
%{_unitdir}/logreduce-server.service
%dir /srv/www/logreduce
%dir %attr(0755, logreduce, logreduce) /srv/www/logreduce/logs
%dir %attr(0755, logreduce, logreduce) /srv/www/logreduce/anomalies
%files worker
%{_bindir}/logreduce-worker
%{_sbindir}/rclogreduce-worker
%{_unitdir}/logreduce-worker.service
%files webui
%{_datadir}/log-classify
%changelog