Skip to content

Commit

Permalink
Merge branch 'main' into docs/add-telemetry-configuration-table
Browse files Browse the repository at this point in the history
  • Loading branch information
clayton-cornell authored Nov 15, 2023
2 parents bf22149 + 3a28ced commit ff2418d
Show file tree
Hide file tree
Showing 73 changed files with 1,075 additions and 2,615 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
name: Test
strategy:
matrix:
platform: [macos-latest]
platform: [macos-latest-xlarge]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: "1.21.0"
go-version: "1.21"
cache: true
- name: Test
run: make GO_TAGS="nodocker" test
2 changes: 1 addition & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@b77b85c0254bba6789e787844f0585cde1e56320
uses: aquasecurity/trivy-action@2b6a709cf9c4025c5438138008beaddbb02086f0
with:
image-ref: 'grafana/agent:main'
format: 'template'
Expand Down
30 changes: 25 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ Main (unreleased)
- renamed 3 metrics starting with `mysql_perf_schema_transaction_` to start with `mysql_perf_schema_transactions_` to be consistent with column names.
- exposing only server's own stats by matching `MEMBER_ID` with `@@server_uuid` resulting "member_id" label to be dropped.

### Other changes

- Bump `mysqld_exporter` version to v0.15.0. (@marctc)
- Bump `github-exporter` version to 1.0.6. (@marctc)

### Features

- Added a new `stage.decolorize` stage to `loki.process` component which
Expand Down Expand Up @@ -99,8 +94,12 @@ Main (unreleased)

- Added support for unicode strings in `pyroscope.ebpf` python profiles. (@korniltsev)

- Improved resilience of graph evaluation in presence of slow components. (@thampiotr)

### Bugfixes

- Set exit code 1 on grafana-agentctl non-runnable command. (@fgouteroux)

- Fixed an issue where `loki.process` validation for stage `metric.counter` was
allowing invalid combination of configuration options. (@thampiotr)

Expand Down Expand Up @@ -135,6 +134,24 @@ Main (unreleased)

- Updating configuration for `loki.write` no longer drops data. (@thepalbi)

- Fixed a bug in WAL where exemplars were recorded before the first native histogram samples for new series,
resulting in remote write sending the exemplar first and Prometheus failing to ingest it due to missing
series. (@krajorama)

- Fixed an issue in the static config converter where exporter instance values
were not being mapped when translating to flow. (@erikbaranowski)

- Fix a bug which prevented Agent from running `otelcol.exporter.loadbalancing`
with a `routing_key` of `traceID`. (@ptodev)

### Other changes

- Bump `mysqld_exporter` version to v0.15.0. (@marctc)

- Bump `github-exporter` version to 1.0.6. (@marctc)

- Use Go 1.21.4 for builds. (@rfratto)

v0.37.4 (2023-11-06)
-----------------

Expand All @@ -148,6 +165,9 @@ v0.37.4 (2023-11-06)
- Fix a bug where reloading the configuration of a `loki.write` component lead
to a panic. (@tpaschalis)

- Added Kubernetes service resolver to static node's loadbalancing exporter
and to Flow's `otelcol.exporter.loadbalancing`. (@ptodev)

v0.37.3 (2023-10-26)
-----------------

Expand Down
49 changes: 8 additions & 41 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
# The following groups are used to refer to a changing set of users:
# The CODEOWNERS file is used to define ownership of individuals or teams
# outside of the core set of Grafana Agent maintainers.
#
# * @grafana/grafana-agent-core-maintainers: maintainers of type/core issues.
# * @grafana/grafana-agent-signals-maintainers: maintainers of type/signals issues.
# * @grafana/grafana-agent-operator-maintainers: maintainers of type/operator issues.
# * @grafana/grafana-agent-infrastructure-maintainers: maintainers of type/infrastructure issues.
#
# Other users may be listed explicitly if maintainership does not fall into one
# of the above groups.

# The default owners for everything in the repo. Unless a later match takes
# precedence, these owners are requested for review whenever someone opens a
# pull request.
* @grafana/grafana-agent-core-maintainers

