Skip to content

Commit

Permalink
Override Promtail User-Agent header (#270)
Browse files Browse the repository at this point in the history
* override Loki User-Agent header

Fixes #188

* update CHANGELOG

* revert hacky workaround, no longer needed now that fix in loki is merged

* use prometheus version for setting user-agent header

This avoids the same problem that Loki originally had and allows
downstream importers that use prometheus/common/version to import
the loki package without it overwriting their build info.
  • Loading branch information
rfratto authored Dec 7, 2020
1 parent 1fad2e1 commit 98d0577
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ this platform. FreeBSD builds will return in a future release.
- [BUGFIX] Fix issue where the Tempo example manifest could not be applied
because the port names were too long. (@rfratto)

- [CHANGE] The User-Agent header sent for logs will now be
`GrafanaCloudAgent/<version>` (@rfratto)

# v0.8.0 (2020-11-06)

NOTE: FreeBSD builds will not be included for this release. There is a bug in an
Expand Down
9 changes: 1 addition & 8 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
package build

import (
// We do an empty import of Loki's build package to force it ahead of us on
// the dependency graph. This makes sure that our init function runs after it
// and retains the build info we set at compile time.
_ "github.com/grafana/loki/pkg/build"

"github.com/prometheus/common/version"
)
import "github.com/prometheus/common/version"

// Version information passed to Prometheus version package.
// Package path as used by linker changes based on vendoring being used or not,
Expand Down
6 changes: 6 additions & 0 deletions pkg/loki/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package loki

import (
"flag"
"fmt"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
Expand All @@ -13,8 +14,13 @@ import (
"github.com/grafana/loki/pkg/promtail/scrapeconfig"
"github.com/grafana/loki/pkg/promtail/server"
"github.com/grafana/loki/pkg/promtail/targets/file"
"github.com/prometheus/common/version"
)

func init() {
client.UserAgent = fmt.Sprintf("GrafanaCloudAgent/%s", version.Version)
}

// Config controls the configuration of the Loki log scraper.
type Config struct {
// Whether the Loki subsystem should be enabled.
Expand Down

0 comments on commit 98d0577

Please sign in to comment.