Skip to content

Commit

Permalink
Onboard Argus scrape configurations (#242)
Browse files Browse the repository at this point in the history
* Onboard Argus Scrape Configs: generate-payload command (#231)

* Initial implementation

* add utils, testing and make command work

* implement function to create default create config

* update help, improve testing and remove verification when job name is not provided

* Improve testing

* address PR comments

* improve variable names

* update command help

* address PR comments

* fix utils testing

* Onboard Argus Scrape Config: create command (#233)

* implement command and testing

* remove TODO

* address PR comments

* address PR comments

* Onboard Argus Scrape Config: delete command (#235)

* delete command implementation and testing

* improve help and log messages

* update help

* address PR comments

* generate docs

* Onboard Argus Scrape Configs: update command (#236)

* delete command implementation and testing

* initial implementation

* finish implementation

* generate docs

* cleanup

* remove json files

* Address PR comments

* generate docs

* add comment about async method

* Onboard Argus scrape config: list and describe commands (#240)

* delete command implementation and testing

* initial implementation

* finish implementation

* remove json files

* list command implementation and testing

* describe command implementation and testing

* verify pointer before dereference

* add config name to confirmation prompt in create cmd

* generate docs

* improve describe output

* improve describe output

* address PR comments

* Merge main (#241)

* Add `argus grafana describe` command (#221)

* Add `argus grafana config describe` command

* Extend command to also show dashboard URL

* Generate docs

* Improve command descriptions

* Adjust function names

* Show initial Grafana credentials in output

* Add example for showing password

* Change to hide-password flag

* Update GitHub actions (#223)

* Implemnt util for Argus grafana configuration commands (#224)

* Add `argus grafana single-sign-on` commands (#228)

* Add argus grafana single-sign-on enable command

* Add argus grafana single-sign-on disable command

* Update docs

* Register disable command and update docs

* Improvements after review

* Add repology packaging status badge to INSTALLATION docs (#215)

* Add argus grafana `public-read-access` commands (#229)

* Copy files from single sign-on

* Adaptations for the public-read-access commands

* Update docs

* Improvements after review

* Move instance ID to argument

* Adapt examples

* Change config handling: only create config file & directory if needed (#214)

* Change config handling: only create config file & directory if needed

* Changes from code review

* Fix config read

* correctly handle f.Close error

* chore(deps): update renovatebot/github-action action to v40.1.9 (#225)

Co-authored-by: Renovate Bot <[email protected]>

* fix(deps): update module github.com/stackitcloud/stackit-sdk-go/services/ske to v0.13.0 (#226)

Co-authored-by: Renovate Bot <[email protected]>

* Improvements for argus grafana commands (#230)

* Add debug error logs (#217)

* add error debug logs to clients

* add error debug logs to refreshToken

* add error debug logs to label fetching

* Update internal/pkg/services/argus/client/client.go

Co-authored-by: Vicente Pinto <[email protected]>

* Update internal/pkg/services/argus/client/client.go

Co-authored-by: Vicente Pinto <[email protected]>

* add error debug logs to flag conversions

* add printer to argus grafana commands

* add debug log to getBearerToken function

* fix debug messages on clients

* Update internal/pkg/flags/flag_to_value.go

Co-authored-by: Vicente Pinto <[email protected]>

* remove obsolete err from the debug messages

* make printer first parameter

* add printer to new argus commands

* Update internal/pkg/auth/user_token_flow.go

Co-authored-by: Vicente Pinto <[email protected]>

* Update internal/cmd/root.go

Co-authored-by: Vicente Pinto <[email protected]>

* fix linting problem

* add string formatting to the printer debug function

* set source in log handler to false

---------

Co-authored-by: Vicente Pinto <[email protected]>

* change order of debug and error logs (#232)

* Output format none (#234)

* Output format none

* Add unit test, move const to print pkg

* Switch usage of const

* Signature (#237)

* update docs for output format none addition (#239)

* merge main

* add error level debug logs to scrape config commands

---------

Co-authored-by: João Palet <[email protected]>
Co-authored-by: GokceGK <[email protected]>
Co-authored-by: Kumm-Kai <[email protected]>
Co-authored-by: stackit-pipeline <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Vicente Pinto <[email protected]>

* fix seg fault on create with no payload (#243)

---------

Co-authored-by: João Palet <[email protected]>
Co-authored-by: GokceGK <[email protected]>
Co-authored-by: Kumm-Kai <[email protected]>
Co-authored-by: stackit-pipeline <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Vicente Pinto <[email protected]>
  • Loading branch information
7 people authored Apr 24, 2024
1 parent ce61281 commit d5a495f
Show file tree
Hide file tree
Showing 26 changed files with 3,430 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/stackit_argus.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ stackit argus [flags]
* [stackit argus grafana](./stackit_argus_grafana.md) - Provides functionality for the Grafana configuration of Argus instances
* [stackit argus instance](./stackit_argus_instance.md) - Provides functionality for Argus instances
* [stackit argus plans](./stackit_argus_plans.md) - Lists all Argus service plans
* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus

38 changes: 38 additions & 0 deletions docs/stackit_argus_scrape-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## stackit argus scrape-config

Provides functionality for scrape configurations in Argus

### Synopsis

Provides functionality for scrape configurations in Argus.

```
stackit argus scrape-config [flags]
```

### Options

```
-h, --help Help for "stackit argus scrape-config"
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty" "none"]
-p, --project-id string Project ID
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
```

### SEE ALSO

* [stackit argus](./stackit_argus.md) - Provides functionality for Argus
* [stackit argus scrape-config create](./stackit_argus_scrape-config_create.md) - Creates a scrape configuration for an Argus instance
* [stackit argus scrape-config delete](./stackit_argus_scrape-config_delete.md) - Deletes a scrape configuration from an Argus instance
* [stackit argus scrape-config describe](./stackit_argus_scrape-config_describe.md) - Shows details of a scrape configuration from an Argus instance
* [stackit argus scrape-config generate-payload](./stackit_argus_scrape-config_generate-payload.md) - Generates a payload to create/update scrape configurations for an Argus instance
* [stackit argus scrape-config list](./stackit_argus_scrape-config_list.md) - Lists all scrape configurations of an Argus instance
* [stackit argus scrape-config update](./stackit_argus_scrape-config_update.md) - Updates a scrape configuration of an Argus instance

55 changes: 55 additions & 0 deletions docs/stackit_argus_scrape-config_create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## stackit argus scrape-config create

Creates a scrape configuration for an Argus instance

### Synopsis

Creates a scrape configuration job for an Argus instance.
The payload can be provided as a JSON string or a file path prefixed with "@".
If no payload is provided, a default payload will be used.
See https://docs.api.stackit.cloud/documentation/argus/version/v1#tag/scrape-config/operation/v1_projects_instances_scrapeconfigs_create for information regarding the payload structure.

```
stackit argus scrape-config create [flags]
```

### Examples

```
Create a scrape configuration on Argus instance "xxx" using default configuration
$ stackit argus scrape-config create
Create a scrape configuration on Argus instance "xxx" using an API payload sourced from the file "./payload.json"
$ stackit argus scrape-config create --payload @./payload.json --instance-id xxx
Create a scrape configuration on Argus instance "xxx" using an API payload provided as a JSON string
$ stackit argus scrape-config create --payload "{...}" --instance-id xxx
Generate a payload with default values, and adapt it with custom values for the different configuration options
$ stackit argus scrape-config generate-payload > ./payload.json
<Modify payload in file, if needed>
$ stackit argus scrape-config create --payload @./payload.json --instance-id xxx
```

### Options

```
-h, --help Help for "stackit argus scrape-config create"
--instance-id string Instance ID
--payload string Request payload (JSON). Can be a string or a file path, if prefixed with "@" (example: @./payload.json). If unset, will use a default payload (you can check it by running "stackit argus scrape-config generate-payload")
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty" "none"]
-p, --project-id string Project ID
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
```

### SEE ALSO

* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus

40 changes: 40 additions & 0 deletions docs/stackit_argus_scrape-config_delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## stackit argus scrape-config delete

Deletes a scrape configuration from an Argus instance

### Synopsis

Deletes a scrape configuration from an Argus instance.

```
stackit argus scrape-config delete JOB_NAME [flags]
```

### Examples

```
Delete a scrape configuration job with name "my-config" from Argus instance "xxx"
$ stackit argus scrape-config delete my-config --instance-id xxx
```

### Options

```
-h, --help Help for "stackit argus scrape-config delete"
--instance-id string Instance ID
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty" "none"]
-p, --project-id string Project ID
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
```

### SEE ALSO

* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus

43 changes: 43 additions & 0 deletions docs/stackit_argus_scrape-config_describe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## stackit argus scrape-config describe

Shows details of a scrape configuration from an Argus instance

### Synopsis

Shows details of a scrape configuration from an Argus instance.

```
stackit argus scrape-config describe JOB_NAME [flags]
```

### Examples

```
Get details of a scrape configuration with name "my-config" from Argus instance "xxx"
$ stackit argus scrape-config describe my-config --instance-id xxx
Get details of a scrape configuration with name "my-config" from Argus instance "xxx" in a table format
$ stackit argus scrape-config describe my-config --output-format pretty
```

### Options

```
-h, --help Help for "stackit argus scrape-config describe"
--instance-id string Instance ID
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty" "none"]
-p, --project-id string Project ID
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
```

### SEE ALSO

* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus

54 changes: 54 additions & 0 deletions docs/stackit_argus_scrape-config_generate-payload.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## stackit argus scrape-config generate-payload

Generates a payload to create/update scrape configurations for an Argus instance

### Synopsis

Generates a JSON payload with values to be used as --payload input for scrape configurations creation or update.
This command can be used to generate a payload to update an existing scrape config or to create a new scrape config job.
To update an existing scrape config job, provide the job name and the instance ID of the Argus instance.
To obtain a default payload to create a new scrape config job, run the command with no flags.
Note that some of the default values provided, such as the job name, the metrics path and URL of the targets, should be adapted to your use case.
See https://docs.api.stackit.cloud/documentation/argus/version/v1#tag/scrape-config/operation/v1_projects_instances_scrapeconfigs_create for information regarding the payload structure.


```
stackit argus scrape-config generate-payload [flags]
```

### Examples

```
Generate a Create payload with default values, and adapt it with custom values for the different configuration options
$ stackit argus scrape-config generate-payload > ./payload.json
<Modify payload in file, if needed>
$ stackit argus scrape-config create my-config --payload @./payload.json
Generate an Update payload with the values of an existing configuration named "my-config" for Argus instance xxx, and adapt it with custom values for the different configuration options
$ stackit argus scrape-config generate-payload --job-name my-config --instance-id xxx > ./payload.json
<Modify payload in file>
$ stackit argus scrape-config update my-config --payload @./payload.json
```

### Options

```
-h, --help Help for "stackit argus scrape-config generate-payload"
--instance-id string Instance ID
-n, --job-name string If set, generates an update payload with the current state of the given scrape config. If unset, generates a create payload with default values
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty" "none"]
-p, --project-id string Project ID
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
```

### SEE ALSO

* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus

47 changes: 47 additions & 0 deletions docs/stackit_argus_scrape-config_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## stackit argus scrape-config list

Lists all scrape configurations of an Argus instance

### Synopsis

Lists all scrape configurations of an Argus instance.

```
stackit argus scrape-config list [flags]
```

### Examples

```
List all scrape configurations of Argus instance "xxx"
$ stackit argus scrape-config list --instance-id xxx
List all scrape configurations of Argus instance "xxx" in JSON format
$ stackit argus scrape-config list --instance-id xxx --output-format json
List up to 10 scrape configurations of Argus instance "xxx"
$ stackit argus scrape-config list --instance-id xxx --limit 10
```

### Options

```
-h, --help Help for "stackit argus scrape-config list"
--instance-id string Instance ID
--limit int Maximum number of entries to list
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty" "none"]
-p, --project-id string Project ID
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
```

### SEE ALSO

* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus

51 changes: 51 additions & 0 deletions docs/stackit_argus_scrape-config_update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## stackit argus scrape-config update

Updates a scrape configuration of an Argus instance

### Synopsis

Updates a scrape configuration of an Argus instance.
The payload can be provided as a JSON string or a file path prefixed with "@".
See https://docs.api.stackit.cloud/documentation/argus/version/v1#tag/scrape-config/operation/v1_projects_instances_scrapeconfigs_update for information regarding the payload structure.

```
stackit argus scrape-config update JOB_NAME [flags]
```

### Examples

```
Update a scrape configuration with name "my-config" from Argus instance "xxx", using an API payload sourced from the file "./payload.json"
$ stackit argus scrape-config update my-config --payload @./payload.json --instance-id xxx
Update an scrape configuration with name "my-config" from Argus instance "xxx", using an API payload provided as a JSON string
$ stackit argus scrape-config update my-config --payload "{...}" --instance-id xxx
Generate a payload with the current values of a scrape configuration, and adapt it with custom values for the different configuration options
$ stackit argus scrape-config generate-payload --job-name my-config > ./payload.json
<Modify payload in file>
$ stackit argus scrape-configs update my-config --payload @./payload.json
```

### Options

```
-h, --help Help for "stackit argus scrape-config update"
--instance-id string Instance ID
--payload string Request payload (JSON). Can be a string or a file path, if prefixed with "@". Example: @./payload.json
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty" "none"]
-p, --project-id string Project ID
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
```

### SEE ALSO

* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus

2 changes: 2 additions & 0 deletions internal/cmd/argus/argus.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/cmd/argus/grafana"
"github.com/stackitcloud/stackit-cli/internal/cmd/argus/instance"
"github.com/stackitcloud/stackit-cli/internal/cmd/argus/plans"
scrapeconfig "github.com/stackitcloud/stackit-cli/internal/cmd/argus/scrape-config"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
Expand All @@ -26,5 +27,6 @@ func NewCmd(p *print.Printer) *cobra.Command {
func addSubcommands(cmd *cobra.Command, p *print.Printer) {
cmd.AddCommand(grafana.NewCmd(p))
cmd.AddCommand(instance.NewCmd(p))
cmd.AddCommand(scrapeconfig.NewCmd(p))
cmd.AddCommand(plans.NewCmd(p))
}
Loading

0 comments on commit d5a495f

Please sign in to comment.