From 658739ed89d567ac5c657009a3327709ced4deeb Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Sun, 9 Aug 2020 18:25:53 +0000 Subject: [PATCH] import grafana-pcp-2.0.2-3.el8 --- .gitignore | 2 + .grafana-pcp.metadata | 2 + .../001-fix-empty-container-dashboard.patch | 30 +++ ...name-and-pid-in-flamegraph-dashboard.patch | 22 +++ SOURCES/create_dependency_bundle.sh | 37 ++++ SOURCES/list_bundled_nodejs_packages.py | 51 +++++ SPECS/grafana-pcp.spec | 185 ++++++++++++++++++ 7 files changed, 329 insertions(+) create mode 100644 .gitignore create mode 100644 .grafana-pcp.metadata create mode 100644 SOURCES/001-fix-empty-container-dashboard.patch create mode 100644 SOURCES/002-add-process-name-and-pid-in-flamegraph-dashboard.patch create mode 100755 SOURCES/create_dependency_bundle.sh create mode 100755 SOURCES/list_bundled_nodejs_packages.py create mode 100644 SPECS/grafana-pcp.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d17819 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +SOURCES/grafana-pcp-2.0.2.tar.gz +SOURCES/grafana-pcp-deps-2.0.2.tar.xz diff --git a/.grafana-pcp.metadata b/.grafana-pcp.metadata new file mode 100644 index 0000000..aca3298 --- /dev/null +++ b/.grafana-pcp.metadata @@ -0,0 +1,2 @@ +72d5789fd9277bc9816f6a0590bb5f044ad1175c SOURCES/grafana-pcp-2.0.2.tar.gz +226f68fa48b86eb4dfdcca73a79ab292adaa6503 SOURCES/grafana-pcp-deps-2.0.2.tar.xz diff --git a/SOURCES/001-fix-empty-container-dashboard.patch b/SOURCES/001-fix-empty-container-dashboard.patch new file mode 100644 index 0000000..5c57bfd --- /dev/null +++ b/SOURCES/001-fix-empty-container-dashboard.patch @@ -0,0 +1,30 @@ +diff --git a/src/dashboards/pcp-vector-container-overview.json b/src/dashboards/pcp-vector-container-overview.json +index a1a75c2..a674d74 100644 +--- a/src/dashboards/pcp-vector-container-overview.json ++++ b/src/dashboards/pcp-vector-container-overview.json +@@ -127,7 +127,7 @@ + "format": "percentunit", + "label": null, + "logBase": 1, +- "max": "1", ++ "max": null, + "min": "0", + "show": true + }, +diff --git a/src/datasources/lib/datasource_base.ts b/src/datasources/lib/datasource_base.ts +index db0167b..4bca9c0 100644 +--- a/src/datasources/lib/datasource_base.ts ++++ b/src/datasources/lib/datasource_base.ts +@@ -150,7 +150,11 @@ export abstract class PmapiDatasourceBase { + container: container, + endpoint: this.getOrCreateEndpoint(url, container) + }; +- }); ++ }) ++ // getConnectionParams only processes target.container if it is not blank ++ // the only case when container is "" is because it was $container, but the ++ // $container dashboard variable is empty (viewing "all" containers, but none exists) ++ .filter(target => target.container !== ""); + } + + async applyTransformations(pmapiSrv: PmapiSrv, results: TargetResult) { diff --git a/SOURCES/002-add-process-name-and-pid-in-flamegraph-dashboard.patch b/SOURCES/002-add-process-name-and-pid-in-flamegraph-dashboard.patch new file mode 100644 index 0000000..bb45ef0 --- /dev/null +++ b/SOURCES/002-add-process-name-and-pid-in-flamegraph-dashboard.patch @@ -0,0 +1,22 @@ +diff --git a/src/dashboards/pcp-bpftrace-flame-graphs.json b/src/dashboards/pcp-bpftrace-flame-graphs.json +index 8f3d0ba..a05dbb9 100644 +--- a/src/dashboards/pcp-bpftrace-flame-graphs.json ++++ b/src/dashboards/pcp-bpftrace-flame-graphs.json +@@ -150,7 +150,7 @@ + }, + "targets": [ + { +- "expr": "/*\n * sample kernel stacks every 99 Hz, and clear map every 5 seconds\n *\n * 30-Oct-2019 Andreas Gerstmayr Created this.\n */\n// include: @stacks\n// custom-output-block\n\nprofile:hz:99 { @stacks[kstack] = count(); }\n\ninterval:s:1 {\n print(@stacks);\n @cnt++;\n if (@cnt >= 5) {\n clear(@stacks);\n @cnt = 0;\n }\n}", ++ "expr": "/*\n * sample kernel stacks every 99 Hz, and clear map every 5 seconds\n *\n * 30-Oct-2019 Andreas Gerstmayr Created this.\n * 7-Aug-2020 Andreas Gerstmayr Added process name and PID.\n */\n// include: @stacks\n// custom-output-block\n\nprofile:hz:99 { @stacks[comm,pid,kstack] = count(); }\n\ninterval:s:1 {\n print(@stacks);\n @cnt++;\n if (@cnt >= 5) {\n clear(@stacks);\n @cnt = 0;\n }\n}", + "format": "flamegraph", + "minPcpVersion": "5.0.2", + "refId": "A" +@@ -177,7 +177,7 @@ + }, + "targets": [ + { +- "expr": "/*\n * sample user stacks every 99 Hz, and clear map every 5 seconds\n *\n * 30-Oct-2019 Andreas Gerstmayr Created this.\n */\n// include: @stacks\n// custom-output-block\n\nprofile:hz:99 { @stacks[ustack] = count(); }\n\ninterval:s:1 {\n print(@stacks);\n @cnt++;\n if (@cnt >= 5) {\n clear(@stacks);\n @cnt = 0;\n }\n}", ++ "expr": "/*\n * sample user stacks every 99 Hz, and clear map every 5 seconds\n *\n * 30-Oct-2019 Andreas Gerstmayr Created this.\n * 7-Aug-2020 Andreas Gerstmayr Added process name and PID.\n */\n// include: @stacks\n// custom-output-block\n\nprofile:hz:99 { @stacks[comm,pid,ustack] = count(); }\n\ninterval:s:1 {\n print(@stacks);\n @cnt++;\n if (@cnt >= 5) {\n clear(@stacks);\n @cnt = 0;\n }\n}", + "format": "flamegraph", + "minPcpVersion": "5.0.2", + "refId": "A" diff --git a/SOURCES/create_dependency_bundle.sh b/SOURCES/create_dependency_bundle.sh new file mode 100755 index 0000000..fbcd787 --- /dev/null +++ b/SOURCES/create_dependency_bundle.sh @@ -0,0 +1,37 @@ +#!/bin/bash -eu + +SRC=$(readlink -f "${1:?Usage: $0 source destination}") +DEST=$(readlink -f "${2:?Usage: $0 source destination}") + +if [ -f "$DEST" ]; then + echo "File $DEST exists already." + exit 0 +fi +if [ "$#" -gt 2 ]; then + PATCHES=$(readlink -f "${@:3}") +else + PATCHES="" +fi + +pushd "$(mktemp -d)" + +echo Extracting sources... +tar xfz "$SRC" +cd grafana-pcp-* + +echo Applying patches... +for patch in $PATCHES +do + patch -p1 < $patch +done + +echo Installing dependencies... +yarn install + +echo Removing files with licensing issues... +rm -rf node_modules/node-notifier + +echo Compressing... +XZ_OPT=-9 tar cJf "$DEST" node_modules + +popd diff --git a/SOURCES/list_bundled_nodejs_packages.py b/SOURCES/list_bundled_nodejs_packages.py new file mode 100755 index 0000000..a42e223 --- /dev/null +++ b/SOURCES/list_bundled_nodejs_packages.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +import sys +import os.path +import tarfile +from io import TextIOWrapper +import json +import re +from packaging import version + + +def read_declared_pkgs(f): + package_json = json.load(f) + return list(package_json['devDependencies'].keys()) + list(package_json['dependencies'].keys()) + + +def read_installed_pkgs(f): + lockfile = f.read() + return re.findall(r'^"?' # can start with a " + r'(.+?)@.+(?:,.*)?:\n' # characters up to @ + r' version "(.+)"', # and the version + lockfile, re.MULTILINE) + + +def list_provides(declared_pkgs, installed_pkgs): + for declared_pkg in declared_pkgs: + # there can be multiple versions installed of one package (transitive dependencies) + # but rpm doesn't support Provides: with a single package and multiple versions + # so let's declare the oldest version here + versions = [version.parse(pkg_version) + for pkg_name, pkg_version in installed_pkgs if pkg_name == declared_pkg] + oldest_version = sorted(versions)[0] + yield f"Provides: bundled(nodejs-{declared_pkg}) = {oldest_version}" + + +if __name__ == "__main__": + if len(sys.argv) != 2: + print(f"usage: {sys.argv[0]} grafana-pcp-X.Y.Z.tar.gz", file=sys.stdout) + sys.exit(1) + + source_archive_path = sys.argv[1] + root_dir = os.path.basename(source_archive_path)[:-len('.tar.gz')] + with tarfile.open(source_archive_path) as tar: + package_json = TextIOWrapper(tar.extractfile(f'{root_dir}/package.json')) + declared_pkgs = read_declared_pkgs(package_json) + + yarn_lock = TextIOWrapper(tar.extractfile(f'{root_dir}/yarn.lock')) + installed_pkgs = read_installed_pkgs(yarn_lock) + + provides = list_provides(declared_pkgs, installed_pkgs) + for provide in sorted(provides): + print(provide) diff --git a/SPECS/grafana-pcp.spec b/SPECS/grafana-pcp.spec new file mode 100644 index 0000000..282b97f --- /dev/null +++ b/SPECS/grafana-pcp.spec @@ -0,0 +1,185 @@ +Name: grafana-pcp +Version: 2.0.2 +Release: 3%{?dist} +Summary: Performance Co-Pilot Grafana Plugin + +%global github https://github.com/performancecopilot/grafana-pcp +%global install_dir %{_sharedstatedir}/grafana/plugins/grafana-pcp + +BuildArch: noarch +ExclusiveArch: %{nodejs_arches} + +License: ASL 2.0 +URL: %{github} + +Source0: %{github}/archive/v%{version}/%{name}-%{version}.tar.gz +Source1: grafana-pcp-deps-%{version}.tar.xz +Source2: create_dependency_bundle.sh +Source3: list_bundled_nodejs_packages.py + +Patch1: 001-fix-empty-container-dashboard.patch +Patch2: 002-add-process-name-and-pid-in-flamegraph-dashboard.patch + +BuildRequires: nodejs +Requires: grafana >= 6.6.0 +Suggests: pcp >= 5.0.0 +Suggests: redis >= 5.0.0 +Suggests: bpftrace >= 0.9.2 + +# Obsolete old webapps +Obsoletes: pcp-webjs <= 4.3.4 +Obsoletes: pcp-webapp-blinkenlights <= 4.3.4 +Obsoletes: pcp-webapp-grafana <= 4.3.4 +Obsoletes: pcp-webapp-graphite <= 4.3.4 +Obsoletes: pcp-webapp-vector <= 4.3.4 + +# Bundled npm packages +Provides: bundled(nodejs-@babel/cli) = 7.8.4 +Provides: bundled(nodejs-@babel/core) = 7.8.4 +Provides: bundled(nodejs-@babel/preset-env) = 7.8.4 +Provides: bundled(nodejs-@babel/preset-react) = 7.8.3 +Provides: bundled(nodejs-@babel/preset-typescript) = 7.8.3 +Provides: bundled(nodejs-@grafana/data) = 6.6.0 +Provides: bundled(nodejs-@grafana/ui) = 6.6.0 +Provides: bundled(nodejs-@types/benchmark) = 1.0.31 +Provides: bundled(nodejs-@types/d3) = 5.7.2 +Provides: bundled(nodejs-@types/grafana) = 4.6.3 +Provides: bundled(nodejs-@types/jest) = 24.9.1 +Provides: bundled(nodejs-@types/lodash) = 4.14.149 +Provides: bundled(nodejs-babel-jest) = 24.9.0 +Provides: bundled(nodejs-babel-loader) = 8.0.6 +Provides: bundled(nodejs-babel-plugin-angularjs-annotate) = 0.10.0 +Provides: bundled(nodejs-benchmark) = 2.1.4 +Provides: bundled(nodejs-clean-webpack-plugin) = 0.1.19 +Provides: bundled(nodejs-copy-webpack-plugin) = 5.1.1 +Provides: bundled(nodejs-core-js) = 1.2.7 +Provides: bundled(nodejs-css-loader) = 1.0.1 +Provides: bundled(nodejs-d3-flame-graph) = 2.1.9 +Provides: bundled(nodejs-d3-selection) = 1.4.0 +Provides: bundled(nodejs-expr-eval) = 1.2.3 +Provides: bundled(nodejs-jest) = 24.9.0 +Provides: bundled(nodejs-jest-date-mock) = 1.0.8 +Provides: bundled(nodejs-jsdom) = 9.12.0 +Provides: bundled(nodejs-lodash) = 4.17.15 +Provides: bundled(nodejs-memoize-one) = 4.1.0 +Provides: bundled(nodejs-mocha) = 6.2.2 +Provides: bundled(nodejs-prunk) = 1.3.1 +Provides: bundled(nodejs-q) = 1.5.1 +Provides: bundled(nodejs-regenerator-runtime) = 0.11.1 +Provides: bundled(nodejs-request) = 2.88.0 +Provides: bundled(nodejs-style-loader) = 0.22.1 +Provides: bundled(nodejs-ts-jest) = 24.3.0 +Provides: bundled(nodejs-ts-loader) = 4.5.0 +Provides: bundled(nodejs-tslint) = 5.20.1 +Provides: bundled(nodejs-tslint-config-airbnb) = 5.11.2 +Provides: bundled(nodejs-typescript) = 3.7.5 +Provides: bundled(nodejs-webpack) = 4.41.5 +Provides: bundled(nodejs-webpack-cli) = 3.3.10 + + +%description +This Grafana plugin for Performance Co-Pilot includes datasources for +scalable time series from pmseries(1) and Redis, live PCP metrics and +bpftrace scripts from pmdabpftrace(1), as well as several dashboards. + +%prep +%setup -q +%setup -q -a 1 +%patch1 -p1 +%patch2 -p1 + +%build +rm -rf dist +./node_modules/webpack/bin/webpack.js --config webpack.config.prod.js + +# webpack/copy-webpack-plugin sometimes outputs files with mode = 666 due to reasons unknown (race condition/umask issue afaics) +chmod -Rf a+rX,u+w,g-w,o-w dist + +%check +./node_modules/jest/bin/jest.js --silent + +%install +install -d -m 755 %{buildroot}/%{install_dir} +cp -a dist/* %{buildroot}/%{install_dir} + +%files +%{install_dir} + +%license LICENSE NOTICE +%doc README.md + +%changelog +* Fri Aug 07 2020 Andreas Gerstmayr 2.0.2-3 +- bpftrace: show process name and PID in flame graphs + +* Fri Jul 24 2020 Andreas Gerstmayr 2.0.2-2 +- vector: do not show all cgroups in the container overview dashboard in case no containers are present on the system + +* Mon May 11 2020 Andreas Gerstmayr 2.0.2-1 +- update to upstream version 2.0.2, see CHANGELOG + +* Tue Jan 28 2020 Andreas Gerstmayr 1.0.5-3 +- redis: pass correct timespec to pmproxy (fixes empty graphs for large time ranges) + +* Tue Jan 07 2020 Andreas Gerstmayr 1.0.5-2 +- redis: support wildcards in metric names +- redis: fix legend and label support + +* Mon Dec 16 2019 Andreas Gerstmayr 1.0.5-1 +- upgrade to upstream 1.0.5 +- flame graphs: clean flame graph stacks every 5s (reduces CPU load) +- general: implement PCP version checks +- redis: set default sample interval to 60s (fixes empty graph borders) + +* Mon Dec 16 2019 Andreas Gerstmayr 1.0.3-2 +- remove node_modules/node-notifier directory from webpack (due to licensing issues) +- upgrade copy-webpack-plugin, terser-webpack-plugin and remove uglifyjs-webpack-plugin to mitigate XSS vulnerability in serialize-javascript dependency + +* Tue Nov 26 2019 Nathan Scott 1.0.3-1 +- fix flame graph dependency (flamegraph.destroy error in javascript console) + +* Tue Nov 12 2019 Andreas Gerstmayr 1.0.2-1 +- handle counter wraps (overflows) +- convert time based counters to time utilization +- flame graphs: aggregate stack counts by selected time range in the Grafana UI +- flame graphs: add option to hide idle stacks +- vector: fix container dropdown in query editor +- vector: remove container setting from datasource settings page +- redis: fix value transformations (e.g. rate conversation of counters) +- request more datapoints from the datasource to fill the borders of the graph panel + +* Fri Oct 11 2019 Andreas Gerstmayr 1.0.0-1 +- bpftrace: support for Flame Graphs +- bpftrace: context-sensitive auto completion for bpftrace probes, builtin variables and functions incl. help texts +- bpftrace: parse output of bpftrace scripts (e.g. using `printf()`) as CSV and display it in the Grafana table panel +- bpftrace: sample dashboards (BPFtrace System Analysis, BPFtrace Flame Graphs) +- vector: table output: show instance name in left column +- vector: table output: support non-matching instance names (cells of metrics which don't have the specific instance will be blank) +- vector & bpftrace: if the metric/script gets changed in the query editor, immeditately stop polling the old metric/deregister the old script +- vector & bpftrace: improve pmwebd compatibility +- misc: help texts for all datasources (visible with the **[ ? ]** button in the query editor) +- misc: renamed PCP Live to PCP Vector +- misc: logos for all datasources +- misc: improved error handling + +* Fri Aug 16 2019 Andreas Gerstmayr 0.0.7-1 +- converted into a Grafana app plugin, renamed to grafana-pcp +- redis: support for instance domains, labels, autocompletion, automatic rate conversation +- live and bpftrace: initial commit of datasources + +* Tue Jun 11 2019 Mark Goodwin 0.0.6-1 +- renamed package to grafana-pcp-redis, updated README, etc + +* Wed Jun 05 2019 Mark Goodwin 0.0.5-1 +- renamed package to grafana-pcp-datasource, README, etc + +* Fri May 17 2019 Mark Goodwin 0.0.4-1 +- add suggested pmproxy URL in config html +- updated instructions and README.md now that grafana is in Fedora + +* Fri Apr 12 2019 Mark Goodwin 0.0.3-1 +- require grafana v6.1.3 or later +- install directory is now below /var/lib/grafana/plugins + +* Wed Mar 20 2019 Mark Goodwin 0.0.2-1 +- initial version