From 4838314c5f3a1c27e6a4c31b331b0fb9a23fcf28 Mon Sep 17 00:00:00 2001 From: Andre Ziviani Date: Thu, 4 Apr 2024 15:10:09 -0300 Subject: [PATCH] feat: Add hidden flag to inject time on query filter --- exporter/metrics.go | 2 +- main.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/exporter/metrics.go b/exporter/metrics.go index 65edd0b..5ba90ba 100644 --- a/exporter/metrics.go +++ b/exporter/metrics.go @@ -50,7 +50,7 @@ func (m *Metrics) init(ctx context.Context, c *cli.Context) { m.NewHealthClient(ctx) - m.lastScrape = time.Now() + m.lastScrape = time.Now().Add(c.Duration("time-shift")) if len(c.String("slack-token")) > 0 && len(c.String("slack-channel")) > 0 { m.slackToken = c.String("slack-token") diff --git a/main.go b/main.go index 29e06de..d51dabf 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "fmt" "net/http" "os" + "time" "github.com/AndreZiviani/aws-health-exporter/exporter" "github.com/prometheus/client_golang/prometheus" @@ -25,6 +26,8 @@ func main() { &cli.StringFlag{Name: "ignore-events", Usage: "Comma separated list of events to be ignored on all resources"}, &cli.StringFlag{Name: "ignore-resources", Usage: "Comma separated list of resources to be ignored on all events, format is dependant on resource type (some are ARN others are Name, check AWS docs)"}, &cli.StringFlag{Name: "ignore-resource-event", Usage: "Comma separated list of events to be ignored on a specific resource (format: :)"}, + + &cli.DurationFlag{Name: "time-shift", Usage: "[INTERNAL] Apply a time delta to event filter instead of looking at previous scrape", Hidden: true, Value: 0 * time.Second}, } app := &cli.App{