Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend /flush to support flushing a single tenant #2260

Merged
merged 4 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* [ENHANCEMENT] Add support for arbitrary arithemtic to TraceQL queries [#2146](https://github.com/grafana/tempo/pull/2146) (@joe-elliott)
* [ENHANCEMENT] tempo-cli: add command to migrate a tenant [#2130](https://github.com/grafana/tempo/pull/2130) (@kvrhdn)
* [ENHANCEMENT] Added the ability to multiple span metrics by an attribute such as `X-SampleRatio` [#2172](https://github.com/grafana/tempo/pull/2172) (@altanozlu)
* [ENHANCEMENT] Extend `/flush` to support flushing a single tenant [#2260](https://github.com/grafana/tempo/pull/2260) (@kvrhdn)
* [BUGFIX] Apply `rate()` to bytes/s panel in tenant's dashboard. [#2081](https://github.com/grafana/tempo/pull/2081) (@mapno)
* [CHANGE] Update Go to 1.20 [#2079](https://github.com/grafana/tempo/pull/2079) (@scalalang2)
* [BUGFIX] Retry copy operations during compaction in GCS backend [#2111](https://github.com/grafana/tempo/pull/2111) (@mapno)
Expand Down
6 changes: 6 additions & 0 deletions docs/sources/tempo/api_docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ GET,POST /flush

Triggers a flush of all in-memory traces to the WAL. Useful at the time of rollout restarts and unexpected crashes.

Specify the `instance` parameter to flush data of a single tenant only.

```
GET,POST /flush?instance=dev
```

### Shutdown

```
Expand Down
20 changes: 17 additions & 3 deletions modules/ingester/flush.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,23 @@ func (i *Ingester) ShutdownHandler(w http.ResponseWriter, _ *http.Request) {
}

// FlushHandler calls sweepAllInstances(true) which will force push all traces into the WAL and force
// mark all head blocks as ready to flush.
func (i *Ingester) FlushHandler(w http.ResponseWriter, _ *http.Request) {
i.sweepAllInstances(true)
// mark all head blocks as ready to flush. It will either flush all instances or if an instance is specified,
// just that one.
func (i *Ingester) FlushHandler(w http.ResponseWriter, r *http.Request) {
queryParamInstance := "instance"

if r.URL.Query().Has(queryParamInstance) {
instance, ok := i.getInstanceByID(r.URL.Query().Get(queryParamInstance))
if !ok {
w.WriteHeader(http.StatusNotFound)
return
}
level.Info(log.Logger).Log("msg", "flushing instance", "instance", instance.instanceID)
i.sweepInstance(instance, true)
} else {
i.sweepAllInstances(true)
}

w.WriteHeader(http.StatusNoContent)
}

Expand Down