Skip to content

Commit

Permalink
add flag for lowercase resourceids
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Blaschke <[email protected]>
  • Loading branch information
mblaschke committed Aug 28, 2021
1 parent 93f88e1 commit 10bf665
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ type (
ResourceTags []string `long:"azure.resource-tag" env:"AZURE_RESOURCE_TAG" env-delim:" " description:"Azure Resource tags" default:"owner"`
}

Metrics struct {
ResourceIdLowercase bool `long:"metrics.resourceid.lowercase" env:"METRIC_RESOURCEID_LOWERCASE" description:"Publish lowercase Azure Resoruce ID in metrics"`
}

// scrape times
Scrape struct {
Time time.Duration `long:"scrape.time" env:"SCRAPE_TIME" description:"Default scrape time (time.duration)" default:"5m"`
Expand Down
5 changes: 5 additions & 0 deletions metrics_keyvault.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
prometheusCommon "github.com/webdevops/go-prometheus-common"
"strings"
"sync"
"time"
)
Expand Down Expand Up @@ -260,7 +261,11 @@ func (m *MetricsCollectorKeyvault) collectKeyvault(ctx context.Context, logger *
vaultCertificateStatusMetrics := prometheusCommon.NewMetricsList()

vaultUrl := to.String(vault.Properties.VaultURI)

vaultResourceId := to.String(vault.ID)
if opts.Metrics.ResourceIdLowercase {
vaultResourceId = strings.ToLower(vaultResourceId)
}
vaultName := to.String(vault.Name)

entrySecretsCount := float64(0)
Expand Down

0 comments on commit 10bf665

Please sign in to comment.