Skip to content

Migrate dynamic scripted Grafana Dashboards to Scenes #7927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions infrastructure/cdn-in-a-box/optional/grafana/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ RUN npm install

COPY optional/grafana/trafficcontrol-scenes/ ./

# COPY ../../misc/logos/ATC-PNG.png ./img/logo-atc.svg

RUN npm run build

FROM grafana/grafana:10.2.3-ubuntu
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/cdn-in-a-box/traffic_stats/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ RUN if [[ "${RHEL_VERSION%%.*}" -eq 7 ]]; then \
yum -y install dnf || exit 1; \
fi

RUN set -o pipefail && \
curl -sLf https://rpm.nodesource.com/setup_16.x | bash

RUN dnf install -y epel-release && \
dnf install -y \
jq \
nodejs \
nmap-ncat \
net-tools \
# find is required by to-access.sh
Expand Down
3 changes: 3 additions & 0 deletions infrastructure/docker/build/Dockerfile-traffic_stats
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-* && \
### traffic_stats specific requirements
FROM common-dependencies AS traffic-stats

RUN curl -sL https://rpm.nodesource.com/setup_20.x | bash - && \
yum -y install nodejs

COPY GO_VERSION /
RUN set -o nounset -o errexit; \
rpm_arch="$(rpm --eval %_arch)" && \
Expand Down
1 change: 1 addition & 0 deletions infrastructure/docker/build/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ services:
- linux/arm64
volumes:
- ../../..:/trafficcontrol:z
- ../../../.npm:/root/.npm:z

grove_build:
image: apache/traffic_grove_builder:master
Expand Down
9 changes: 8 additions & 1 deletion traffic_stats/build/build_rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ initBuildArea() {
go build -v -gcflags "$gcflags" -ldflags "$ldflags" create/create_ts_databases.go || \
{ echo "Could not build create_ts_databases binary"; return 1; })

# compile trafficcontrol-scenes
echo "Installing npm dependencies"
(cd trafficcontrol-scenes
npm i || \
{ echo "Could not install packages from $TS_DIR/trafficcontrol-scenes: $?"; return 1; }
)

rsync -aLv ./ "$ts_dest"/ || \
{ echo "Could not copy to $ts_dest: $?"; return 1; }
cp "$TS_DIR"/build/*.spec "$RPMBUILD"/SPECS/. || \
Expand All @@ -103,6 +110,6 @@ preBuildChecks() {

importFunctions
preBuildChecks
checkEnvironment -i go,rsync
checkEnvironment -i npm,go,rsync
initBuildArea
buildRpm traffic_stats
13 changes: 13 additions & 0 deletions traffic_stats/build/traffic_stats.spec
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Group: Applications/Communications
License: Apache License, Version 2.0
URL: https://github.com/apache/trafficcontrol
Source: %{_sourcedir}/traffic_stats-%{traffic_control_version}.tgz
AutoReqProv: no
Requires: nodejs >= 20.0.0

%description
Installs traffic_stats which performs the follwing functions:
Expand All @@ -50,6 +52,13 @@ godir=src/github.com/apache/trafficcontrol/traffic_stats/influxdb_tools
cp -R "$TC_DIR"/traffic_stats/influxdb_tools/* .
) || { echo "Could not copy go program at $(pwd): $!"; exit 1; }

# build trafficcontrol-scenes
scenesdir=src/github.com/apache/trafficcontrol/traffic_stats/trafficcontrol-scenes
( mkdir -p "$scenesdir" && \
cd "$scenesdir" && \
npm run build
) || { echo "Could not copy trafficcontrol-scenes at $(pwd): $!"; exit 1; }

%install
mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_stats
mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_stats/bin
Expand All @@ -60,13 +69,15 @@ mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_stats/var/run
mkdir -p "${RPM_BUILD_ROOT}"/opt/traffic_stats/var/log/traffic_stats
mkdir -p "${RPM_BUILD_ROOT}"/etc/init.d
mkdir -p "${RPM_BUILD_ROOT}"/etc/logrotate.d
mkdir -p "${RPM_BUILD_ROOT}"/var/lib/grafana/plugins/trafficcontrol-scenes-app

src=src/github.com/apache/trafficcontrol/traffic_stats
cp -p "$src"/traffic_stats "${RPM_BUILD_ROOT}"/opt/traffic_stats/bin/traffic_stats
cp "$src"/traffic_stats.cfg "${RPM_BUILD_ROOT}"/opt/traffic_stats/conf/traffic_stats.cfg
cp "$src"/traffic_stats_seelog.xml "${RPM_BUILD_ROOT}"/opt/traffic_stats/conf/traffic_stats_seelog.xml
cp "$src"/traffic_stats.init "${RPM_BUILD_ROOT}"/etc/init.d/traffic_stats
cp "$src"/traffic_stats.logrotate "${RPM_BUILD_ROOT}"/etc/logrotate.d/traffic_stats
cp -r "$src"/trafficcontrol-scenes/dist/* "${RPM_BUILD_ROOT}"/var/lib/grafana/plugins/trafficcontrol-scenes-app/
cp "$src"/influxdb_tools/sync_ts_databases "${RPM_BUILD_ROOT}"/opt/traffic_stats/influxdb_tools/
cp "$src"/influxdb_tools/create_ts_databases "${RPM_BUILD_ROOT}"/opt/traffic_stats/influxdb_tools/

Expand Down Expand Up @@ -123,10 +134,12 @@ fi
%dir /opt/traffic_stats/var/log
%dir /opt/traffic_stats/var/run
%dir /opt/traffic_stats/var/log/traffic_stats
%dir /var/lib/grafana/plugins/trafficcontrol-scenes-app
%dir /opt/traffic_stats/influxdb_tools

%attr(755, traffic_stats, traffic_stats) /opt/traffic_stats/bin/traffic_stats
%attr(755, traffic_stats, traffic_stats) /etc/init.d/traffic_stats
%attr(644, traffic_stats, traffic_stats) /var/lib/grafana/plugins/trafficcontrol-scenes-app
%attr(755, traffic_stats, traffic_stats) /opt/traffic_stats/influxdb_tools/create_ts_databases
%attr(755, traffic_stats, traffic_stats) /opt/traffic_stats/influxdb_tools/sync_ts_databases

Expand Down