File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
internal/command/dashboard Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 99 "github.com/superfly/flyctl/internal/appconfig"
1010 "github.com/superfly/flyctl/internal/command"
1111 "github.com/superfly/flyctl/internal/flag"
12+ "github.com/superfly/flyctl/internal/flyutil"
1213 "github.com/superfly/flyctl/iostreams"
1314)
1415
@@ -44,6 +45,12 @@ func newDashboardMetrics() *cobra.Command {
4445 flag .Add (cmd ,
4546 flag .App (),
4647 flag .AppConfig (),
48+ flag.Bool {
49+ Name : "grafana" ,
50+ Shorthand : "g" ,
51+ Description : "Open Grafana metrics dashboard directly" ,
52+ Default : false ,
53+ },
4754 )
4855 return cmd
4956}
@@ -55,6 +62,18 @@ func runDashboard(ctx context.Context) error {
5562
5663func runDashboardMetrics (ctx context.Context ) error {
5764 appName := appconfig .NameFromContext (ctx )
65+
66+ if flag .GetBool (ctx , "grafana" ) {
67+ client := flyutil .ClientFromContext (ctx )
68+ app , err := client .GetAppBasic (ctx , appName )
69+ if err != nil {
70+ return fmt .Errorf ("failed to get app info: %w" , err )
71+ }
72+
73+ url := fmt .Sprintf ("https://fly-metrics.net/d/fly-app/fly-app?orgId=%s&var-app=%s" , app .Organization .InternalNumericID , appName )
74+ return runDashboardOpen (ctx , url )
75+ }
76+
5877 return runDashboardOpen (ctx , "https://fly.io/apps/" + appName + "/metrics" )
5978}
6079
You can’t perform that action at this time.
0 commit comments