Skip to content

Commit

Permalink
Merge remote-tracking branch 'grafana-agent/main' into sync-grafana-a…
Browse files Browse the repository at this point in the history
…gent
  • Loading branch information
rfratto committed Feb 29, 2024
2 parents c681d22 + b691a44 commit efaa218
Show file tree
Hide file tree
Showing 31 changed files with 623 additions and 140 deletions.
111 changes: 64 additions & 47 deletions .drone/drone.yml

Large diffs are not rendered by default.

55 changes: 21 additions & 34 deletions .drone/pipelines/crosscompile.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local os_arch_tuples = [
// Windows
{ name: 'Windows amd64', os: 'windows', arch: 'amd64' },


// FreeBSD
{ name: 'FreeBSD amd64', os: 'freebsd', arch: 'amd64' },
];
Expand All @@ -37,15 +38,22 @@ local targets = [
local targets_boringcrypto = [
'agent-boringcrypto',
];
local targets_boringcrypto_windows = [
'agent-flow-windows-boringcrypto',
];


local os_arch_types_boringcrypto = [
// Linux boringcrypto
{ name: 'Linux amd64 boringcrypto', os: 'linux', arch: 'amd64', experiment: 'boringcrypto' },
{ name: 'Linux arm64 boringcrypto', os: 'linux', arch: 'arm64', experiment: 'boringcrypto' },
];
local windows_os_arch_types_boringcrypto = [
// Windows boringcrypto
{ name: 'Windows amd64', os: 'windows', arch: 'amd64', experiment: 'cngcrypto' },
];


std.flatMap(function(target) (
local build_environments(targets, tuples, image) = std.flatMap(function(target) (
std.map(function(platform) (
pipelines.linux('Build %s (%s)' % [target, platform.name]) {
local env = {
Expand All @@ -56,47 +64,26 @@ std.flatMap(function(target) (
target: target,

tags: go_tags[platform.os],
},
} + (if 'experiment' in platform then { GOEXPERIMENT: platform.experiment } else { }),

trigger: {
event: ['pull_request'],
},
steps: [{
name: 'Build',
image: build_image.linux,
commands: [
'make generate-ui',
'GO_TAGS="%(tags)s" GOOS=%(GOOS)s GOARCH=%(GOARCH)s GOARM=%(GOARM)s make %(target)s' % env,
],
}],
}
), os_arch_tuples)
), targets) +
std.flatMap(function(target) (
std.map(function(platform) (
pipelines.linux('Build %s (%s)' % [target, platform.name]) {
local env = {
GOOS: platform.os,
GOARCH: platform.arch,
GOARM: if 'arm' in platform then platform.arm else '',
GOEXPERIMENT: platform.experiment,

target: target,

tags: go_tags[platform.os],
},

trigger: {
event: ['pull_request'],
},
steps: [{
name: 'Build',
image: build_image.linux,
image: image,
commands: [
'make generate-ui',
'GO_TAGS="%(tags)s" GOOS=%(GOOS)s GOARCH=%(GOARCH)s GOARM=%(GOARM)s GOEXPERIMENT=%(GOEXPERIMENT)s make %(target)s' % env,
(if 'GOEXPERIMENT' in env
then 'GO_TAGS="%(tags)s" GOOS=%(GOOS)s GOARCH=%(GOARCH)s GOARM=%(GOARM)s GOEXPERIMENT=%(GOEXPERIMENT)s make %(target)s' % env
else 'GO_TAGS="%(tags)s" GOOS=%(GOOS)s GOARCH=%(GOARCH)s GOARM=%(GOARM)s make %(target)s') % env,
],
}],
}
), os_arch_types_boringcrypto)
), targets_boringcrypto)
), tuples)
), targets);

build_environments(targets, os_arch_tuples, build_image.linux) +
build_environments(targets_boringcrypto, os_arch_types_boringcrypto, build_image.linux) +
build_environments(targets_boringcrypto_windows, windows_os_arch_types_boringcrypto, build_image.boringcrypto)
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Main (unreleased)

- A new `loki.rules.kubernetes` component that discovers `PrometheusRule` Kubernetes resources and loads them into a Loki Ruler instance. (@EStork09)

### Bugfixes

- Fix an issues where the logging config block would trigger an error when trying to send logs to components that were not running. (@wildum)

v0.40.0 (2024-02-27)
--------------------

Expand Down Expand Up @@ -51,6 +55,8 @@ v0.40.0 (2024-02-27)

- Add `otelcol.connector.host_info` component to gather usage metrics for cloud users. (@rlankfo, @jcreixell)

- Add Windows boringcrypto build and executable. (@mattdurham)

### Enhancements

- Include line numbers in profiles produced by `pyrsocope.java` component. (@korniltsev)
Expand Down Expand Up @@ -127,6 +133,8 @@ v0.40.0 (2024-02-27)

- Fix an issue where changing the configuration of `loki.write` would cause a panic. (@rfratto)

- Fix issue where registry was not being properly deleted. (@mattdurham)

### Other changes

