Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-thisisbud authored May 14, 2024
2 parents 842a156 + dd1ccf6 commit 9f1c5c2
Show file tree
Hide file tree
Showing 38 changed files with 1,395 additions and 158 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,21 @@ internal API changes are not present.
Main (unreleased)
-----------------

### Breaking changes to non-GA functionality

- Update Public preview `remotecfg` to use `alloy-remote-config` instead of `agent-remote-config`. The
API has been updated to use the term `collector` over `agent`. (@erikbaranowski)

### Bugfixes


- Fixed an issue with `prometheus.scrape` in which targets that move from one
cluster instance to another could have a staleness marker inserted and result
in a gap in metrics (@thampiotr)

- Exit Alloy immediately if the port it runs on is not available.
This port can be configured with `--server.http.listen-addr` or using
the default listen address`127.0.0.1:12345`. (@mattdurham)

- Fix clustering on instances running within Istio mesh by allowing to change the name of the clustering port

v1.1.0-rc.0
Expand Down
15 changes: 15 additions & 0 deletions docs/sources/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,18 @@ The release notes provide information about deprecations and breaking changes in
For a complete list of changes to {{< param "FULL_PRODUCT_NAME" >}}, with links to pull requests and related issues when available, refer to the [Changelog][].

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

## v1.2

### Breaking change: `remotecfg` block updated for Agent rename

