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

Add the option to configure memory ballast for Loki #5081

Merged
merged 8 commits into from
Jan 10, 2022
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Main

* [5081](https://github.com/grafana/loki/pull/5081) **SasSwart**: Add the option to configure memory ballast for Loki
* [5067](https://github.com/grafana/loki/pull/5057) **cstyan**: Add a metric to Azure Blob Storage client to track total egress bytes
* [4950](https://github.com/grafana/loki/pull/4950) **DylanGuedes**: Implement common instance addr/net interface
* [4949](https://github.com/grafana/loki/pull/4949) **ssncferreira**: Add query `queueTime` metric to statistics and metrics.go
Expand Down
4 changes: 4 additions & 0 deletions cmd/loki/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"reflect"
"runtime"

"github.com/go-kit/log/level"
"github.com/prometheus/common/version"
Expand Down Expand Up @@ -87,6 +88,9 @@ func main() {
}()
}

ballast := make([]byte, config.BallastBytes)
runtime.KeepAlive(ballast)

// Start Loki
t, err := loki.New(config.Config)
util_log.CheckFatal("initialising loki", err)
Expand Down
3 changes: 3 additions & 0 deletions pkg/loki/config_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type ConfigWrapper struct {
LogConfig bool
ConfigFile string
ConfigExpandEnv bool
BallastBytes int
}

func (c *ConfigWrapper) RegisterFlags(f *flag.FlagSet) {
Expand All @@ -46,6 +47,8 @@ func (c *ConfigWrapper) RegisterFlags(f *flag.FlagSet) {
"level with the order reversed, reversing the order makes viewing the entries easier in Grafana.")
f.StringVar(&c.ConfigFile, "config.file", "", "yaml file to load")
f.BoolVar(&c.ConfigExpandEnv, "config.expand-env", false, "Expands ${var} in config according to the values of the environment variables.")
f.IntVar(&c.BallastBytes, "config.ballast-bytes", 0, "The amount of virtual memory to reserve as a ballast in order to optimise "+
"garbage collection.")
c.Config.RegisterFlags(f)
}

Expand Down