Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions framework/.changeset/v0.13.5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix local dashboards load, bump Grafana version
36 changes: 31 additions & 5 deletions framework/observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"fmt"
"io/fs"
"os"
"os/exec"
"path/filepath"
"strings"
)

//go:embed observability/*
//go:embed observability
var EmbeddedObservabilityFiles embed.FS

const (
Expand All @@ -24,16 +25,38 @@ const (
LocalPostgresDebugURL = "http://localhost:3000/d/000000039/postgresql-database?orgId=1&refresh=5s&var-DS_PROMETHEUS=PBFA97CFB590B2093&var-interval=$__auto_interval_interval&var-namespace=&var-release=&var-instance=postgres_exporter_0:9187&var-datname=All&var-mode=All&from=now-15m&to=now"
LocalPyroScopeURL = "http://localhost:4040/?query=process_cpu%3Acpu%3Ananoseconds%3Acpu%3Ananoseconds%7Bservice_name%3D%22chainlink-node%22%7D&from=now-15m"

CTFCacheDir = ".local/share/ctf"
CTFObservabilityCacheDir = ".local/share/ctf"
CTFLocalDashboardsDirRelative = "dashboards"
)

// copyLocalDashboards syncs local dashboards to CTF observability cache dir
func copyLocalDashboards(obsDir string) error {
wd, _ := os.Getwd()
localDir := filepath.Join(wd, CTFLocalDashboardsDirRelative)
L.Info().
Str("From", localDir).
Str("To", obsDir).
Msg("Copying local dashboards")
cmd := exec.Command(
"cp",
"-r",
localDir,
obsDir,
)
err := cmd.Run()
if err != nil {
return fmt.Errorf("failed to sync local dashboard dirs, from %s to %s, error: %w", localDir, obsDir, err)
}
return nil
}

// getObservabilityDir returns the fixed directory where observability files are extracted
func getObservabilityDir() (string, error) {
homeDir, err := os.UserHomeDir()
if err != nil {
return "", fmt.Errorf("failed to get home directory: %w", err)
}
return filepath.Join(homeDir, CTFCacheDir), nil
return filepath.Join(homeDir, CTFObservabilityCacheDir), nil
}

// extractAllFiles goes through the embedded directory and extracts all files to the fixed observability directory
Expand Down Expand Up @@ -86,8 +109,11 @@ func extractAllFiles(embeddedDir string) error {
}
return nil
})

return err
if err != nil {
return err
}
// copy dashboards from a local dir to CTF cache dir
return copyLocalDashboards(obsDir)
}

func BlockScoutUp(url, chainID string) error {
Expand Down
2 changes: 1 addition & 1 deletion framework/observability/compose/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ services:
- -ruler.storage.local.directory=/etc/loki/rules

grafana:
image: grafana/grafana:10.1.0
image: grafana/grafana:12.3.1
environment:
- GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=grafana-pyroscope-app
volumes:
Expand Down
3 changes: 0 additions & 3 deletions framework/observability/dashboards/dummy.json

This file was deleted.

Loading