{{< 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 been updated to use [alloy-remote-config](https://github.com/grafana/alloy-remote-config)
over [agent-remote-config](https://github.com/grafana/agent-remote-config). This change
aligns `remotecfg` API terminology with Alloy and includes updated endpoints.
32 changes: 16 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ require (
github.com/Shopify/sarama v1.38.1
github.com/alecthomas/kingpin/v2 v2.4.0
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9
github.com/aws/aws-sdk-go v1.51.22 // indirect
github.com/aws/aws-sdk-go-v2 v1.26.1
github.com/aws/aws-sdk-go-v2/config v1.27.11
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1
Expand All @@ -29,7 +28,6 @@ require (
github.com/cespare/xxhash/v2 v2.3.0
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/coreos/go-systemd/v22 v22.5.0
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dimchansky/utfbom v1.1.1
github.com/docker/docker v25.0.5+incompatible
github.com/docker/go-connections v0.5.0
Expand All @@ -54,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/agent-remote-config v0.0.2
github.com/grafana/alloy-remote-config v0.0.4
github.com/grafana/alloy/syntax v0.1.0
github.com/grafana/beyla v1.5.1
github.com/grafana/ckit v0.0.0-20230906125525-c046c99a5c04
Expand All @@ -64,7 +62,7 @@ require (
github.com/grafana/jfr-parser/pprof v0.0.0-20240126072739-986e71dc0361
github.com/grafana/jsonparser v0.0.0-20240209175146-098958973a2d
github.com/grafana/kafka_exporter v0.0.0-20240409084445-5e3488ad9f9a
github.com/grafana/loki v1.6.2-0.20240221085104-f9d188620153 // k190 branch
github.com/grafana/loki v1.6.2-0.20240510183741-cef4c2826b4b // k190 branch
github.com/grafana/loki/pkg/push v0.0.0-20231212100434-384e5c2dc872 // k180 branch
github.com/grafana/pyroscope-go/godeltaprof v0.1.7
github.com/grafana/pyroscope/api v0.4.0
Expand All @@ -73,9 +71,7 @@ require (
github.com/grafana/snowflake-prometheus-exporter v0.0.0-20221213150626-862cad8e9538
github.com/grafana/tail v0.0.0-20230510142333-77b18831edf0
github.com/grafana/vmware_exporter v0.0.5-beta
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/hashicorp/consul/api v1.28.2
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-discover v0.0.0-20230724184603-e89ebd1b2f65
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/golang-lru v1.0.2
Expand All @@ -98,7 +94,6 @@ require (
github.com/lib/pq v1.10.9
github.com/miekg/dns v1.1.58
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
github.com/natefinch/atomic v1.0.1
github.com/ncabatoff/process-exporter v0.7.10
Expand All @@ -120,7 +115,6 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/azure v0.99.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/loki v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.99.0
Expand All @@ -131,14 +125,12 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filestatsreceiver v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kafkareceiver v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/opencensusreceiver v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.99.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.99.0
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e // indirect
github.com/opentracing-contrib/go-stdlib v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/ory/dockertest/v3 v3.8.1
github.com/oschwald/geoip2-golang v1.9.0
github.com/oschwald/maxminddb-golang v1.11.0
Expand Down Expand Up @@ -198,7 +190,6 @@ require (
go.opentelemetry.io/collector/config/configtls v0.99.0
go.opentelemetry.io/collector/confmap v0.99.0
go.opentelemetry.io/collector/confmap/converter/expandconverter v0.99.0
go.opentelemetry.io/collector/confmap/provider/fileprovider v0.99.0 // indirect
go.opentelemetry.io/collector/confmap/provider/yamlprovider v0.99.0
go.opentelemetry.io/collector/connector v0.99.0
go.opentelemetry.io/collector/consumer v0.99.0
Expand Down Expand Up @@ -248,7 +239,6 @@ require (
gopkg.in/yaml.v3 v3.0.1
gotest.tools v2.2.0+incompatible
k8s.io/api v0.29.3
k8s.io/apiextensions-apiserver v0.29.2 // indirect
k8s.io/apimachinery v0.29.3
k8s.io/client-go v0.29.3
k8s.io/component-base v0.29.2
Expand All @@ -258,8 +248,6 @@ require (
sigs.k8s.io/yaml v1.4.0
)

require github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filestatsreceiver v0.99.0

require (
cloud.google.com/go v0.112.0 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
Expand Down Expand Up @@ -311,6 +299,7 @@ require (
github.com/armon/go-metrics v0.4.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/avvmoto/buf-readerat v0.0.0-20171115124131-a17c8cb89270 // indirect
github.com/aws/aws-sdk-go v1.51.22 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.0 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.11 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.0 // indirect
Expand Down Expand Up @@ -363,6 +352,7 @@ require (
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/danieljoos/wincred v1.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dennwc/btrfs v0.0.0-20230312211831-a1f570bd01a1 // indirect
github.com/dennwc/ioctl v1.0.0 // indirect
github.com/dennwc/varint v1.0.0 // indirect
Expand Down Expand Up @@ -447,10 +437,12 @@ require (
github.com/grafana/gomemcache v0.0.0-20231204155601-7de47a8c3cb0 // indirect
github.com/grafana/jfr-parser v0.8.0 // indirect
github.com/grobie/gomemcache v0.0.0-20230213081705-239240bbc445 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hashicorp/cronexpr v1.1.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-envparse v0.1.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
Expand Down Expand Up @@ -535,6 +527,7 @@ require (
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/mna/redisc v1.3.2 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
Expand Down Expand Up @@ -563,6 +556,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.99.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/batchpersignal v0.99.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.99.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/azure v0.99.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger v0.99.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/opencensus v0.99.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin v0.99.0 // indirect
Expand All @@ -573,6 +567,9 @@ require (
github.com/opencontainers/selinux v1.11.0 // indirect
github.com/openshift/api v3.9.0+incompatible // indirect
github.com/openshift/client-go v0.0.0-20210521082421-73d9475a9142 // indirect
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e // indirect
github.com/opentracing-contrib/go-stdlib v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/openzipkin/zipkin-go v0.4.2 // indirect
github.com/ovh/go-ovh v1.4.3 // indirect
github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c // indirect
Expand Down Expand Up @@ -653,6 +650,7 @@ require (
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector/config/internal v0.99.0 // indirect
go.opentelemetry.io/collector/confmap/provider/envprovider v0.99.0 // indirect
go.opentelemetry.io/collector/confmap/provider/fileprovider v0.99.0 // indirect
go.opentelemetry.io/collector/confmap/provider/httpprovider v0.99.0 // indirect
go.opentelemetry.io/collector/confmap/provider/httpsprovider v0.99.0 // indirect
go.opentelemetry.io/collector/filter v0.99.0 // indirect
Expand Down Expand Up @@ -684,6 +682,7 @@ require (
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
howett.net/plist v1.0.0 // indirect
k8s.io/apiextensions-apiserver v0.29.2 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
Expand Down Expand Up @@ -714,9 +713,10 @@ replace (
// * There is a release of Prometheus which contains
// prometheus/prometheus#13002
// and prometheus/prometheus#13497
// and https://github.com/grafana/prometheus/pull/34
// We use the last v1-related tag as the replace statement does not work for v2
// tags without the v2 suffix to the module root.
replace github.com/prometheus/prometheus => github.com/grafana/prometheus v1.8.2-0.20240130142130-51b39f24d406 // cmp_header_order branch
replace github.com/prometheus/prometheus => github.com/grafana/prometheus v1.8.2-0.20240513094155-793c8c9fe88e // cmp_header_order_and_staleness_disabling branch

replace gopkg.in/yaml.v2 => github.com/rfratto/go-yaml v0.0.0-20211119180816-77389c3526dc

Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,8 @@ github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
github.com/gosnmp/gosnmp v1.36.0 h1:1Si+MImHcKIqFc3/kJEs2LOULP1nlFKlzPFyrMOk5Qk=
github.com/gosnmp/gosnmp v1.36.0/go.mod h1:iLcZxN2MxKhH0jPQDVMZaSNypw1ykqVi27O79koQj6w=
github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY=
github.com/grafana/agent-remote-config v0.0.2 h1:s3FKgVzfY5Ij+xG0wVKgVvtDrh/Bz0ZvB3D5MM7LJxU=
github.com/grafana/agent-remote-config v0.0.2/go.mod h1:amyG3pVNXKcMo+kNN46yhnAXAz/m/9Ew9MRf53n7XBg=
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/beyla v1.5.1 h1:7CTTXSUmDcobGoJ3fvwdpfCgMxpRsW13V+Remxgl5aU=
github.com/grafana/beyla v1.5.1/go.mod h1:y6zU7/QV3db6SVXx3PYOLOp2s/PlwWyIDzUzOrfcI6o=
github.com/grafana/cadvisor v0.0.0-20231110094609-5f7917925dea h1:Q5f5/nJJ0SbusZjA6F6XkJuHDbl2/PqdTGw6wHsuccA=
Expand All @@ -1052,8 +1052,8 @@ github.com/grafana/jsonparser v0.0.0-20240209175146-098958973a2d h1:YwbJJ/PrVWVd
github.com/grafana/jsonparser v0.0.0-20240209175146-098958973a2d/go.mod h1:796sq+UcONnSlzA3RtlBZ+b/hrerkZXiEmO8oMjyRwY=
github.com/grafana/kafka_exporter v0.0.0-20240409084445-5e3488ad9f9a h1:jqM4NNdx8LSquKo8bPx+XWn91S2b+sgNvEcFfSJQtHY=
github.com/grafana/kafka_exporter v0.0.0-20240409084445-5e3488ad9f9a/go.mod h1:ZXGGyeTUMenf/H1CDBK9lv3azjswfa0nVzLoQAYmnDc=
github.com/grafana/loki v1.6.2-0.20240221085104-f9d188620153 h1:C191g5Ls8lIf9lkJEoScTQgoVDwUdK4HXKP5XtL+zAM=
github.com/grafana/loki v1.6.2-0.20240221085104-f9d188620153/go.mod h1:j2XCl3SmslPf+3Vs7uyoaJE/QkmUlL9JzTBTShSOSiU=
github.com/grafana/loki v1.6.2-0.20240510183741-cef4c2826b4b h1:x5JsSnExxRl9kTMNqHebMCv0fn+V1+T16z7Tgz6xYf4=
github.com/grafana/loki v1.6.2-0.20240510183741-cef4c2826b4b/go.mod h1:j2XCl3SmslPf+3Vs7uyoaJE/QkmUlL9JzTBTShSOSiU=
github.com/grafana/loki/pkg/push v0.0.0-20231212100434-384e5c2dc872 h1:6kPX7bngjBgUlHqADwZ6249UtzMaoQW5n0H8bOtnYeM=
github.com/grafana/loki/pkg/push v0.0.0-20231212100434-384e5c2dc872/go.mod h1:f3JSoxBTPXX5ec4FxxeC19nTBSxoTz+cBgS3cYLMcr0=
github.com/grafana/mysqld_exporter v0.12.2-0.20231005125903-364b9c41e595 h1:I9sRknI5ajd8whPOX0nBDXy5B6xUfhItClMy+6R4oqE=
Expand All @@ -1068,8 +1068,8 @@ github.com/grafana/opentelemetry-collector/service v0.0.0-20240429170914-d1e1018
github.com/grafana/opentelemetry-collector/service v0.0.0-20240429170914-d1e101852ba5/go.mod h1:0djU5YbUIZw4Y+KNYk07tZztXrMK/LNAZyfH8b7f7xA=
github.com/grafana/postgres_exporter v0.15.1-0.20240417113938-9358270470dd h1:vNHdecaOmYgSHMEQRgyzWacV++N38Jp8qLZg0RCsfFo=
github.com/grafana/postgres_exporter v0.15.1-0.20240417113938-9358270470dd/go.mod h1:kR16GJ0ZwWVQ2osW3pgtDJU1a/GXpufrwio0kLG14cg=
github.com/grafana/prometheus v1.8.2-0.20240130142130-51b39f24d406 h1:LVIOYe5j92m10wluP5hgeHqSkOLnZzcPxhYCkdbLXCE=
github.com/grafana/prometheus v1.8.2-0.20240130142130-51b39f24d406/go.mod h1:SRw624aMAxTfryAcP8rOjg4S/sHHaetx2lyJJ2nM83g=
github.com/grafana/prometheus v1.8.2-0.20240513094155-793c8c9fe88e h1:uQDMlJKE+h6TloPTTiSyA8FSMJeU8mQfg1MY1/UrCKA=
github.com/grafana/prometheus v1.8.2-0.20240513094155-793c8c9fe88e/go.mod h1:SRw624aMAxTfryAcP8rOjg4S/sHHaetx2lyJJ2nM83g=
github.com/grafana/pyroscope-go/godeltaprof v0.1.7 h1:C11j63y7gymiW8VugJ9ZW0pWfxTZugdSJyC48olk5KY=
github.com/grafana/pyroscope-go/godeltaprof v0.1.7/go.mod h1:Tk376Nbldo4Cha9RgiU7ik8WKFkNpfds98aUzS8omLE=
github.com/grafana/pyroscope/api v0.4.0 h1:J86DxoNeLOvtJhB1Cn65JMZkXe682D+RqeoIUiYc/eo=
Expand Down
49 changes: 0 additions & 49 deletions internal/component/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"time"

"github.com/grafana/alloy/internal/component"
"github.com/grafana/alloy/internal/service/cluster"
"github.com/grafana/ckit/shard"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/discovery"
"github.com/prometheus/prometheus/discovery/targetgroup"
Expand All @@ -20,53 +18,6 @@ import (
// component.
type Target map[string]string

// DistributedTargets uses the node's Lookup method to distribute discovery
// targets when a component runs in a cluster.
type DistributedTargets struct {
useClustering bool
cluster cluster.Cluster
targets []Target
}

// NewDistributedTargets creates the abstraction that allows components to
// dynamically shard targets between components.
func NewDistributedTargets(e bool, n cluster.Cluster, t []Target) DistributedTargets {
return DistributedTargets{e, n, t}
}

// Get distributes discovery targets a clustered environment.
//
// If a cluster size is 1, then all targets will be returned.
func (t *DistributedTargets) Get() []Target {
// TODO(@tpaschalis): Make this into a single code-path to simplify logic.
if !t.useClustering || t.cluster == nil {
return t.targets
}

peerCount := len(t.cluster.Peers())
resCap := (len(t.targets) + 1)
if peerCount != 0 {
resCap = (len(t.targets) + 1) / peerCount
}

res := make([]Target, 0, resCap)

for _, tgt := range t.targets {
peers, err := t.cluster.Lookup(shard.StringKey(tgt.NonMetaLabels().String()), 1, shard.OpReadWrite)
if err != nil {
// This can only fail in case we ask for more owners than the
// available peers. This will never happen, but in any case we fall
// back to owning the target ourselves.
res = append(res, tgt)
}
if len(peers) == 0 || peers[0].Self {
res = append(res, tgt)
}
}

return res
}

// Labels converts Target into a set of sorted labels.
func (t Target) Labels() labels.Labels {
var lset labels.Labels
Expand Down
Loading

0 comments on commit 9f1c5c2

Please sign in to comment.