diff --git a/Makefile b/Makefile index d54d69c0..0ef04739 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ VERSION = "build-$(shell date +%F)" all: install: - install -d -m 755 $(DESTDIR)$(bindir) $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(unitdir) $(DESTDIR)$(oscplugindir) $(DESTDIR)$(sysconfdir)/$(package_name) + install -d -m 755 $(DESTDIR)$(bindir) $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(unitdir) $(DESTDIR)$(oscplugindir) $(DESTDIR)$(sysconfdir)/$(package_name) $(DESTDIR)$(grafana_dashboards_dir) for i in $(pkgdata_SCRIPTS); do install -m 755 $$i $(DESTDIR)$(pkgdatadir); done chmod 644 $(DESTDIR)$(pkgdatadir)/osc-*.py for i in $(pkgdata_DATA); do cp -a $$i $(DESTDIR)$(pkgdatadir); done @@ -34,6 +34,7 @@ install: for i in $(pkgdata_BINS); do ln -s $(pkgdatadir)/$$i $(DESTDIR)$(bindir)/osrt-$${i%.*}; done install -m 755 script/* $(DESTDIR)$(bindir) cp -R config/* $(DESTDIR)$(sysconfdir)/$(package_name) + for i in metrics/grafana/* ; do ln -s $(pkgdatadir)/$$i $(DESTDIR)$(grafana_dashboards_dir)/osrt-$$(basename $$i); done check: test diff --git a/Makefile.common b/Makefile.common index 8fe25b7f..bc49dc11 100644 --- a/Makefile.common +++ b/Makefile.common @@ -5,6 +5,7 @@ datadir=$(prefix)/share sysconfdir=/etc unitdir=$(prefix)/lib/systemd/system pkgdatadir=$(datadir)/osc-plugin-factory +grafana_dashboards_dir="/var/lib/grafana/dashboards/$(package_name)" oscplugindir=$(prefix)/lib/osc-plugins apachevhostsdir=$(sysconfdir)/apache2/vhosts.d tmpfilesdir=$(prefix)/lib/tmpfiles.d diff --git a/dist/package/openSUSE-release-tools.spec b/dist/package/openSUSE-release-tools.spec index d74ac2d9..9d98fcde 100644 --- a/dist/package/openSUSE-release-tools.spec +++ b/dist/package/openSUSE-release-tools.spec @@ -151,6 +151,8 @@ Requires: osclib = %{version} # TODO Requires: python-influxdb, but package does not exist in Factory, but # present in Cloud:OpenStack:Master/python-influxdb. Recommends: python-influxdb +Suggests: grafana +Suggests: influxdb %description metrics Ingest relevant OBS and annotation data to generate insightful metrics. @@ -268,6 +270,7 @@ make %{?_smp_mflags} %install %make_install \ + grafana_dashboards_dir="%{_localstatedir}/lib/grafana/dashboards/%{name}" \ oscplugindir="%{osc_plugin_dir}" \ VERSION="%{version}" @@ -340,6 +343,11 @@ exit 0 %service_del_postun osrt-maintenance-incidents.service # TODO Provide metrics service once #1006 is resolved. +%postun metrics +# If grafana-server.service is enabled then restart it to load new dashboards. +if [ -x /usr/bin/systemctl ] && systemctl is-enabled grafana-server ; then + /usr/bin/systemctl try-restart --no-block grafana-server +fi %pre repo-checker %service_add_pre osrt-repo-checker.service diff --git a/docs/metrics.md b/docs/metrics.md index e9a17797..3eaef72c 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -23,7 +23,8 @@ issues are documented in: - InfluxDB instance - Grafana instance - - import `metrics/grafana` dashboards + - `grafana.ini`: + - `[dashboards.json].enabled = true` to use the dashboards provided by rpm - create data sources for desired projects setting name and database to the project name (ex. `openSUSE:Factory`)