Skip to content

Commit

Permalink
update remotecfg argument name from metadata to attributes (#1090)
Browse files Browse the repository at this point in the history
Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com>
  • Loading branch information
erikbaranowski authored Jun 20, 2024
1 parent c636f0e commit 0681130
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 50 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ internal API changes are not present.
Main (unreleased)
-----------------

### Breaking changes to non-GA functionality

- Update Public preview `remotecfg` argument from `metadata` to `attributes`. (@erikbaranowski)

v1.2.0-rc.0
-----------------

Expand Down
6 changes: 3 additions & 3 deletions docs/sources/reference/config-blocks/remotecfg.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ remotecfg {
}
id = constants.hostname
metadata = {"cluster" = "dev", "namespace" = "otlp-dev"}
attributes = {"cluster" = "dev", "namespace" = "otlp-dev"}
poll_frequency = "5m"
}
```
Expand All @@ -40,14 +40,14 @@ Name | Type | Description
-----------------|----------------------|---------------------------------------------------|-------------|---------
`url` | `string` | The address of the API to poll for configuration. | `""` | no
`id` | `string` | A self-reported ID. | `see below` | no
`metadata` | `map(string)` | A set of self-reported metadata. | `{}` | no
`attributes` | `map(string)` | A set of self-reported attributes. | `{}` | no
`poll_frequency` | `duration` | How often to poll the API for new configuration. | `"1m"` | no

If the `url` is not set, then the service block is a no-op.

If not set, the self-reported `id` that {{< param "PRODUCT_NAME" >}} uses is a randomly generated, anonymous unique ID (UUID) that is stored as an `alloy_seed.json` file in {{< param "PRODUCT_NAME" >}}'s storage path so that it can persist across restarts.

The `id` and `metadata` fields are used in the periodic request sent to the
The `id` and `attributes` fields are used in the periodic request sent to the
remote endpoint so that the API can decide what configuration to serve.

The `poll_frequency` must be set to at least `"10s"`.
Expand Down
13 changes: 13 additions & 0 deletions docs/sources/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ For a complete list of changes to {{< param "FULL_PRODUCT_NAME" >}}, with links

[Changelog]: https://github.com/grafana/alloy/blob/main/CHANGELOG.md

## v1.3

### Breaking change: `remotecfg` block updated argument name from `metadata` to `attributes`

{{< admonition type="note" >}}
This feature is in [Public preview][] and is not covered by {{< param "FULL_PRODUCT_NAME" >}} [backward compatibility][] guarantees.

[Public preview]: https://grafana.com/docs/release-life-cycle/
[backward compatibility]: ../introduction/backward-compatibility/
{{< /admonition >}}

The `remotecfg` block has an updated argument name from `metadata` to `attributes`.

## v1.2

### Breaking change: `remotecfg` block updated for Agent rename
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ require (
github.com/google/renameio/v2 v2.0.0
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1
github.com/grafana/alloy-remote-config v0.0.4
github.com/grafana/alloy-remote-config v0.0.6
github.com/grafana/alloy/syntax v0.1.0
github.com/grafana/beyla v1.6.3
github.com/grafana/catchpoint-prometheus-exporter v0.0.0-20240606062944-e55f3668661d
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,8 @@ github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
github.com/gosnmp/gosnmp v1.37.0 h1:/Tf8D3b9wrnNuf/SfbvO+44mPrjVphBhRtcGg22V07Y=
github.com/gosnmp/gosnmp v1.37.0/go.mod h1:GDH9vNqpsD7f2HvZhKs5dlqSEcAS6s6Qp099oZRCR+M=
github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY=
github.com/grafana/alloy-remote-config v0.0.4 h1:XqpZ5ZmaVc1E1MZwWoQ4pTPtDQq1L2I2TEhN5JpH8nY=
github.com/grafana/alloy-remote-config v0.0.4/go.mod h1:kHE1usYo2WAVCikQkIXuoG1Clz8BSdiz3kF+DZSCQ4k=
github.com/grafana/alloy-remote-config v0.0.6 h1:/GzYu3/QPHRZFeqeeCZWnDMzXbXVkr7tAfrnHGZzreA=
github.com/grafana/alloy-remote-config v0.0.6/go.mod h1:kHE1usYo2WAVCikQkIXuoG1Clz8BSdiz3kF+DZSCQ4k=
github.com/grafana/beyla v1.6.3 h1:Jonwtz2BouJ0A6vgcKZyZ4+zI22LAKDUm+NAD4WbwLI=
github.com/grafana/beyla v1.6.3/go.mod h1:kNi1vKt2ESdoOy84+zq6Z7z67+BqwaMfEngcM/K8yKA=
github.com/grafana/cadvisor v0.0.0-20231110094609-5f7917925dea h1:Q5f5/nJJ0SbusZjA6F6XkJuHDbl2/PqdTGw6wHsuccA=
Expand Down
25 changes: 0 additions & 25 deletions internal/service/remotecfg/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,3 @@ type noopClient struct{}
func (c noopClient) GetConfig(context.Context, *connect.Request[collectorv1.GetConfigRequest]) (*connect.Response[collectorv1.GetConfigResponse], error) {
return nil, errors.New("noop client")
}

// GetCollector returns information about the collector.
func (c noopClient) GetCollector(context.Context, *connect.Request[collectorv1.GetCollectorRequest]) (*connect.Response[collectorv1.Collector], error) {
return nil, errors.New("noop client")
}

// ListCollectors returns information about all collectors.
func (c noopClient) ListCollectors(context.Context, *connect.Request[collectorv1.ListCollectorsRequest]) (*connect.Response[collectorv1.Collectors], error) {
return nil, errors.New("noop client")
}

// CreateCollector registers a new collector.
func (c noopClient) CreateCollector(context.Context, *connect.Request[collectorv1.CreateCollectorRequest]) (*connect.Response[collectorv1.Collector], error) {
return nil, errors.New("noop client")
}

// UpdateCollector updates an existing collector.
func (c noopClient) UpdateCollector(context.Context, *connect.Request[collectorv1.UpdateCollectorRequest]) (*connect.Response[collectorv1.Collector], error) {
return nil, errors.New("noop client")
}

// DeleteCollector deletes an existing collector.
func (c noopClient) DeleteCollector(context.Context, *connect.Request[collectorv1.DeleteCollectorRequest]) (*connect.Response[collectorv1.DeleteCollectorResponse], error) {
return nil, errors.New("noop client")
}
8 changes: 4 additions & 4 deletions internal/service/remotecfg/remotecfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type Options struct {
type Arguments struct {
URL string `alloy:"url,attr,optional"`
ID string `alloy:"id,attr,optional"`
Metadata map[string]string `alloy:"metadata,attr,optional"`
Attributes map[string]string `alloy:"attributes,attr,optional"`
PollFrequency time.Duration `alloy:"poll_frequency,attr,optional"`
HTTPClientConfig *config.HTTPClientConfig `alloy:",squash"`
}
Expand All @@ -86,7 +86,7 @@ type Arguments struct {
func GetDefaultArguments() Arguments {
return Arguments{
ID: alloyseed.Get().UID,
Metadata: make(map[string]string),
Attributes: make(map[string]string),
PollFrequency: 1 * time.Minute,
HTTPClientConfig: config.CloneDefaultHTTPClientConfig(),
}
Expand Down Expand Up @@ -328,8 +328,8 @@ func (s *Service) fetchLocal() {
func (s *Service) getAPIConfig() ([]byte, error) {
s.mut.RLock()
req := connect.NewRequest(&collectorv1.GetConfigRequest{
Id: s.args.ID,
Metadata: s.args.Metadata,
Id: s.args.ID,
Attributes: s.args.Attributes,
})
client := s.asClient
s.mut.RUnlock()
Expand Down
15 changes: 0 additions & 15 deletions internal/service/remotecfg/remotecfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,6 @@ func (ag *collectorClient) GetConfig(ctx context.Context, req *connect.Request[c

panic("getConfigFunc not set")
}
func (ag *collectorClient) GetCollector(context.Context, *connect.Request[collectorv1.GetCollectorRequest]) (*connect.Response[collectorv1.Collector], error) {
return nil, nil
}
func (ag *collectorClient) CreateCollector(context.Context, *connect.Request[collectorv1.CreateCollectorRequest]) (*connect.Response[collectorv1.Collector], error) {
return nil, nil
}
func (ag *collectorClient) UpdateCollector(context.Context, *connect.Request[collectorv1.UpdateCollectorRequest]) (*connect.Response[collectorv1.Collector], error) {
return nil, nil
}
func (ag *collectorClient) DeleteCollector(context.Context, *connect.Request[collectorv1.DeleteCollectorRequest]) (*connect.Response[collectorv1.DeleteCollectorResponse], error) {
return nil, nil
}
func (ag *collectorClient) ListCollectors(context.Context, *connect.Request[collectorv1.ListCollectorsRequest]) (*connect.Response[collectorv1.Collectors], error) {
return nil, nil
}

type serviceController struct {
f *alloy_runtime.Runtime
Expand Down

0 comments on commit 0681130

Please sign in to comment.