Skip to content

Commit

Permalink
Merge branch 'main' into static-windows-installer-option
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbaranowski authored Jan 10, 2024
2 parents c008dda + 3b95da4 commit 286ace7
Show file tree
Hide file tree
Showing 239 changed files with 20,411 additions and 1,056 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/helm-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
version: v3.10.3

- name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'
check-latest: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Set OTEL Exporter Endpoint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/needs-attention.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
needs-attention:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
with:
days-before-stale: 30
days-before-close: -1 # never close automatically
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go 1.21
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21"
cache: true
Expand Down
4 changes: 2 additions & 2 deletions .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@2b6a709cf9c4025c5438138008beaddbb02086f0
uses: aquasecurity/trivy-action@d43c1f16c00cfd3978dde6c07f4bbcf9eb6993ca
with:
image-ref: 'grafana/agent:main'
format: 'template'
Expand All @@ -35,6 +35,6 @@ jobs:
severity: 'CRITICAL,HIGH,MEDIUM,LOW'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
50 changes: 48 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@ internal API changes are not present.
Main (unreleased)
-----------------

### Security fixes

- Fixes following vulnerabilities (@hainenber)
- [GO-2023-2409](https://github.com/advisories/GHSA-mhpq-9638-x6pw)
- [GO-2023-2412](https://github.com/advisories/GHSA-7ww5-4wqc-m92c)
- [CVE-2023-49568](https://github.com/advisories/GHSA-mw99-9chc-xw7r)

### Enhancements

- Add an option to the windows static mode installer for expanding environment vars in the yaml config. (@erikbaranowski)

### Bugfixes

- Fix an issue in `remote.s3` where the exported content of an object would be an empty string if `remote.s3` failed to fully retrieve
the file in a single read call. (@grafana/agent-squad)

- Utilize the `instance` Argument of `prometheus.exporter.kafka` when set. (@akhmatov-s)

### Other changes

- Removed support for Windows 2012 in line with Microsoft end of life. (@mattdurham)

v0.39.0 (2024-01-09)
--------------------

### Breaking changes

- `otelcol.receiver.prometheus` will drop all `otel_scope_info` metrics when converting them to OTLP. (@wildum)
Expand All @@ -25,6 +50,12 @@ Main (unreleased)
- This change will not break any existing configurations and you can opt in to validation via the `validate_dimensions` configuration option.
- Before this change, pulling metrics for azure resources with variable dimensions required one configuration per metric + dimension combination to avoid an error.
- After this change, you can include all metrics and dimensions in a single configuration and the Azure APIs will only return dimensions which are valid for the various metrics.

### Features

- A new `discovery.ovhcloud` component for discovering scrape targets on OVHcloud. (@ptodev)

- Allow specifying additional containers to run. (@juangom)

### Enhancements

Expand Down Expand Up @@ -53,6 +84,7 @@ Main (unreleased)
- `otelcol.receiver.prometheus` does not drop histograms without buckets anymore. (@wildum)

- Added exemplars support to `otelcol.receiver.prometheus`. (@wildum)

- `mimir.rules.kubernetes` may now retry its startup on failure. (@hainenber)

- Added links between compatible components in the documentation to make it
Expand All @@ -78,7 +110,13 @@ Main (unreleased)

- Add support for `http_sd_config` within a `scrape_config` for prometheus to flow config conversion. (@erikbaranowski)

- Add an option to the windows static mode installer for expanding environment vars in the yaml config. (@erikbaranowski)
- `discovery.lightsail` now supports additional parameters for configuring HTTP client settings. (@ptodev)
- Add `sample_age_limit` to remote_write config to drop samples older than a specified duration. (@marctc)

- Handle paths in the Kubelet URL for `discovery.kubelet`. (@petewall)

- `loki.source.docker` now deduplicates targets which report the same container
ID. (@tpaschalis)

### Bugfixes

Expand All @@ -98,11 +136,19 @@ Main (unreleased)

- Fix issue where `prometheus.exporter.kafka` would crash when configuring `sasl_password`. (@rfratto)

- Fix performance issue where perf lib where clause was not being set, leading to timeouts in collecting metrics for windows_exporter. (@mattdurham)

- Fix nil panic when using the process collector with the windows exporter. (@mattdurham)

### Other changes

- Bump github.com/IBM/sarama from v1.41.2 to v1.42.1

- Attatch unique Agent ID header to remote-write requests. (@captncraig)
- Attach unique Agent ID header to remote-write requests. (@captncraig)

- Update to v2.48.1 of `github.com/prometheus/prometheus`.
Previously, a custom fork of v2.47.2 was used.
The custom fork of v2.47.2 also contained prometheus#12729 and prometheus#12677.

v0.38.1 (2023-11-30)
--------------------
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ lint: agentlint
# more without -race for packages that have known race detection issues.
test:
$(GO_ENV) go test $(GO_FLAGS) -race $(shell go list ./... | grep -v /integration-tests/)
$(GO_ENV) go test $(GO_FLAGS) ./pkg/integrations/node_exporter ./pkg/logs ./pkg/operator ./pkg/util/k8s ./component/otelcol/processor/tail_sampling ./component/loki/source/file
$(GO_ENV) go test $(GO_FLAGS) ./pkg/integrations/node_exporter ./pkg/logs ./pkg/operator ./pkg/util/k8s ./component/otelcol/processor/tail_sampling ./component/loki/source/file ./component/loki/source/docker

test-packages:
docker pull $(BUILD_IMAGE)
Expand Down
1 change: 1 addition & 0 deletions component/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
_ "github.com/grafana/agent/component/discovery/nerve" // Import discovery.nerve
_ "github.com/grafana/agent/component/discovery/nomad" // Import discovery.nomad
_ "github.com/grafana/agent/component/discovery/openstack" // Import discovery.openstack
_ "github.com/grafana/agent/component/discovery/ovhcloud" // Import discovery.ovhcloud
_ "github.com/grafana/agent/component/discovery/puppetdb" // Import discovery.puppetdb
_ "github.com/grafana/agent/component/discovery/relabel" // Import discovery.relabel
_ "github.com/grafana/agent/component/discovery/scaleway" // Import discovery.scaleway
Expand Down
10 changes: 5 additions & 5 deletions component/common/loki/wal/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,9 @@ func TestWatcher_StopAndDrainWAL(t *testing.T) {
watcher.Drain()
watcher.Stop()

// expecting 15s (missing 15 entries * 1 sec delay in AppendEntries) +/- 1.1s (taking into account the drain timeout
// expecting 15s (missing 15 entries * 1 sec delay in AppendEntries) +/- 2.0s (taking into account the drain timeout
// has one extra second.
require.InDelta(t, time.Second*15, time.Since(now), float64(time.Millisecond*1100), "expected the drain procedure to take around 15s")
require.InDelta(t, time.Second*15, time.Since(now), float64(time.Millisecond*2000), "expected the drain procedure to take around 15s")
require.Equal(t, int(writeTo.entriesReceived.Load()), 20, "expected the watcher to fully drain the WAL")
})

Expand Down Expand Up @@ -737,9 +737,9 @@ func TestWatcher_StopAndDrainWAL(t *testing.T) {
watcher.Drain()
watcher.Stop()

// expecting 15s (missing 15 entries * 1 sec delay in AppendEntries) +/- 1.1s (taking into account the drain timeout
// expecting 15s (missing 15 entries * 1 sec delay in AppendEntries) +/- 2.0s (taking into account the drain timeout
// has one extra second.
require.InDelta(t, time.Second*15, time.Since(now), float64(time.Millisecond*1100), "expected the drain procedure to take around 15s")
require.InDelta(t, time.Second*15, time.Since(now), float64(time.Millisecond*2000), "expected the drain procedure to take around 15s")
require.Equal(t, int(writeTo.entriesReceived.Load()), 20, "expected the watcher to fully drain the WAL")
})

Expand Down Expand Up @@ -790,7 +790,7 @@ func TestWatcher_StopAndDrainWAL(t *testing.T) {
watcher.Drain()
watcher.Stop()

require.InDelta(t, time.Second*10, time.Since(now), float64(time.Millisecond*1100), "expected the drain procedure to take around 15s")
require.InDelta(t, time.Second*10, time.Since(now), float64(time.Millisecond*2000), "expected the drain procedure to take around 15s")
require.Less(t, int(writeTo.entriesReceived.Load()), 20, "expected watcher to have not consumed WAL fully")
require.InDelta(t, 15, int(writeTo.entriesReceived.Load()), 1.0, "expected Watcher to consume at most +/- 1 entry from the WAL")
})
Expand Down
5 changes: 3 additions & 2 deletions component/discovery/aws/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ func (args EC2Arguments) Convert() *promaws.EC2SDConfig {
}

