Skip to content
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

feat(dashboard): generate dashboard depending on platform #11996

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
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
Loading