Skip to content

Commit

Permalink
🐛 Fix: egctl stats invalid format
Browse files Browse the repository at this point in the history
Signed-off-by: bitliu <[email protected]>
  • Loading branch information
Xunzhuo committed Sep 25, 2023
1 parent 67b885d commit f966eaf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions d.json

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions internal/cmd/egctl/envoy_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
)

const (
summaryOutput = "statsd"
prometheusOutput = "prom"
)

Expand Down Expand Up @@ -103,6 +102,12 @@ func newEnvoyStatsCmd() *cobra.Command {
}

switch outputFormat {
case jsonOutput:
statsBytes, err := json.Marshal(stats)
if err != nil {
return err
}
_, _ = fmt.Fprint(c.OutOrStdout(), string(statsBytes))
// convert the json output to yaml
case yamlOutput:
var out []byte
Expand All @@ -124,7 +129,7 @@ func newEnvoyStatsCmd() *cobra.Command {
return nil
},
}
statsConfigCmd.PersistentFlags().StringVarP(&outputFormat, "output", "o", summaryOutput, "Output format: one of json|yaml|prom")
statsConfigCmd.PersistentFlags().StringVarP(&outputFormat, "output", "o", prometheusOutput, "Output format: one of json|yaml|prom")
statsConfigCmd.PersistentFlags().StringVarP(&statsType, "type", "t", "server", "Where to grab the stats: one of server|clusters")
statsConfigCmd.PersistentFlags().StringArrayVarP(&labelSelectors, "labels", "l", nil, "Labels to select the envoy proxy pod.")
statsConfigCmd.PersistentFlags().StringVarP(&podNamespace, "namespace", "n", "envoy-gateway-system", "Namespace where envoy proxy pod are installed.")
Expand Down
6 changes: 4 additions & 2 deletions internal/cmd/egctl/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import (

func statsCommand() *cobra.Command {
c := &cobra.Command{
Use: "stats",
Long: "Retrieve stats from envoy proxy.",
Use: "stats",
Long: "Retrieve Prometheus Stats from envoy proxy.",
Short: "Retrieve stats from envoy proxy.",
Aliases: []string{"proxy"},
}

c.AddCommand(newEnvoyStatsCmd())
Expand Down

0 comments on commit f966eaf

Please sign in to comment.