Skip to content

Commit

Permalink
feat(dashboard): generate dashboard depending on platform (#11996)
Browse files Browse the repository at this point in the history
* feat(dashboard): generate dashboard depending on platform

* feat(dashboard): depending on platform env var variables and panels adapts

* feat(dashboard): add env var to select panels to be included

* feat(dashboard): delete old file

* feat(dashboard): add panels for solana balance + go metrics panels

* feat(dashboard): prepare wasp integration

* feat(dashboard): add wasp integration

* feat(dashboard): use new wasp version

---------

Co-authored-by: Sergey Kudasov <[email protected]>
  • Loading branch information
Atrax1 and skudasov authored Feb 28, 2024
1 parent fb8b399 commit c033e02
Show file tree
Hide file tree
Showing 6 changed files with 1,974 additions and 3,218 deletions.
74 changes: 50 additions & 24 deletions charts/chainlink-cluster/dashboard/cmd/dashboard_deploy.go
Original file line number Diff line number Diff line change
@@ -1,49 +1,75 @@
package main

import (
"os"

"fmt"
"github.com/smartcontractkit/chainlink/charts/chainlink-cluster/dashboard/dashboard"
"github.com/smartcontractkit/wasp"
"os"
"strings"
)

func main() {
name := os.Getenv("DASHBOARD_NAME")
if name == "" {
panic("DASHBOARD_NAME must be provided")
}
ldsn := os.Getenv("LOKI_DATA_SOURCE_NAME")
if ldsn == "" {
panic("DATA_SOURCE_NAME must be provided")
}
os.Setenv("DATA_SOURCE_NAME", ldsn)
pdsn := os.Getenv("PROMETHEUS_DATA_SOURCE_NAME")
if ldsn == "" {
panic("DATA_SOURCE_NAME must be provided")

lokiDataSourceName := os.Getenv("LOKI_DATA_SOURCE_NAME")
if lokiDataSourceName == "" {
fmt.Println("LOKI_DATA_SOURCE_NAME is empty, panels with logs will be disabled")
}
dbf := os.Getenv("DASHBOARD_FOLDER")
if dbf == "" {
panic("DASHBOARD_FOLDER must be provided")

prometheusDataSourceName := os.Getenv("PROMETHEUS_DATA_SOURCE_NAME")
if prometheusDataSourceName == "" {
panic("PROMETHEUS_DATA_SOURCE_NAME must be provided")
}

grafanaURL := os.Getenv("GRAFANA_URL")
if grafanaURL == "" {
panic("GRAFANA_URL must be provided")
}

grafanaToken := os.Getenv("GRAFANA_TOKEN")
if grafanaToken == "" {
panic("GRAFANA_TOKEN must be provided")
}
// if you'll use this dashboard base in other projects, you can add your own opts here to extend it
db, err := dashboard.NewCLClusterDashboard(6, name, ldsn, pdsn, dbf, grafanaURL, grafanaToken, nil)
if err != nil {
panic(err)

grafanaFolder := os.Getenv("GRAFANA_FOLDER")
if grafanaFolder == "" {
panic("GRAFANA_FOLDER must be provided")
}
// here we are extending load testing dashboard with core metrics, for example
wdb, err := wasp.NewDashboard(nil, db.Opts())
if err != nil {
panic(err)

infraPlatform := os.Getenv("INFRA_PLATFORM")
if infraPlatform == "" {
panic("INFRA_PLATFORM must be provided, can be either docker|kubernetes")
}
if _, err := wdb.Deploy(); err != nil {
panic(err)

panelsIncluded := os.Getenv("PANELS_INCLUDED")
// can be empty
if panelsIncluded == "" {
fmt.Println("PANELS_INCLUDED can be provided to specify panels groups, value must be separated by comma. Possible values are: core, wasp")
}
panelsIncludedArray := strings.Split(panelsIncluded, ",")

err := dashboard.NewDashboard(
name,
grafanaURL,
grafanaToken,
grafanaFolder,
[]string{"generated"},
lokiDataSourceName,
prometheusDataSourceName,
infraPlatform,
panelsIncludedArray,
nil,
)
if err != nil {
fmt.Printf("Could not create dashbard: %s\n", name)
fmt.Printf("Error: %s\n", err)
os.Exit(1)
}
fmt.Printf("Successfully deployed %s dashboard on grafana instance %s in folder %s\n",
name,
grafanaURL,
grafanaFolder,
)
}
Loading

0 comments on commit c033e02

Please sign in to comment.