var DefaultEC2SDConfig = EC2Arguments{
Port: 80,
RefreshInterval: 60 * time.Second,
Port: 80,
RefreshInterval: 60 * time.Second,
HTTPClientConfig: config.DefaultHTTPClientConfig,
}

// SetToDefault implements river.Defaulter.
Expand Down
40 changes: 22 additions & 18 deletions component/discovery/aws/lightsail.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/aws/aws-sdk-go/aws/ec2metadata"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/river/rivertypes"
promcfg "github.com/prometheus/common/config"
Expand All @@ -27,34 +28,37 @@ func init() {

// LightsailArguments is the configuration for AWS Lightsail based service discovery.
type LightsailArguments struct {
Endpoint string `river:"endpoint,attr,optional"`
Region string `river:"region,attr,optional"`
AccessKey string `river:"access_key,attr,optional"`
SecretKey rivertypes.Secret `river:"secret_key,attr,optional"`
Profile string `river:"profile,attr,optional"`
RoleARN string `river:"role_arn,attr,optional"`
RefreshInterval time.Duration `river:"refresh_interval,attr,optional"`
Port int `river:"port,attr,optional"`
Endpoint string `river:"endpoint,attr,optional"`
Region string `river:"region,attr,optional"`
AccessKey string `river:"access_key,attr,optional"`
SecretKey rivertypes.Secret `river:"secret_key,attr,optional"`
Profile string `river:"profile,attr,optional"`
RoleARN string `river:"role_arn,attr,optional"`
RefreshInterval time.Duration `river:"refresh_interval,attr,optional"`
Port int `river:"port,attr,optional"`
HTTPClientConfig config.HTTPClientConfig `river:",squash"`
}

func (args LightsailArguments) Convert() *promaws.LightsailSDConfig {
cfg := &promaws.LightsailSDConfig{
Endpoint: args.Endpoint,
Region: args.Region,
AccessKey: args.AccessKey,
SecretKey: promcfg.Secret(args.SecretKey),
Profile: args.Profile,
RoleARN: args.RoleARN,
RefreshInterval: model.Duration(args.RefreshInterval),
Port: args.Port,
Endpoint: args.Endpoint,
Region: args.Region,
AccessKey: args.AccessKey,
SecretKey: promcfg.Secret(args.SecretKey),
Profile: args.Profile,
RoleARN: args.RoleARN,
RefreshInterval: model.Duration(args.RefreshInterval),
Port: args.Port,
HTTPClientConfig: *args.HTTPClientConfig.Convert(),
}
return cfg
}

// DefaultLightsailSDConfig is the default Lightsail SD configuration.
var DefaultLightsailSDConfig = LightsailArguments{
Port: 80,
RefreshInterval: 60 * time.Second,
Port: 80,
RefreshInterval: 60 * time.Second,
HTTPClientConfig: config.DefaultHTTPClientConfig,
}

// SetToDefault implements river.Defaulter.
Expand Down
2 changes: 2 additions & 0 deletions component/discovery/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ var DefaultArguments = Arguments{
Environment: azure.PublicCloud.Name,
Port: 80,
RefreshInterval: 5 * time.Minute,
FollowRedirects: true,
EnableHTTP2: true,
}

// SetToDefault implements river.Defaulter.
Expand Down
11 changes: 6 additions & 5 deletions component/discovery/consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ type Arguments struct {
}

var DefaultArguments = Arguments{
Server: "localhost:8500",
TagSeparator: ",",
Scheme: "http",
AllowStale: true,
RefreshInterval: 30 * time.Second,
Server: "localhost:8500",
TagSeparator: ",",
Scheme: "http",
AllowStale: true,
RefreshInterval: 30 * time.Second,
HTTPClientConfig: config.DefaultHTTPClientConfig,
}

// SetToDefault implements river.Defaulter.
Expand Down
2 changes: 2 additions & 0 deletions component/discovery/digitalocean/digitalocean.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type Arguments struct {
var DefaultArguments = Arguments{
Port: 80,
RefreshInterval: time.Minute,
FollowRedirects: true,
EnableHTTP2: true,
}

// SetToDefault implements river.Defaulter.
Expand Down
5 changes: 2 additions & 3 deletions component/discovery/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,10 @@ func NewKubeletDiscovery(args Arguments) (*Discovery, error) {
Transport: transport,
Timeout: 30 * time.Second,
}
// ensure the path is the kubelet pods endpoint
args.URL.Path = "/pods"
// Append the path to the kubelet pods endpoint
return &Discovery{
client: client,
url: args.URL.String(),
url: args.URL.String() + "/pods",
targetNamespaces: args.Namespaces,
}, nil
}
Expand Down
19 changes: 19 additions & 0 deletions component/discovery/kubelet/kubelet_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package kubelet

import (
"net/url"
"testing"

"github.com/prometheus/prometheus/discovery/targetgroup"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/grafana/agent/component/common/config"
"github.com/grafana/river"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -105,3 +107,20 @@ func TestDiscoveryPodWithoutPod(t *testing.T) {
require.NoError(t, err)
require.Len(t, kubeletDiscovery.discoveredPodSources, 2)
}

func TestWithDefaultKubeletHost(t *testing.T) {
kubeletDiscovery, err := NewKubeletDiscovery(DefaultConfig)
require.NoError(t, err)
require.Equal(t, "https://localhost:10250/pods", kubeletDiscovery.url)
}

func TestWithCustomPath(t *testing.T) {
kubeletProxyUrl, _ := url.Parse("https://kubernetes.default.svc.cluster.local:443/api/v1/nodes/cluster-node-1/proxy")
kubeletDiscovery, err := NewKubeletDiscovery(Arguments{
URL: config.URL{
URL: kubeletProxyUrl,
},
})
require.NoError(t, err)
require.Equal(t, "https://kubernetes.default.svc.cluster.local:443/api/v1/nodes/cluster-node-1/proxy/pods", kubeletDiscovery.url)
}
Loading

0 comments on commit 286ace7

Please sign in to comment.