Skip to content

Commit d5a495f

Browse files
DiogoFerraojoaopaletGokceGKKumm-Kaistackit-pipeline
authored
Onboard Argus scrape configurations (#242)
* 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]>
1 parent ce61281 commit d5a495f

26 files changed

+3430
-0
lines changed

docs/stackit_argus.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ stackit argus [flags]
3232
* [stackit argus grafana](./stackit_argus_grafana.md) - Provides functionality for the Grafana configuration of Argus instances
3333
* [stackit argus instance](./stackit_argus_instance.md) - Provides functionality for Argus instances
3434
* [stackit argus plans](./stackit_argus_plans.md) - Lists all Argus service plans
35+
* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus
3536

docs/stackit_argus_scrape-config.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## stackit argus scrape-config
2+
3+
Provides functionality for scrape configurations in Argus
4+
5+
### Synopsis
6+
7+
Provides functionality for scrape configurations in Argus.
8+
9+
```
10+
stackit argus scrape-config [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
-h, --help Help for "stackit argus scrape-config"
17+
```
18+
19+
### Options inherited from parent commands
20+
21+
```
22+
-y, --assume-yes If set, skips all confirmation prompts
23+
--async If set, runs the command asynchronously
24+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
25+
-p, --project-id string Project ID
26+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
27+
```
28+
29+
### SEE ALSO
30+
31+
* [stackit argus](./stackit_argus.md) - Provides functionality for Argus
32+
* [stackit argus scrape-config create](./stackit_argus_scrape-config_create.md) - Creates a scrape configuration for an Argus instance
33+
* [stackit argus scrape-config delete](./stackit_argus_scrape-config_delete.md) - Deletes a scrape configuration from an Argus instance
34+
* [stackit argus scrape-config describe](./stackit_argus_scrape-config_describe.md) - Shows details of a scrape configuration from an Argus instance
35+
* [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
36+
* [stackit argus scrape-config list](./stackit_argus_scrape-config_list.md) - Lists all scrape configurations of an Argus instance
37+
* [stackit argus scrape-config update](./stackit_argus_scrape-config_update.md) - Updates a scrape configuration of an Argus instance
38+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
## stackit argus scrape-config create
2+
3+
Creates a scrape configuration for an Argus instance
4+
5+
### Synopsis
6+
7+
Creates a scrape configuration job for an Argus instance.
8+
The payload can be provided as a JSON string or a file path prefixed with "@".
9+
If no payload is provided, a default payload will be used.
10+
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.
11+
12+
```
13+
stackit argus scrape-config create [flags]
14+
```
15+
16+
### Examples
17+
18+
```
19+
Create a scrape configuration on Argus instance "xxx" using default configuration
20+
$ stackit argus scrape-config create
21+
22+
Create a scrape configuration on Argus instance "xxx" using an API payload sourced from the file "./payload.json"
23+
$ stackit argus scrape-config create --payload @./payload.json --instance-id xxx
24+
25+
Create a scrape configuration on Argus instance "xxx" using an API payload provided as a JSON string
26+
$ stackit argus scrape-config create --payload "{...}" --instance-id xxx
27+
28+
Generate a payload with default values, and adapt it with custom values for the different configuration options
29+
$ stackit argus scrape-config generate-payload > ./payload.json
30+
<Modify payload in file, if needed>
31+
$ stackit argus scrape-config create --payload @./payload.json --instance-id xxx
32+
```
33+
34+
### Options
35+
36+
```
37+
-h, --help Help for "stackit argus scrape-config create"
38+
--instance-id string Instance ID
39+
--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")
40+
```
41+
42+
### Options inherited from parent commands
43+
44+
```
45+
-y, --assume-yes If set, skips all confirmation prompts
46+
--async If set, runs the command asynchronously
47+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
48+
-p, --project-id string Project ID
49+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
50+
```
51+
52+
### SEE ALSO
53+
54+
* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus
55+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## stackit argus scrape-config delete
2+
3+
Deletes a scrape configuration from an Argus instance
4+
5+
### Synopsis
6+
7+
Deletes a scrape configuration from an Argus instance.
8+
9+
```
10+
stackit argus scrape-config delete JOB_NAME [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
Delete a scrape configuration job with name "my-config" from Argus instance "xxx"
17+
$ stackit argus scrape-config delete my-config --instance-id xxx
18+
```
19+
20+
### Options
21+
22+
```
23+
-h, --help Help for "stackit argus scrape-config delete"
24+
--instance-id string Instance ID
25+
```
26+
27+
### Options inherited from parent commands
28+
29+
```
30+
-y, --assume-yes If set, skips all confirmation prompts
31+
--async If set, runs the command asynchronously
32+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
33+
-p, --project-id string Project ID
34+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
35+
```
36+
37+
### SEE ALSO
38+
39+
* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus
40+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## stackit argus scrape-config describe
2+
3+
Shows details of a scrape configuration from an Argus instance
4+
5+
### Synopsis
6+
7+
Shows details of a scrape configuration from an Argus instance.
8+
9+
```
10+
stackit argus scrape-config describe JOB_NAME [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
Get details of a scrape configuration with name "my-config" from Argus instance "xxx"
17+
$ stackit argus scrape-config describe my-config --instance-id xxx
18+
19+
Get details of a scrape configuration with name "my-config" from Argus instance "xxx" in a table format
20+
$ stackit argus scrape-config describe my-config --output-format pretty
21+
```
22+
23+
### Options
24+
25+
```
26+
-h, --help Help for "stackit argus scrape-config describe"
27+
--instance-id string Instance ID
28+
```
29+
30+
### Options inherited from parent commands
31+
32+
```
33+
-y, --assume-yes If set, skips all confirmation prompts
34+
--async If set, runs the command asynchronously
35+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
36+
-p, --project-id string Project ID
37+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
38+
```
39+
40+
### SEE ALSO
41+
42+
* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus
43+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## stackit argus scrape-config generate-payload
2+
3+
Generates a payload to create/update scrape configurations for an Argus instance
4+
5+
### Synopsis
6+
7+
Generates a JSON payload with values to be used as --payload input for scrape configurations creation or update.
8+
This command can be used to generate a payload to update an existing scrape config or to create a new scrape config job.
9+
To update an existing scrape config job, provide the job name and the instance ID of the Argus instance.
10+
To obtain a default payload to create a new scrape config job, run the command with no flags.
11+
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.
12+
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.
13+
14+
15+
```
16+
stackit argus scrape-config generate-payload [flags]
17+
```
18+
19+
### Examples
20+
21+
```
22+
Generate a Create payload with default values, and adapt it with custom values for the different configuration options
23+
$ stackit argus scrape-config generate-payload > ./payload.json
24+
<Modify payload in file, if needed>
25+
$ stackit argus scrape-config create my-config --payload @./payload.json
26+
27+
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
28+
$ stackit argus scrape-config generate-payload --job-name my-config --instance-id xxx > ./payload.json
29+
<Modify payload in file>
30+
$ stackit argus scrape-config update my-config --payload @./payload.json
31+
```
32+
33+
### Options
34+
35+
```
36+
-h, --help Help for "stackit argus scrape-config generate-payload"
37+
--instance-id string Instance ID
38+
-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
39+
```
40+
41+
### Options inherited from parent commands
42+
43+
```
44+
-y, --assume-yes If set, skips all confirmation prompts
45+
--async If set, runs the command asynchronously
46+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
47+
-p, --project-id string Project ID
48+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
49+
```
50+
51+
### SEE ALSO
52+
53+
* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus
54+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## stackit argus scrape-config list
2+
3+
Lists all scrape configurations of an Argus instance
4+
5+
### Synopsis
6+
7+
Lists all scrape configurations of an Argus instance.
8+
9+
```
10+
stackit argus scrape-config list [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
List all scrape configurations of Argus instance "xxx"
17+
$ stackit argus scrape-config list --instance-id xxx
18+
19+
List all scrape configurations of Argus instance "xxx" in JSON format
20+
$ stackit argus scrape-config list --instance-id xxx --output-format json
21+
22+
List up to 10 scrape configurations of Argus instance "xxx"
23+
$ stackit argus scrape-config list --instance-id xxx --limit 10
24+
```
25+
26+
### Options
27+
28+
```
29+
-h, --help Help for "stackit argus scrape-config list"
30+
--instance-id string Instance ID
31+
--limit int Maximum number of entries to list
32+
```
33+
34+
### Options inherited from parent commands
35+
36+
```
37+
-y, --assume-yes If set, skips all confirmation prompts
38+
--async If set, runs the command asynchronously
39+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
40+
-p, --project-id string Project ID
41+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
42+
```
43+
44+
### SEE ALSO
45+
46+
* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus
47+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
## stackit argus scrape-config update
2+
3+
Updates a scrape configuration of an Argus instance
4+
5+
### Synopsis
6+
7+
Updates a scrape configuration of an Argus instance.
8+
The payload can be provided as a JSON string or a file path prefixed with "@".
9+
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.
10+
11+
```
12+
stackit argus scrape-config update JOB_NAME [flags]
13+
```
14+
15+
### Examples
16+
17+
```
18+
Update a scrape configuration with name "my-config" from Argus instance "xxx", using an API payload sourced from the file "./payload.json"
19+
$ stackit argus scrape-config update my-config --payload @./payload.json --instance-id xxx
20+
21+
Update an scrape configuration with name "my-config" from Argus instance "xxx", using an API payload provided as a JSON string
22+
$ stackit argus scrape-config update my-config --payload "{...}" --instance-id xxx
23+
24+
Generate a payload with the current values of a scrape configuration, and adapt it with custom values for the different configuration options
25+
$ stackit argus scrape-config generate-payload --job-name my-config > ./payload.json
26+
<Modify payload in file>
27+
$ stackit argus scrape-configs update my-config --payload @./payload.json
28+
```
29+
30+
### Options
31+
32+
```
33+
-h, --help Help for "stackit argus scrape-config update"
34+
--instance-id string Instance ID
35+
--payload string Request payload (JSON). Can be a string or a file path, if prefixed with "@". Example: @./payload.json
36+
```
37+
38+
### Options inherited from parent commands
39+
40+
```
41+
-y, --assume-yes If set, skips all confirmation prompts
42+
--async If set, runs the command asynchronously
43+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
44+
-p, --project-id string Project ID
45+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
46+
```
47+
48+
### SEE ALSO
49+
50+
* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus
51+

internal/cmd/argus/argus.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/stackitcloud/stackit-cli/internal/cmd/argus/grafana"
55
"github.com/stackitcloud/stackit-cli/internal/cmd/argus/instance"
66
"github.com/stackitcloud/stackit-cli/internal/cmd/argus/plans"
7+
scrapeconfig "github.com/stackitcloud/stackit-cli/internal/cmd/argus/scrape-config"
78
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
89
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
910
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
@@ -26,5 +27,6 @@ func NewCmd(p *print.Printer) *cobra.Command {
2627
func addSubcommands(cmd *cobra.Command, p *print.Printer) {
2728
cmd.AddCommand(grafana.NewCmd(p))
2829
cmd.AddCommand(instance.NewCmd(p))
30+
cmd.AddCommand(scrapeconfig.NewCmd(p))
2931
cmd.AddCommand(plans.NewCmd(p))
3032
}

0 commit comments

Comments
 (0)