Skip to content

Commit

Permalink
Permit basic authentication in metrics endpoint (kube-burner#584)
Browse files Browse the repository at this point in the history
## Type of change

- [ ] Refactor
- [x] New feature
- [ ] Bug fix
- [ ] Optimization
- [x] Documentation Update

## Description

Permit basic authentication for metrics endpoint

## Related Tickets & Documents

- Related Issue #
- Closes #

Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 authored Jan 25, 2024
1 parent 207304d commit 0a8b0d5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ A metrics-endpoints.yaml file with valid keys for the `init` command would look
profile: metrics.yaml
alertProfile: alert-profile.yaml
- endpoint: http://remotehost:9090
token: <token>
username: foo
password: bar
```
!!! Note
Expand Down
2 changes: 2 additions & 0 deletions pkg/prometheus/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ type MetricEndpoint struct {
Token string `yaml:"token"`
Profile string `yaml:"profile"`
AlertProfile string `yaml:"alertProfile"`
Username string `yaml:"username"`
Password string `yaml:"password"`
}

type metric struct {
Expand Down
6 changes: 4 additions & 2 deletions pkg/util/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ func ProcessMetricsScraperConfig(metricsScraperConfig ScraperConfig) Scraper {
Token: metricsScraperConfig.Token,
Profile: metricsScraperConfig.MetricsProfile,
AlertProfile: metricsScraperConfig.AlertProfile,
Username: metricsScraperConfig.Username,
Password: metricsScraperConfig.Password,
})
}
}
for _, metricsEndpoint := range metricsEndpoints {
auth := prometheus.Auth{
Username: metricsScraperConfig.Username,
Password: metricsScraperConfig.Password,
Username: metricsEndpoint.Username,
Password: metricsEndpoint.Password,
Token: metricsEndpoint.Token,
SkipTLSVerify: metricsScraperConfig.SkipTLSVerify,
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/workloads/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ func (wh *WorkloadHelper) Run(workload string, metricsProfiles []string, alertsP
auth := prometheus.Auth{
Token: metricsEndpoint.Token,
SkipTLSVerify: true,
Username: metricsEndpoint.Username,
Password: metricsEndpoint.Password,
}
p, err := prometheus.NewPrometheusClient(ConfigSpec, metricsEndpoint.Endpoint, auth, stepSize, wh.MetricsMetadata, indexer, embedConfig)
if err != nil {
Expand Down

0 comments on commit 0a8b0d5

Please sign in to comment.