- Removed support for Windows 2012 in line with Microsoft end of life. (@mattdurham)
Expand Down
23 changes: 16 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
##
## Targets for building binaries:
##
## binaries Compiles all binaries.
## agent Compiles cmd/grafana-agent to $(AGENT_BINARY)
## agent-boringcrypto Compiles cmd/grafana-agent with GOEXPERIMENT=boringcrypto to $(AGENT_BORINGCRYPTO_BINARY)
## agent-flow Compiles cmd/grafana-agent-flow to $(FLOW_BINARY)
## agent-service Compiles cmd/grafana-agent-service to $(SERVICE_BINARY)
## agentctl Compiles cmd/grafana-agentctl to $(AGENTCTL_BINARY)
## operator Compiles cmd/grafana-agent-operator to $(OPERATOR_BINARY)
## binaries Compiles all binaries.
## agent Compiles cmd/grafana-agent to $(AGENT_BINARY)
## agent-boringcrypto Compiles cmd/grafana-agent with GOEXPERIMENT=boringcrypto to $(AGENT_BORINGCRYPTO_BINARY)
## agent-flow Compiles cmd/grafana-agent-flow to $(FLOW_BINARY)
## agent-flow-windows-boringcrypto Compiles cmd/grafana-agent-flow to $(FLOW_BINARY)-windows-boringcrypto
## agent-service Compiles cmd/grafana-agent-service to $(SERVICE_BINARY)
## agentctl Compiles cmd/grafana-agentctl to $(AGENTCTL_BINARY)
## operator Compiles cmd/grafana-agent-operator to $(OPERATOR_BINARY)
##
## Targets for building Docker images:
##
Expand Down Expand Up @@ -98,6 +99,7 @@ AGENTCTL_IMAGE ?= grafana/agentctl:latest
OPERATOR_IMAGE ?= grafana/agent-operator:latest
AGENT_BINARY ?= build/grafana-agent
AGENT_BORINGCRYPTO_BINARY ?= build/grafana-agent-boringcrypto
AGENT_BORINGCRYPTO_WINDOWS_BINARY ?= build/agent-flow-windows-boringcrypto.exe
FLOW_BINARY ?= build/grafana-agent-flow
SERVICE_BINARY ?= build/grafana-agent-service
AGENTCTL_BINARY ?= build/grafana-agentctl
Expand Down Expand Up @@ -192,6 +194,13 @@ else
GOEXPERIMENT=boringcrypto $(GO_ENV) go build $(GO_FLAGS) -o $(AGENT_BORINGCRYPTO_BINARY) ./cmd/grafana-agent
endif

agent-flow-windows-boringcrypto:
ifeq ($(USE_CONTAINER),1)
$(RERUN_IN_CONTAINER)
else
GOEXPERIMENT=cngcrypto $(GO_ENV) go build $(GO_FLAGS) -tags cngcrypto -o $(AGENT_BORINGCRYPTO_WINDOWS_BINARY) ./cmd/grafana-agent-flow
endif


agent-flow:
ifeq ($(USE_CONTAINER),1)
Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agent-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.

FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.4 as build
FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.32.0 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.

FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.4 as build
FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.32.0 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agent/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM grafana/agent-build-image:0.30.4-windows as builder
FROM grafana/agent-build-image:0.32.0-windows as builder
ARG VERSION
ARG RELEASE_BUILD=1

Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agentctl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.

FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.4 as build
FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.32.0 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agentctl/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM grafana/agent-build-image:0.30.4-windows as builder
FROM grafana/agent-build-image:0.32.0-windows as builder
ARG VERSION
ARG RELEASE_BUILD=1

Expand Down
4 changes: 2 additions & 2 deletions component/common/net/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ func (g *GRPCConfig) Into(c *dskit.Config) {
c.GRPCServerMaxConnectionAge = g.MaxConnectionAge
c.GRPCServerMaxConnectionAgeGrace = g.MaxConnectionAgeGrace
c.GRPCServerMaxConnectionIdle = g.MaxConnectionIdle
c.GPRCServerMaxRecvMsgSize = g.ServerMaxRecvMsg
c.GRPCServerMaxRecvMsgSize = g.ServerMaxRecvMsg
c.GRPCServerMaxSendMsgSize = g.ServerMaxSendMsg
c.GPRCServerMaxConcurrentStreams = g.ServerMaxConcurrentStreams
c.GRPCServerMaxConcurrentStreams = g.ServerMaxConcurrentStreams
}

