Skip to content

feat(cockpit): cli on get cockpit metrics #2968

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

Merged
merged 1 commit into from
Mar 29, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Get the cockpit metrics with the given project ID.

USAGE:
scw cockpit cockpit get-metrics [arg=value ...]

ARGS:
[project-id] Project ID to use. If none is passed the default project ID will be used
[start-date] Start date
[end-date] End date
[metric-name] Metric name

FLAGS:
-h, --help help for get-metrics

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ AVAILABLE COMMANDS:
activate Activate a cockpit
deactivate Deactivate a cockpit
get Get cockpit
get-metrics Get cockpit metrics
reset-grafana Reset Grafana

WORKFLOW COMMANDS:
Expand Down
23 changes: 23 additions & 0 deletions docs/commands/cockpit.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Cockpit API.
- [Activate a cockpit](#activate-a-cockpit)
- [Deactivate a cockpit](#deactivate-a-cockpit)
- [Get cockpit](#get-cockpit)
- [Get cockpit metrics](#get-cockpit-metrics)
- [Reset Grafana](#reset-grafana)
- [Wait for a cockpit to reach a stable state (installation)](#wait-for-a-cockpit-to-reach-a-stable-state-(installation))
- [Contacts management commands](#contacts-management-commands)
Expand Down Expand Up @@ -152,6 +153,28 @@ scw cockpit cockpit get [arg=value ...]



### Get cockpit metrics

Get the cockpit metrics with the given project ID.

**Usage:**

```
scw cockpit cockpit get-metrics [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| project-id | | Project ID to use. If none is passed the default project ID will be used |
| start-date | | Start date |
| end-date | | End date |
| metric-name | | Metric name |



### Reset Grafana

Reset the Grafana of your cockpit associated with the given project ID.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/moby/buildkit v0.11.5
github.com/opencontainers/go-digest v1.0.0
github.com/pkg/errors v0.9.1
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230327160534-01e8b89ed721
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230328152143-e7dd9eaf36ab
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230327160534-01e8b89ed721 h1:sH3/HWBjaFYFuWnmA2biULFcq6KTc1OP3cdz/OPMhAI=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230327160534-01e8b89ed721/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230328152143-e7dd9eaf36ab h1:VCye3DHBTXfYxCi014GkRliIOvKImUBySvyHwIROCaE=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230328152143-e7dd9eaf36ab/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
Expand Down
45 changes: 45 additions & 0 deletions internal/namespaces/cockpit/v1beta1/cockpit_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func GetGeneratedCommands() *core.Commands {
cockpitContact(),
cockpitCockpitActivate(),
cockpitCockpitGet(),
cockpitCockpitGetMetrics(),
cockpitCockpitDeactivate(),
cockpitCockpitResetGrafana(),
cockpitTokenCreate(),
Expand Down Expand Up @@ -144,6 +145,50 @@ func cockpitCockpitGet() *core.Command {
}
}

func cockpitCockpitGetMetrics() *core.Command {
return &core.Command{
Short: `Get cockpit metrics`,
Long: `Get the cockpit metrics with the given project ID.`,
Namespace: "cockpit",
Resource: "cockpit",
Verb: "get-metrics",
// Deprecated: false,
ArgsType: reflect.TypeOf(cockpit.GetCockpitMetricsRequest{}),
ArgSpecs: core.ArgSpecs{
core.ProjectIDArgSpec(),
{
Name: "start-date",
Short: `Start date`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "end-date",
Short: `End date`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "metric-name",
Short: `Metric name`,
Required: false,
Deprecated: false,
Positional: false,
},
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*cockpit.GetCockpitMetricsRequest)

client := core.ExtractClient(ctx)
api := cockpit.NewAPI(client)
return api.GetCockpitMetrics(request)

},
}
}

func cockpitCockpitDeactivate() *core.Command {
return &core.Command{
Short: `Deactivate a cockpit`,
Expand Down