Skip to content

Commit 85b9995

Browse files
kalleepkgeckhartrafaelroquetto
authored
alloy rc.2 (#4482)
* Bump walqueue for new LRU cache implementation + disable the metadata cache OOTB (#4472) * Allow passing BEYLA_ env vars (#4473) * Update changelog --------- Co-authored-by: Kyle Eckhart <[email protected]> Co-authored-by: Rafael Roquetto <[email protected]>
1 parent bbdf1fb commit 85b9995

File tree

7 files changed

+104
-20
lines changed

7 files changed

+104
-20
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal API changes are not present.
1010
Main (unreleased)
1111
-----------------
1212

13-
v1.11.0-rc.1
13+
v1.11.0-rc.2
1414
-----------------
1515

1616
### Breaking changes
@@ -152,6 +152,8 @@ v1.11.0-rc.1
152152

153153
- Reduce CPU of `prometheus.write.queue` by eliminating duplicate calls to calculate the protobuf Size. (@kgeckhart)
154154

155+
- Use new cache for metadata cache in `prometheus.write.queue` and support disabling the metadata cache with it disable by default. (@kgeckhart, @dehaansa)
156+
155157
### Bugfixes
156158

157159
- Update `webdevops/go-common` dependency to resolve concurrent map write panic. (@dehaansa)

docs/sources/reference/components/prometheus/prometheus.write.queue.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ The following arguments are supported:
8080
| `flush_interval` | `duration` | How long to wait until sending if `batch_count` isn't triggered. | `"1s"` | no |
8181
| `headers` | `map(secret)` | Custom HTTP headers to add to all requests sent to the server. | | no |
8282
| `max_retry_attempts` | `uint` | Maximum number of retries before dropping the batch. | `0` | no |
83+
| `metadata_cache_enabled` | `bool` | Enables an LRU cache for tracking Metadata to support sparse metadata sending. | `false` | no |
8384
| `metadata_cache_size` | `uint` | Maximum number of metadata entries to keep in cache to track what has been sent. | `1000` | no |
8485
| `protobuf_message` | `string` | Protobuf message format to use for remote write. | `"prometheus.WriteRequest"` | no |
8586
| `proxy_url` | `string` | URL of the HTTP proxy to use for requests. | | no |
@@ -90,7 +91,7 @@ The following arguments are supported:
9091

9192
`protobuf_message` must be `prometheus.WriteRequest` or `io.prometheus.write.v2.Request`. These values represent prometheus remote write protocol versions 1 and 2.
9293

93-
`metadata_cache_size` is only relevant when using `io.prometheus.write.v2.Request`, and is intended to reduce the frequency of metadata sending to reduce overall network traffic.
94+
'metadata_cache_enabled' and `metadata_cache_size` are only relevant when using `io.prometheus.write.v2.Request`, and is intended to reduce the frequency of metadata sending to reduce overall network traffic.
9495
A larger cache_size will consume more memory, but if you are sending many different metrics will also reduce how frequently metadata is sent with samples.
9596

9697
### `basic_auth`

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ require (
8181
github.com/grafana/snowflake-prometheus-exporter v0.0.0-20250627131542-0c2feac3a700
8282
github.com/grafana/tail v0.0.0-20230510142333-77b18831edf0
8383
github.com/grafana/vmware_exporter v0.0.5-beta.0.20250218170317-73398ba08329
84-
github.com/grafana/walqueue v0.0.0-20250916201216-152b1f10cca2
84+
github.com/grafana/walqueue v0.0.0-20250919134944-0471c03aa304
8585
github.com/hashicorp/consul/api v1.32.1
8686
github.com/hashicorp/go-discover v1.1.0
8787
github.com/hashicorp/go-multierror v1.1.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,8 @@ github.com/grafana/vmware_exporter v0.0.5-beta.0.20250218170317-73398ba08329 h1:
11961196
github.com/grafana/vmware_exporter v0.0.5-beta.0.20250218170317-73398ba08329/go.mod h1:Z28219aViNlsLlPvuCnlgHDagRdZBAZ7JOnQg1b3eWg=
11971197
github.com/grafana/walqueue v0.0.0-20250916201216-152b1f10cca2 h1:6HRYKHfWwdIoBF5jvVAYnARFHJiKe+++j1Oxh6A1mNw=
11981198
github.com/grafana/walqueue v0.0.0-20250916201216-152b1f10cca2/go.mod h1:LJm4P3SayTHSbHBYepsAf3WqlY/gwSYQyMs7OLLAi6A=
1199+
github.com/grafana/walqueue v0.0.0-20250919134944-0471c03aa304 h1:0Mllr6XQcAzwxGh/zHQbL/BtVGNRzRmIRBZRHqTiG3E=
1200+
github.com/grafana/walqueue v0.0.0-20250919134944-0471c03aa304/go.mod h1:RokiltsxYrF3qitnIdaFBGLz5UrCo7DZMMoJrrzHyPc=
11991201
github.com/grobie/gomemcache v0.0.0-20230213081705-239240bbc445 h1:FlKQKUYPZ5yDCN248M3R7x8yu2E3yEZ0H7aLomE4EoE=
12001202
github.com/grobie/gomemcache v0.0.0-20230213081705-239240bbc445/go.mod h1:L69/dBlPQlWkcnU76WgcppK5e4rrxzQdi6LhLnK/ytA=
12011203
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=

internal/component/beyla/ebpf/beyla_linux.go

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"sync"
1414
"time"
1515

16+
"github.com/caarlos0/env/v9"
1617
"github.com/grafana/beyla/v2/pkg/beyla"
1718
"github.com/grafana/beyla/v2/pkg/components"
1819
beylaCfg "github.com/grafana/beyla/v2/pkg/config"
@@ -580,6 +581,31 @@ func New(opts component.Options, args Arguments) (*Component, error) {
580581
return c, nil
581582
}
582583

584+
func (c *Component) loadConfig() (*beyla.Config, error) {
585+
c.mut.Lock()
586+
defer c.mut.Unlock()
587+
588+
cfg, err := c.args.Convert()
589+
if err != nil {
590+
return nil, fmt.Errorf("failed to convert arguments: %w", err)
591+
}
592+
593+
if err := env.Parse(cfg); err != nil {
594+
return nil, fmt.Errorf("failed to parse env: %w", err)
595+
}
596+
597+
if cfg.Discovery.SurveyEnabled() {
598+
cfg.Discovery.OverrideDefaultExcludeForSurvey()
599+
}
600+
601+
c.reg = prometheus.NewRegistry()
602+
c.reportHealthy()
603+
604+
cfg.Prometheus.Registry = c.reg
605+
606+
return cfg, nil
607+
}
608+
583609
// Run implements component.Component.
584610
func (c *Component) Run(ctx context.Context) error {
585611
// Add deprecation warnings at the start of Run
@@ -625,18 +651,12 @@ func (c *Component) Run(ctx context.Context) error {
625651
newCtx, cancelFunc := context.WithCancel(ctx)
626652
cancel = cancelFunc
627653

628-
c.mut.Lock()
629-
cfg, err := c.args.Convert()
654+
cfg, err := c.loadConfig()
630655
if err != nil {
631-
level.Error(c.opts.Logger).Log("msg", "failed to convert arguments", "err", err)
656+
level.Error(c.opts.Logger).Log("msg", "failed to load config", "err", err)
632657
c.reportUnhealthy(err)
633-
c.mut.Unlock()
634658
continue
635659
}
636-
c.reg = prometheus.NewRegistry()
637-
c.reportHealthy()
638-
cfg.Prometheus.Registry = c.reg
639-
c.mut.Unlock()
640660

641661
g, launchCtx := errgroup.WithContext(newCtx)
642662
cancelG = g

internal/component/beyla/ebpf/beyla_linux_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/grafana/beyla/v2/pkg/beyla"
1515
"github.com/grafana/beyla/v2/pkg/config"
16+
beylaSvc "github.com/grafana/beyla/v2/pkg/services"
1617
"github.com/stretchr/testify/require"
1718
"go.opentelemetry.io/obi/pkg/export/attributes"
1819
"go.opentelemetry.io/obi/pkg/export/debug"
@@ -1488,3 +1489,56 @@ func TestServices_Convert_SamplerConfig(t *testing.T) {
14881489
})
14891490
}
14901491
}
1492+
1493+
func TestEnvVars(t *testing.T) {
1494+
comp := &Component{
1495+
args: Arguments{
1496+
TracePrinter: "text",
1497+
},
1498+
}
1499+
1500+
t.Setenv("BEYLA_TRACE_PRINTER", "json")
1501+
1502+
cfg, err := comp.loadConfig()
1503+
1504+
require.NoError(t, err)
1505+
require.Equal(t, debug.TracePrinterJSON, cfg.TracePrinter)
1506+
}
1507+
1508+
func TestSurveyDisabled(t *testing.T) {
1509+
comp := &Component{
1510+
args: Arguments{
1511+
TracePrinter: "text",
1512+
},
1513+
}
1514+
1515+
cfg, err := comp.loadConfig()
1516+
1517+
require.NoError(t, err)
1518+
require.False(t, cfg.Discovery.SurveyEnabled())
1519+
require.NotEqual(t, beylaSvc.DefaultExcludeServicesWithSurvey, cfg.Discovery.DefaultExcludeServices)
1520+
require.NotEqual(t, beylaSvc.DefaultExcludeInstrumentWithSurvey, cfg.Discovery.DefaultExcludeInstrument)
1521+
}
1522+
1523+
func TestSurveyEnabled(t *testing.T) {
1524+
comp := &Component{
1525+
args: Arguments{
1526+
TracePrinter: "text",
1527+
Discovery: Discovery{
1528+
Survey: Services{
1529+
{
1530+
Name: "foo",
1531+
},
1532+
},
1533+
},
1534+
},
1535+
}
1536+
1537+
cfg, err := comp.loadConfig()
1538+
1539+
require.NoError(t, err)
1540+
require.Len(t, cfg.Discovery.Survey, 1)
1541+
require.True(t, cfg.Discovery.SurveyEnabled())
1542+
require.Equal(t, beylaSvc.DefaultExcludeServicesWithSurvey, cfg.Discovery.DefaultExcludeServices)
1543+
require.Equal(t, beylaSvc.DefaultExcludeInstrumentWithSurvey, cfg.Discovery.DefaultExcludeInstrument)
1544+
}

internal/component/prometheus/write/queue/types.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import (
44
"fmt"
55
"time"
66

7-
"github.com/grafana/alloy/syntax/alloytypes"
87
"github.com/grafana/walqueue/types"
98
"github.com/prometheus/common/version"
109
"github.com/prometheus/prometheus/config"
1110
"github.com/prometheus/prometheus/storage"
11+
12+
"github.com/grafana/alloy/syntax/alloytypes"
1213
)
1314

1415
func defaultArgs() Arguments {
@@ -46,13 +47,14 @@ func (rc *Arguments) SetToDefault() {
4647

4748
func defaultEndpointConfig() EndpointConfig {
4849
return EndpointConfig{
49-
Timeout: 30 * time.Second,
50-
RetryBackoff: 1 * time.Second,
51-
MaxRetryAttempts: 0,
52-
BatchCount: 1_000,
53-
FlushInterval: 1 * time.Second,
54-
MetadataCacheSize: 1000,
55-
ProtobufMessage: RemoteWriteProtoMsg(config.RemoteWriteProtoMsgV1),
50+
Timeout: 30 * time.Second,
51+
RetryBackoff: 1 * time.Second,
52+
MaxRetryAttempts: 0,
53+
BatchCount: 1_000,
54+
FlushInterval: 1 * time.Second,
55+
MetadataCacheEnabled: false,
56+
MetadataCacheSize: 1000,
57+
ProtobufMessage: RemoteWriteProtoMsg(config.RemoteWriteProtoMsgV1),
5658
Parallelism: ParallelismConfig{
5759
DriftScaleUp: 60 * time.Second,
5860
DriftScaleDown: 30 * time.Second,
@@ -136,7 +138,9 @@ type EndpointConfig struct {
136138
ProxyConnectHeaders map[string]alloytypes.Secret `alloy:"proxy_connect_headers,attr,optional"`
137139
// ProtobufMessage specifies if Remote Write V1 or V2 should be used
138140
ProtobufMessage RemoteWriteProtoMsg `alloy:"protobuf_message,attr,optional"`
139-
// MetadataCacheSize specifies the size of the metadata cache if using Remote Write V2
141+
// MetadataCacheEnabled enables an LRU cache for tracking Metadata to support sparse metadata sending. Only valid if using Remote Write V2.
142+
MetadataCacheEnabled bool `alloy:"metadata_cache_enabled,attr,optional"`
143+
// MetadataCacheSize specifies the size of the metadata cache if using Remote Write V2 with the cache enabled.
140144
MetadataCacheSize int `alloy:"metadata_cache_size,attr,optional"`
141145
}
142146

@@ -212,6 +216,7 @@ func (cc EndpointConfig) ToNativeType() types.ConnectionConfig {
212216
ProxyFromEnvironment: cc.ProxyFromEnvironment,
213217
ProxyConnectHeaders: proxyConnectHeaders,
214218
ProtobufMessage: config.RemoteWriteProtoMsg(cc.ProtobufMessage),
219+
EnableMetadataCache: cc.MetadataCacheEnabled,
215220
MetadataCacheSize: cc.MetadataCacheSize,
216221
Parallelism: types.ParallelismConfig{
217222
AllowedDrift: cc.Parallelism.DriftScaleUp,

0 commit comments

Comments
 (0)