// Convert converts the River-based ServerConfig into a dskit.Config object.
Expand Down
8 changes: 4 additions & 4 deletions component/common/net/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestConfig(t *testing.T) {
require.Equal(t, time.Second*30, config.ServerGracefulShutdownTimeout)

require.Equal(t, size4MB, config.GRPCServerMaxSendMsgSize)
require.Equal(t, size4MB, config.GPRCServerMaxRecvMsgSize)
require.Equal(t, size4MB, config.GRPCServerMaxRecvMsgSize)
},
},
"overriding defaults": {
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestConfig(t *testing.T) {
require.Equal(t, "0.0.0.0", config.GRPCListenAddress)
require.Equal(t, 10, config.GRPCServerMaxSendMsgSize)
// this should have the default applied
require.Equal(t, size4MB, config.GPRCServerMaxRecvMsgSize)
require.Equal(t, size4MB, config.GRPCServerMaxRecvMsgSize)

require.Equal(t, time.Minute, config.ServerGracefulShutdownTimeout)
},
Expand Down Expand Up @@ -141,9 +141,9 @@ func TestConfig(t *testing.T) {
require.Equal(t, 5*time.Minute, config.GRPCServerMaxConnectionAge)
require.Equal(t, 6*time.Minute, config.GRPCServerMaxConnectionAgeGrace)
require.Equal(t, 7*time.Minute, config.GRPCServerMaxConnectionIdle)
require.Equal(t, 5, config.GPRCServerMaxRecvMsgSize)
require.Equal(t, 5, config.GRPCServerMaxRecvMsgSize)
require.Equal(t, 6, config.GRPCServerMaxSendMsgSize)
require.Equal(t, uint(7), config.GPRCServerMaxConcurrentStreams)
require.Equal(t, uint(7), config.GRPCServerMaxConcurrentStreams)
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (s *PushAPIServer) getRelabelRules() []*relabel.Config {
func (s *PushAPIServer) handleLoki(w http.ResponseWriter, r *http.Request) {
logger := util_log.WithContext(r.Context(), util_log.Logger)
userID, _ := tenant.TenantID(r.Context())
req, err := push.ParseRequest(logger, userID, r, nil)
req, err := push.ParseRequest(logger, userID, r, nil, nil, push.ParseLokiRequest)
if err != nil {
level.Warn(s.logger).Log("msg", "failed to parse incoming push request", "err", err.Error())
http.Error(w, err.Error(), http.StatusBadRequest)
Expand Down
35 changes: 35 additions & 0 deletions component/otelcol/config_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,33 @@ var severityLevels = map[SeverityLevel]plog.SeverityNumber{
"FATAL4": 24,
}

var severityNumbers = map[plog.SeverityNumber]SeverityLevel{
1: "TRACE",
2: "TRACE2",
3: "TRACE3",
4: "TRACE4",
5: "DEBUG",
6: "DEBUG2",
7: "DEBUG3",
8: "DEBUG4",
9: "INFO",
10: "INFO2",
11: "INFO3",
12: "INFO4",
13: "WARN",
14: "WARN2",
15: "WARN3",
16: "WARN4",
17: "ERROR",
18: "ERROR2",
19: "ERROR3",
20: "ERROR4",
21: "FATAL",
22: "FATAL2",
23: "FATAL3",
24: "FATAL4",
}

// UnmarshalText implements encoding.TextUnmarshaler for SeverityLevel.
func (sl *SeverityLevel) UnmarshalText(text []byte) error {
agentSevLevelStr := SeverityLevel(text)
Expand All @@ -278,3 +305,11 @@ func (sl *SeverityLevel) UnmarshalText(text []byte) error {
}
return fmt.Errorf("unrecognized severity level %q", string(text))
}

func LookupSeverityNumber(num plog.SeverityNumber) (SeverityLevel, error) {
if lvl, exists := severityNumbers[num]; exists {
return lvl, nil
}

return "", fmt.Errorf("unrecognized severity number %q", num)
}
4 changes: 2 additions & 2 deletions converter/internal/common/weaveworks_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func WeaveWorksServerToFlowServer(config server.Config) *fnet.ServerConfig {
MaxConnectionAge: config.GRPCServerMaxConnectionAge,
MaxConnectionAgeGrace: config.GRPCServerMaxConnectionAgeGrace,
MaxConnectionIdle: config.GRPCServerMaxConnectionIdle,
ServerMaxRecvMsg: config.GPRCServerMaxRecvMsgSize,
ServerMaxRecvMsg: config.GRPCServerMaxRecvMsgSize,
ServerMaxSendMsg: config.GRPCServerMaxSendMsgSize,
ServerMaxConcurrentStreams: config.GPRCServerMaxConcurrentStreams,
ServerMaxConcurrentStreams: config.GRPCServerMaxConcurrentStreams,
},
GracefulShutdownTimeout: config.ServerGracefulShutdownTimeout,
}
Expand Down
24 changes: 24 additions & 0 deletions converter/internal/otelcolconvert/converter_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,27 @@ func encodeMapstruct(v any) map[string]any {
}
return res
}

// encodeMapslice uses mapstruct fields to convert the given argument into a
// []map[string]any. This is useful for being able to convert configuration
// sections for OpenTelemetry components where the configuration type is hidden
// in an internal package.
func encodeMapslice(v any) []map[string]any {
var res []map[string]any
if err := mapstructure.Decode(v, &res); err != nil {
panic(err)
}
return res
}

// encodeString uses mapstruct fields to convert the given argument into a
// string. This is useful for being able to convert configuration
// sections for OpenTelemetry components where the configuration type is hidden
// in an internal package.
func encodeString(v any) string {
var res string
if err := mapstructure.Decode(v, &res); err != nil {
panic(err)
}
return res
}
Loading

0 comments on commit efaa218

Please sign in to comment.