-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(dataobj): Consolidate configuration and add querier support (#…
- Loading branch information
1 parent
ff0da88
commit 1fa952d
Showing
12 changed files
with
1,080 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package config | ||
|
||
import ( | ||
"flag" | ||
|
||
"github.com/grafana/loki/v3/pkg/dataobj/consumer" | ||
"github.com/grafana/loki/v3/pkg/dataobj/querier" | ||
) | ||
|
||
type Config struct { | ||
Consumer consumer.Config `yaml:"consumer"` | ||
Querier querier.Config `yaml:"querier"` | ||
// StorageBucketPrefix is the prefix to use for the storage bucket. | ||
StorageBucketPrefix string `yaml:"storage_bucket_prefix"` | ||
} | ||
|
||
func (cfg *Config) RegisterFlags(f *flag.FlagSet) { | ||
cfg.Consumer.RegisterFlags(f) | ||
cfg.Querier.RegisterFlags(f) | ||
f.StringVar(&cfg.StorageBucketPrefix, "dataobj-storage-bucket-prefix", "dataobj/", "The prefix to use for the storage bucket.") | ||
} | ||
|
||
func (cfg *Config) Validate() error { | ||
if err := cfg.Consumer.Validate(); err != nil { | ||
return err | ||
} | ||
if err := cfg.Querier.Validate(); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package querier | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
|
||
"github.com/prometheus/common/model" | ||
"github.com/prometheus/prometheus/model/labels" | ||
"github.com/thanos-io/objstore" | ||
|
||
"github.com/grafana/loki/v3/pkg/iter" | ||
"github.com/grafana/loki/v3/pkg/logproto" | ||
"github.com/grafana/loki/v3/pkg/logql" | ||
"github.com/grafana/loki/v3/pkg/querier" | ||
"github.com/grafana/loki/v3/pkg/storage/chunk" | ||
storageconfig "github.com/grafana/loki/v3/pkg/storage/config" | ||
"github.com/grafana/loki/v3/pkg/storage/stores/index/stats" | ||
) | ||
|
||
var _ querier.Store = &Store{} | ||
|
||
type Config struct { | ||
Enabled bool `yaml:"enabled" doc:"description=Enable the dataobj querier."` | ||
From storageconfig.DayTime `yaml:"from" doc:"description=The date of the first day of when the dataobj querier should start querying from. In YYYY-MM-DD format, for example: 2018-04-15."` | ||
} | ||
|
||
func (c *Config) RegisterFlags(f *flag.FlagSet) { | ||
f.BoolVar(&c.Enabled, "dataobj-querier-enabled", false, "Enable the dataobj querier.") | ||
f.Var(&c.From, "dataobj-querier-from", "The start time to query from.") | ||
} | ||
|
||
func (c *Config) Validate() error { | ||
if c.Enabled && c.From.ModelTime().Time().IsZero() { | ||
return fmt.Errorf("from is required when dataobj querier is enabled") | ||
} | ||
return nil | ||
} | ||
|
||
type Store struct { | ||
bucket objstore.Bucket | ||
} | ||
|
||
func NewStore(bucket objstore.Bucket) *Store { | ||
return &Store{ | ||
bucket: bucket, | ||
} | ||
} | ||
|
||
// SelectLogs implements querier.Store | ||
func (s *Store) SelectLogs(_ context.Context, _ logql.SelectLogParams) (iter.EntryIterator, error) { | ||
// TODO: Implement | ||
return iter.NoopEntryIterator, nil | ||
} | ||
|
||
// SelectSamples implements querier.Store | ||
func (s *Store) SelectSamples(_ context.Context, _ logql.SelectSampleParams) (iter.SampleIterator, error) { | ||
// TODO: Implement | ||
return iter.NoopSampleIterator, nil | ||
} | ||
|
||
// SelectSeries implements querier.Store | ||
func (s *Store) SelectSeries(_ context.Context, _ logql.SelectLogParams) ([]logproto.SeriesIdentifier, error) { | ||
// TODO: Implement | ||
return []logproto.SeriesIdentifier{}, nil | ||
} | ||
|
||
// LabelValuesForMetricName implements querier.Store | ||
func (s *Store) LabelValuesForMetricName(_ context.Context, _ string, _ model.Time, _ model.Time, _ string, _ string, _ ...*labels.Matcher) ([]string, error) { | ||
// TODO: Implement | ||
return []string{}, nil | ||
} | ||
|
||
// LabelNamesForMetricName implements querier.Store | ||
func (s *Store) LabelNamesForMetricName(_ context.Context, _ string, _ model.Time, _ model.Time, _ string, _ ...*labels.Matcher) ([]string, error) { | ||
// TODO: Implement | ||
return []string{}, nil | ||
} | ||
|
||
// Stats implements querier.Store | ||
func (s *Store) Stats(_ context.Context, _ string, _ model.Time, _ model.Time, _ ...*labels.Matcher) (*stats.Stats, error) { | ||
// TODO: Implement | ||
return &stats.Stats{}, nil | ||
} | ||
|
||
// Volume implements querier.Store | ||
func (s *Store) Volume(_ context.Context, _ string, _ model.Time, _ model.Time, _ int32, _ []string, _ string, _ ...*labels.Matcher) (*logproto.VolumeResponse, error) { | ||
// TODO: Implement | ||
return &logproto.VolumeResponse{}, nil | ||
} | ||
|
||
// GetShards implements querier.Store | ||
func (s *Store) GetShards(_ context.Context, _ string, _ model.Time, _ model.Time, _ uint64, _ chunk.Predicate) (*logproto.ShardsResponse, error) { | ||
// TODO: Implement | ||
return &logproto.ShardsResponse{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.