# Some directories have shared ownership with the respective owners of the
# specific code for the PR being opened, so there's no CODEOWNERS.
/CHANGELOG.md
/component/all

# Binaries:
/cmd/grafana-agent-operator/ @grafana/grafana-agent-operator-maintainers
# If a directory is not listed here, it is assumed to be owned by the
# @grafana/grafana-agent-maintainers; they are not explicitly listed as
# CODEOWNERS as a GitHub project board is used instead for PR tracking, which
# helps reduce notification noise of the members of that team.

# `make docs` procedure and related workflows are owned by @jdbaldry.
/.github/workflows/publish-technical-documentation-next.yml @jdbaldry
Expand All @@ -30,25 +15,7 @@
/docs/variables.mk @jdbaldry

# Documentation:
/docs/sources/ @clayton-cornell
/docs/sources/ @clayton-cornell

# Components:
/component/discovery/ @grafana/grafana-agent-infrastructure-maintainers
/component/local/ @grafana/grafana-agent-infrastructure-maintainers
/component/loki/ @grafana/grafana-agent-signals-maintainers
/component/loki/source/podlogs/ @grafana/grafana-agent-infrastructure-maintainers
/component/mimir/rules/kubernetes/ @grafana/grafana-agent-infrastructure-maintainers
/component/otelcol/ @grafana/grafana-agent-signals-maintainers
/component/prometheus/ @grafana/grafana-agent-signals-maintainers
/component/prometheus/exporter/ @grafana/grafana-agent-infrastructure-maintainers
/component/prometheus/operator/ @grafana/grafana-agent-operator-maintainers
/component/pyroscope/ @grafana/grafana-agent-profiling-maintainers
/component/remote/ @grafana/grafana-agent-infrastructure-maintainers

# Static mode packages:
/pkg/integrations/ @grafana/grafana-agent-infrastructure-maintainers
/pkg/logs/ @grafana/grafana-agent-signals-maintainers
/pkg/metrics/ @grafana/grafana-agent-signals-maintainers
/pkg/mimir/client/ @grafana/grafana-agent-infrastructure-maintainers
/pkg/operator/ @grafana/grafana-agent-operator-maintainers
/pkg/traces/ @grafana/grafana-agent-signals-maintainers
/component/pyroscope/ @grafana/grafana-agent-profiling-maintainers
2 changes: 1 addition & 1 deletion build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ FROM alpine:3.17 as helm
RUN apk add --no-cache helm

# Dependency: Go and Go dependencies
FROM golang:1.21.3-bullseye as golang
FROM golang:1.21.4-bullseye as golang

# Keep in sync with cmd/grafana-agent-operator/DEVELOPERS.md
ENV CONTROLLER_GEN_VERSION v0.9.2
Expand Down
2 changes: 1 addition & 1 deletion build-image/windows/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM library/golang:1.21.3-windowsservercore-1809
FROM library/golang:1.21.4-windowsservercore-1809

SHELL ["powershell", "-command"]

Expand Down
4 changes: 3 additions & 1 deletion cmd/grafana-agentctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ func main() {
testLogs(),
)

_ = cmd.Execute()
if err := cmd.Execute(); err != nil {
os.Exit(1)
}
}

