From 701d87d4c1f80bc807d667332cff6ac8fe306fd2 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Tue, 9 Jul 2024 20:52:11 +0545 Subject: [PATCH] fix: scrapeconfig level global tags on aws and azure scraper --- scrapers/aws/aws.go | 7 +++++++ scrapers/azure/azure.go | 7 +++++++ scrapers/cron.go | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/scrapers/aws/aws.go b/scrapers/aws/aws.go index 701e254e..450efc54 100644 --- a/scrapers/aws/aws.go +++ b/scrapers/aws/aws.go @@ -1769,6 +1769,13 @@ func (aws Scraper) Scrape(ctx api.ScrapeContext) v1.ScrapeResults { Value: lo.FromPtr(awsCtx.Caller.Account), }) + for _, t := range awsConfig.Tags { + (*results)[i].Tags = append((*results)[i].Tags, v1.Tag{ + Name: t.Name, + Value: t.Value, + }) + } + delete((*results)[i].Labels, "name") delete((*results)[i].Labels, "Name") } diff --git a/scrapers/azure/azure.go b/scrapers/azure/azure.go index 4731a3bc..1afd2621 100644 --- a/scrapers/azure/azure.go +++ b/scrapers/azure/azure.go @@ -173,6 +173,13 @@ func (azure Scraper) Scrape(ctx api.ScrapeContext) v1.ScrapeResults { Value: azure.subscriptionName, }) + for _, t := range config.Tags { + results[i].Tags = append(results[i].Tags, v1.Tag{ + Name: t.Name, + Value: t.Value, + }) + } + // Set parents where missing for j, parent := range results[i].Parents { if parent.ExternalID == "" { diff --git a/scrapers/cron.go b/scrapers/cron.go index 36f79156..c9445023 100644 --- a/scrapers/cron.go +++ b/scrapers/cron.go @@ -170,6 +170,10 @@ func scheduleScraperJob(sc api.ScrapeContext) error { return fmt.Errorf("[%s] failed to schedule %v", j.Name, err) } + if sc.Properties().On("scraper.kubernetes.watch.disable") { + return nil + } + for _, config := range sc.ScrapeConfig().Spec.Kubernetes { if len(config.Watch) == 0 { config.Watch = v1.DefaultWatchKinds