Skip to content

Commit

Permalink
Added changes to enable and disable the examplers storage
Browse files Browse the repository at this point in the history
Description: Added changes to enable and disable the examplers storage

Signed-off-by: hiteshwani29 <hiteshwani29@gmail.com>
  • Loading branch information
hiteshwani29 committed Mar 15, 2023
1 parent 2ab0ec2 commit f9f23b3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re

- [#6185](https://github.com/thanos-io/thanos/pull/6185) Tracing: tracing in OTLP support configuring service_name.
- [#6192](https://github.com/thanos-io/thanos/pull/6192) Store: add flag `bucket-web-label` to select the label to use as timeline title in web UI
- [#6216](https://github.com/thanos-io/thanos/pull/6216) Receiver: add flag `tsdb.enable-exemplar-storage` to enable exemplar storage

### Fixed

Expand Down
12 changes: 11 additions & 1 deletion cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ func registerReceive(app *extkingpin.App) {
return errors.Wrap(err, "error while parsing config for request logging")
}

if !conf.tsdbEnableExemplarStorage && conf.tsdbMaxExemplars > 0 {
return errors.New("Enable tsdb.enable-exemplars-storage flag to pass tsdb.max-exemplars ")
}
if conf.tsdbEnableExemplarStorage && conf.tsdbMaxExemplars <= 0 {
return errors.New("tsdb.enable-exemplars-storage flag is enabled, value of tsdb.max-exemplars must be > 0")
}

tsdbOpts := &tsdb.Options{
MinBlockDuration: int64(time.Duration(*conf.tsdbMinBlockDuration) / time.Millisecond),
MaxBlockDuration: int64(time.Duration(*conf.tsdbMaxBlockDuration) / time.Millisecond),
Expand All @@ -85,7 +92,7 @@ func registerReceive(app *extkingpin.App) {
NoLockfile: conf.noLockFile,
WALCompression: conf.walCompression,
MaxExemplars: conf.tsdbMaxExemplars,
EnableExemplarStorage: true,
EnableExemplarStorage: conf.tsdbEnableExemplarStorage,
HeadChunksWriteQueueSize: int(conf.tsdbWriteQueueSize),
EnableMemorySnapshotOnShutdown: conf.tsdbMemorySnapshotOnShutdown,
EnableNativeHistograms: conf.tsdbEnableNativeHistograms,
Expand Down Expand Up @@ -781,6 +788,7 @@ type receiveConfig struct {
tsdbWriteQueueSize int64
tsdbMemorySnapshotOnShutdown bool
tsdbEnableNativeHistograms bool
tsdbEnableExemplarStorage bool

walCompression bool
noLockFile bool
Expand Down Expand Up @@ -879,6 +887,8 @@ func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {

cmd.Flag("tsdb.wal-compression", "Compress the tsdb WAL.").Default("true").BoolVar(&rc.walCompression)

cmd.Flag("tsdb.enable-exemplar-storage", "Enables support for exemplar storage.").Default("false").BoolVar(&rc.tsdbEnableExemplarStorage)

cmd.Flag("tsdb.no-lockfile", "Do not create lockfile in TSDB data directory. In any case, the lockfiles will be deleted on next startup.").Default("false").BoolVar(&rc.noLockFile)

cmd.Flag("tsdb.max-exemplars",
Expand Down
4 changes: 3 additions & 1 deletion docs/components/receive.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ We recommend this component to users who can only push into a Thanos due to air-

Thanos Receive supports multi-tenancy by using labels. See [Multi-tenancy documentation here](../operating/multi-tenancy.md).

Thanos Receive supports ingesting [exemplars](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#exemplars) via remote-write. By default, the exemplars are silently discarded as `--tsdb.max-exemplars` is set to `0`. To enable exemplars storage, set the `--tsdb.max-exemplars` flag to a non-zero value. It exposes the ExemplarsAPI so that the [Thanos Queriers](query.md) can query the stored exemplars. Take a look at the documentation for [exemplars storage in Prometheus](https://prometheus.io/docs/prometheus/latest/disabled_features/#exemplars-storage) to know more about it.
Thanos Receive supports ingesting [exemplars](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#exemplars) via remote-write. By default, the exemplars are silently discarded as `--tsdb.max-exemplars` is set to `0`. To enable exemplars storage, set the `--tsdb.max-exemplars` flag to a non-zero value and enable --tsdb.enable-exemplars-storage flag . It exposes the ExemplarsAPI so that the [Thanos Queriers](query.md) can query the stored exemplars. Take a look at the documentation for [exemplars storage in Prometheus](https://prometheus.io/docs/prometheus/latest/disabled_features/#exemplars-storage) to know more about it.

For more information please check out [initial design proposal](../proposals-done/201812-thanos-remote-receive.md). For further information on tuning Prometheus Remote Write [see remote write tuning document](https://prometheus.io/docs/practices/remote_write/).

Expand Down Expand Up @@ -376,6 +376,8 @@ Flags:
Allow overlapping blocks, which in turn enables
vertical compaction and vertical query merge.
Does not do anything, enabled all the time.
--tsdb.enable-exemplar-storage
Enables support for exemplar storage.
--tsdb.max-exemplars=0 Enables support for ingesting exemplars and
sets the maximum number of exemplars that will
be stored per tenant. In case the exemplar
Expand Down

0 comments on commit f9f23b3

Please sign in to comment.