func configSyncCmd() *cobra.Command {
Expand Down
74 changes: 58 additions & 16 deletions component/otelcol/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,33 @@ type Arguments interface {
DebugMetricsConfig() otelcol.DebugMetricsArguments
}

// TypeSignal is a bit field to indicate which telemetry signals the exporter supports.
type TypeSignal byte

const (
TypeLogs TypeSignal = 1 << iota // 1
TypeMetrics // 2
TypeTraces // 4
)

// TypeAll indicates that the exporter supports all telemetry signals.
const TypeAll = TypeLogs | TypeMetrics | TypeTraces

// SupportsLogs returns true if the exporter supports logs.
func (s TypeSignal) SupportsLogs() bool {
return s&TypeLogs != 0
}

// SupportsMetrics returns true if the exporter supports metrics.
func (s TypeSignal) SupportsMetrics() bool {
return s&TypeMetrics != 0
}

// SupportsTraces returns true if the exporter supports traces.
func (s TypeSignal) SupportsTraces() bool {
return s&TypeTraces != 0
}

// Exporter is a Flow component shim which manages an OpenTelemetry Collector
// exporter component.
type Exporter struct {
Expand All @@ -56,6 +83,10 @@ type Exporter struct {

sched *scheduler.Scheduler
collector *lazycollector.Collector

// Signals which the exporter is able to export.
// Can be logs, metrics, traces or any combination of them.
supportedSignals TypeSignal
}

var (
Expand All @@ -69,7 +100,7 @@ var (
//
// The registered component must be registered to export the
// otelcol.ConsumerExports type, otherwise New will panic.
func New(opts component.Options, f otelexporter.Factory, args Arguments) (*Exporter, error) {
func New(opts component.Options, f otelexporter.Factory, args Arguments, supportedSignals TypeSignal) (*Exporter, error) {
ctx, cancel := context.WithCancel(context.Background())

consumer := lazyconsumer.New(ctx)
Expand All @@ -96,6 +127,8 @@ func New(opts component.Options, f otelexporter.Factory, args Arguments) (*Expor

sched: scheduler.New(opts.Logger),
collector: collector,

supportedSignals: supportedSignals,
}
if err := e.Update(args); err != nil {
return nil, err
Expand Down Expand Up @@ -162,25 +195,34 @@ func (e *Exporter) Update(args component.Arguments) error {
// supported telemetry signals.
var components []otelcomponent.Component

tracesExporter, err := e.factory.CreateTracesExporter(e.ctx, settings, exporterConfig)
if err != nil && !errors.Is(err, otelcomponent.ErrDataTypeIsNotSupported) {
return err
} else if tracesExporter != nil {
components = append(components, tracesExporter)
var tracesExporter otelexporter.Traces
if e.supportedSignals.SupportsTraces() {
tracesExporter, err = e.factory.CreateTracesExporter(e.ctx, settings, exporterConfig)
if err != nil && !errors.Is(err, otelcomponent.ErrDataTypeIsNotSupported) {
return err
} else if tracesExporter != nil {
components = append(components, tracesExporter)
}
}

metricsExporter, err := e.factory.CreateMetricsExporter(e.ctx, settings, exporterConfig)
if err != nil && !errors.Is(err, otelcomponent.ErrDataTypeIsNotSupported) {
return err
} else if metricsExporter != nil {
components = append(components, metricsExporter)
var metricsExporter otelexporter.Metrics
if e.supportedSignals.SupportsMetrics() {
metricsExporter, err = e.factory.CreateMetricsExporter(e.ctx, settings, exporterConfig)
if err != nil && !errors.Is(err, otelcomponent.ErrDataTypeIsNotSupported) {
return err
} else if metricsExporter != nil {
components = append(components, metricsExporter)
}
}

logsExporter, err := e.factory.CreateLogsExporter(e.ctx, settings, exporterConfig)
if err != nil && !errors.Is(err, otelcomponent.ErrDataTypeIsNotSupported) {
return err
} else if logsExporter != nil {
components = append(components, logsExporter)
var logsExporter otelexporter.Logs
if e.supportedSignals.SupportsLogs() {
logsExporter, err = e.factory.CreateLogsExporter(e.ctx, settings, exporterConfig)
if err != nil && !errors.Is(err, otelcomponent.ErrDataTypeIsNotSupported) {
return err
} else if logsExporter != nil {
components = append(components, logsExporter)
}
}

// Schedule the components to run once our component is running.
Expand Down
36 changes: 35 additions & 1 deletion component/otelcol/exporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func newTestEnvironment(t *testing.T, fe *fakeExporter) *testEnvironment {
}, otelcomponent.StabilityLevelUndefined),
)

return exporter.New(opts, factory, args.(exporter.Arguments))
return exporter.New(opts, factory, args.(exporter.Arguments), exporter.TypeAll)
},
}

Expand Down Expand Up @@ -198,3 +198,37 @@ func createTestTraces() ptrace.Traces {
}
return data
}

func TestExporterSignalType(t *testing.T) {
//
// Check if ExporterAll supports all signals
//
require.True(t, exporter.TypeAll.SupportsLogs())
require.True(t, exporter.TypeAll.SupportsMetrics())
require.True(t, exporter.TypeAll.SupportsTraces())

//
// Make sure each of the 3 signals supports itself
//
require.True(t, exporter.TypeLogs.SupportsLogs())
require.True(t, exporter.TypeMetrics.SupportsMetrics())
require.True(t, exporter.TypeTraces.SupportsTraces())

//
// Make sure Logs does not support Metrics and Traces.
//
require.False(t, exporter.TypeLogs.SupportsMetrics())
require.False(t, exporter.TypeLogs.SupportsTraces())

//
// Make sure Metrics does not support Logs and Traces.
//
require.False(t, exporter.TypeMetrics.SupportsLogs())
require.False(t, exporter.TypeMetrics.SupportsTraces())

//
// Make sure Traces does not support Logs and Metrics.
//
require.False(t, exporter.TypeTraces.SupportsLogs())
require.False(t, exporter.TypeTraces.SupportsMetrics())
}
38 changes: 35 additions & 3 deletions component/otelcol/exporter/loadbalancing/loadbalancing.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func init() {

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
fact := loadbalancingexporter.NewFactory()
return exporter.New(opts, fact, args.(Arguments))
//TODO(ptodev): LB exporter cannot yet work with metrics due to a limitation in the Agent:
// https://github.com/grafana/agent/pull/5684
// Once the limitation is removed, we may be able to remove the need for exporter.TypeSignal altogether.
return exporter.New(opts, fact, args.(Arguments), exporter.TypeLogs|exporter.TypeTraces)
},
})
}
Expand Down Expand Up @@ -137,8 +140,9 @@ func (otlpConfig OtlpConfig) Convert() otlpexporter.Config {

// ResolverSettings defines the configurations for the backend resolver
type ResolverSettings struct {
Static *StaticResolver `river:"static,block,optional"`
DNS *DNSResolver `river:"dns,block,optional"`
Static *StaticResolver `river:"static,block,optional"`
DNS *DNSResolver `river:"dns,block,optional"`
Kubernetes *KubernetesResolver `river:"kubernetes,block,optional"`
}

func (resolverSettings ResolverSettings) Convert() loadbalancingexporter.ResolverSettings {
Expand All @@ -154,6 +158,11 @@ func (resolverSettings ResolverSettings) Convert() loadbalancingexporter.Resolve
res.DNS = &dnsResolver
}

if resolverSettings.Kubernetes != nil {
kubernetesResolver := resolverSettings.Kubernetes.Convert()
res.K8sSvc = &kubernetesResolver
}

return res
}

Expand Down Expand Up @@ -199,6 +208,29 @@ func (dnsResolver *DNSResolver) Convert() loadbalancingexporter.DNSResolver {
}
}

// KubernetesResolver defines the configuration for the k8s resolver
type KubernetesResolver struct {
Service string `river:"service,attr"`
Ports []int32 `river:"ports,attr,optional"`
}

var _ river.Defaulter = &KubernetesResolver{}

// SetToDefault implements river.Defaulter.
func (args *KubernetesResolver) SetToDefault() {
if args == nil {
args = &KubernetesResolver{}
}
args.Ports = []int32{4317}
}

func (k8sSvcResolver *KubernetesResolver) Convert() loadbalancingexporter.K8sSvcResolver {
return loadbalancingexporter.K8sSvcResolver{
Service: k8sSvcResolver.Service,
Ports: append([]int32{}, k8sSvcResolver.Ports...),
}
}

// Extensions implements exporter.Arguments.
func (args Arguments) Extensions() map[otelcomponent.ID]otelextension.Extension {
return args.Protocol.OTLP.Client.Extensions()
Expand Down
Loading

0 comments on commit ff2418d

Please sign in to comment.