#!/bin/bash # Grafana OSS bootstrap for the apm-wo-analysis dashboard host (Amazon Linux 2023, # ARM64). Idempotent enough to re-run. Config + dashboards are pulled from S3 # (the repo is the source of truth); a systemd timer re-syncs dashboards so panel # updates ship by re-uploading to S3 — no instance rebuild. set -euxo pipefail CONFIG_BUCKET="${config_bucket}" CONFIG_PREFIX="${config_prefix}" PLUGIN_VERSION="${plugin_version}" GRAFANA_DOMAIN="${grafana_domain}" cat >/etc/yum.repos.d/grafana.repo <<'REPO' [grafana] name=grafana baseurl=https://rpm.grafana.com repo_gpgcheck=1 enabled=1 gpgcheck=1 gpgkey=https://rpm.grafana.com/gpg.key sslverify=1 REPO dnf install -y grafana grafana-cli --homepath=/usr/share/grafana --pluginsDir=/var/lib/grafana/plugins \ plugins install grafana-athena-datasource "$${PLUGIN_VERSION}" cat >/etc/grafana/grafana.ini </usr/local/bin/grafana-config-sync.sh </etc/systemd/system/grafana-config-sync.service <<'SVC' [Unit] Description=Sync apm-wo Grafana config/dashboards from S3 [Service] Type=oneshot ExecStart=/usr/local/bin/grafana-config-sync.sh SVC cat >/etc/systemd/system/grafana-config-sync.timer <<'TIMER' [Unit] Description=Periodic apm-wo Grafana config sync [Timer] OnBootSec=5min OnUnitActiveSec=15min [Install] WantedBy=timers.target TIMER systemctl daemon-reload systemctl enable --now grafana-config-sync.timer