@@ -36,52 +36,52 @@ import "github.com/smartcontractkit/chainlink-common/observability-lib/grafana"
3636
3737func main () {
3838 builder := grafana.NewBuilder (&grafana.BuilderOptions {
39- Name: " Dashboard Name" ,
40- Tags: []string {" tags1" , " tags2" },
41- Refresh: " 30s" ,
42- TimeFrom: " now-30m" ,
43- TimeTo: " now" ,
39+ Name: " Dashboard Name" ,
40+ Tags: []string {" tags1" , " tags2" },
41+ Refresh: " 30s" ,
42+ TimeFrom: " now-30m" ,
43+ TimeTo: " now" ,
4444 })
45-
45+
4646 builder.AddVars (grafana.NewQueryVariable (&grafana.QueryVariableOptions {
47- VariableOption: &grafana.VariableOption {
48- Label: " Environment" ,
49- Name: " env" ,
50- },
51- Datasource: " Prometheus" ,
52- Query: ` label_values(up, env)` ,
47+ VariableOption: &grafana.VariableOption {
48+ Label: " Environment" ,
49+ Name: " env" ,
50+ },
51+ Datasource: " Prometheus" ,
52+ Query: ` label_values(up, env)` ,
5353 }))
54-
54+
5555 builder.AddRow (" Summary" )
56-
56+
5757 builder.AddPanel (grafana.NewStatPanel (&grafana.StatPanelOptions {
58- PanelOptions: &grafana.PanelOptions {
59- Datasource: " Prometheus" ,
60- Title: " Uptime" ,
61- Description: " instance uptime" ,
62- Span: 12 ,
63- Height: 4 ,
64- Decimals: 2 ,
65- Unit: " s" ,
66- Query: []grafana.Query {
67- {
68- Expr: ` uptime_seconds` ,
69- Legend: ` {{ pod }}` ,
70- },
71- },
72- },
73- ColorMode: common.BigValueColorModeNone ,
74- TextMode: common.BigValueTextModeValueAndName ,
75- Orientation: common.VizOrientationHorizontal ,
58+ PanelOptions: &grafana.PanelOptions {
59+ Datasource: " Prometheus" ,
60+ Title: " Uptime" ,
61+ Description: " instance uptime" ,
62+ Span: 12 ,
63+ Height: 4 ,
64+ Decimals: 2 ,
65+ Unit: " s" ,
66+ Query: []grafana.Query {
67+ {
68+ Expr: ` uptime_seconds` ,
69+ Legend: ` {{ pod }}` ,
70+ },
71+ },
72+ },
73+ ColorMode: common.BigValueColorModeNone ,
74+ TextMode: common.BigValueTextModeValueAndName ,
75+ Orientation: common.VizOrientationHorizontal ,
7676 }))
77-
77+
7878 db , err := builder.Build ()
7979 if err != nil {
80- return nil , err
80+ return nil , err
8181 }
8282 json , err := db.GenerateJSON ()
8383 if err != nil {
84- return nil , err
84+ return nil , err
8585 }
8686 fmt.Println (string (json))
8787}
0 commit comments