Skip to content

Commit 0985edd

Browse files
authored
Make query look back configurable. (#6)
Rather than a fixed query lookback interval of 15m, make the lookback configurable with a reasonable default.
1 parent 74e84e7 commit 0985edd

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

config.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ type Config struct {
1515
MetricPatterns []string `mapstructure:"metric_patterns"`
1616
ScrapeConcurrency int `mapstructure:"scrape_concurrency"`
1717

18-
// AddLabels configures the receiver to add human-readable labels to metrics using the Oxide API.
18+
// QueryLookback configures the lookback interval of queries
19+
// sent to the Oxide API.
20+
QueryLookback string `mapstructure:"query_lookback"`
21+
22+
// AddLabels configures the receiver to add human-readable labels to
23+
// metrics using the Oxide API.
1924
AddLabels bool `mapstructure:"add_labels"`
2025
}
2126

factory.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func createDefaultConfig() component.Config {
2525
return &Config{
2626
MetricPatterns: []string{".*"},
2727
ScrapeConcurrency: 25,
28+
QueryLookback: "5m",
2829
}
2930
}
3031

scraper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (s *oxideScraper) Scrape(ctx context.Context) (pmetric.Metrics, error) {
131131
latencies := make([]time.Duration, len(s.metricNames))
132132

133133
for idx, metricName := range s.metricNames {
134-
query := fmt.Sprintf("get %s | filter timestamp > @now() - %dm | last 1", metricName, 15)
134+
query := fmt.Sprintf("get %s | filter timestamp > @now() - %s | last 1", metricName, s.cfg.QueryLookback)
135135
group.Go(func() error {
136136
goroStartTime := time.Now()
137137
result, err := s.client.SystemTimeseriesQuery(ctx, oxide.SystemTimeseriesQueryParams{

0 commit comments

Comments
 (0)