Documentation ¶
Index ¶
Constants ¶
View Source
const (
LogLevelEnvVar = "DASHBOARD_LOG_LEVEL"
)
Variables ¶
View Source
var DeleteCmd = &cobra.Command{ Use: "delete", Short: "Delete Grafana Dashboard", RunE: func(cmd *cobra.Command, args []string) error { return grafana.DeleteDashboard(&grafana.DeleteOptions{ GrafanaURL: cmd.Flag("grafana-url").Value.String(), GrafanaToken: cmd.Flag("grafana-token").Value.String(), Name: cmd.Flag("dashboard-name").Value.String(), }) }, }
View Source
var DeployCmd = &cobra.Command{ Use: "deploy", Short: "Deploy Grafana dashboard and associated alerts", RunE: func(cmd *cobra.Command, args []string) error { alertsTags, errAlertsTags := cmd.Flags().GetStringToString("alerts-tags") if errAlertsTags != nil { return errAlertsTags } var metricsDataSource *grafana.DataSource if cmd.Flag("metrics-datasource").Value.String() != "" { var errMetricsDataSource error metricsDataSource, errMetricsDataSource = grafana.GetDataSourceFromGrafana( cmd.Flag("metrics-datasource").Value.String(), cmd.Flag("grafana-url").Value.String(), cmd.Flag("grafana-token").Value.String(), ) if errMetricsDataSource != nil { return errMetricsDataSource } } var logsDataSource *grafana.DataSource if cmd.Flag("logs-datasource").Value.String() != "" { var errLogsDataSource error logsDataSource, errLogsDataSource = grafana.GetDataSourceFromGrafana( cmd.Flag("logs-datasource").Value.String(), cmd.Flag("grafana-url").Value.String(), cmd.Flag("grafana-token").Value.String(), ) if errLogsDataSource != nil { return errLogsDataSource } } dashboard, err := BuildDashboardWithType(&BuildOptions{ Name: cmd.Flag("dashboard-name").Value.String(), Platform: grafana.TypePlatform(cmd.Flag("platform").Value.String()), TypeDashboard: TypeDashboard(cmd.Flag("type").Value.String()), MetricsDataSource: metricsDataSource, LogsDataSource: logsDataSource, SlackChannel: cmd.Flag("slack-channel").Value.String(), SlackWebhookURL: cmd.Flag("slack-webhook").Value.String(), AlertsTags: alertsTags, AlertsFilters: cmd.Flag("alerts-filters").Value.String(), }) if err != nil { return err } errDeploy := dashboard.DeployToGrafana(&grafana.DeployOptions{ GrafanaURL: cmd.Flag("grafana-url").Value.String(), GrafanaToken: cmd.Flag("grafana-token").Value.String(), FolderName: cmd.Flag("dashboard-folder").Value.String(), EnableAlerts: cmd.Flag("enable-alerts").Value.String() == "true", NotificationTemplates: cmd.Flag("notification-templates").Value.String(), }) if errDeploy != nil { return errDeploy } return nil }, }
View Source
var GenerateCmd = &cobra.Command{ Use: "generate", Short: "Generate Grafana Dashboard JSON", RunE: func(cmd *cobra.Command, args []string) error { dashboard, err := BuildDashboardWithType(&BuildOptions{ Name: cmd.Flag("dashboard-name").Value.String(), Platform: grafana.TypePlatform(cmd.Flag("platform").Value.String()), TypeDashboard: TypeDashboard(cmd.Flag("type").Value.String()), MetricsDataSource: grafana.NewDataSource(cmd.Flag("metrics-datasource").Value.String(), ""), LogsDataSource: grafana.NewDataSource(cmd.Flag("logs-datasource").Value.String(), ""), }) if err != nil { return err } dashboardJSON, errDashboardJSON := dashboard.GenerateJSON() if errDashboardJSON != nil { return errDashboardJSON } fmt.Print(string(dashboardJSON)) return nil }, }
View Source
var (
Logger zerolog.Logger
)
Functions ¶
func BuildDashboardWithType ¶
func BuildDashboardWithType(options *BuildOptions) (*grafana.Observability, error)
Types ¶
type BuildOptions ¶
type BuildOptions struct { Name string Platform grafana.TypePlatform TypeDashboard TypeDashboard MetricsDataSource *grafana.DataSource LogsDataSource *grafana.DataSource SlackChannel string SlackWebhookURL string AlertsTags map[string]string AlertsFilters string }
type OCRVersion ¶
type OCRVersion string
const ( OCRVersionOCR OCRVersion = "ocr" OCRVersionOCR2 OCRVersion = "ocr2" OCRVersionOCR3 OCRVersion = "ocr3" )
type TypeDashboard ¶
type TypeDashboard string
const ( TypeDashboardCoreNode TypeDashboard = "core-node" TypeDashboardCoreNodeComponents TypeDashboard = "core-node-components" TypeDashboardCoreNodeResources TypeDashboard = "core-node-resources" TypeDashboardDONOCR TypeDashboard = "don-ocr" TypeDashboardDONOCR2 TypeDashboard = "don-ocr2" TypeDashboardDONOCR3 TypeDashboard = "don-ocr3" TypeDashboardNOPOCR2 TypeDashboard = "nop-ocr2" TypeDashboardNOPOCR3 TypeDashboard = "nop-ocr3" TypeDashboardCapabilities TypeDashboard = "capabilities" )
Click to show internal directories.
Click to hide internal directories.