Skip to content

Commit

Permalink
Merge branch 'main' into basic-auth-for-elasticsearch-exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
hainenber authored Nov 21, 2023
2 parents 1f4f02e + f1871df commit 4c5c6d9
Show file tree
Hide file tree
Showing 39 changed files with 354 additions and 139 deletions.
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ internal API changes are not present.
Main (unreleased)
-----------------


### Features

- Add support for Basic Auth-secured connection with Elasticsearch cluster using `prometheus.exporter.elasticsearch`. (@hainenber)
Expand All @@ -19,9 +18,8 @@ Main (unreleased)

- Fix default configuration file `grafana-agent-flow.river` used in downstream packages. (@bricewge)


v0.38.0-rc.0 (2023-11-16)
-------------------------
v0.38.0 (2023-11-21)
--------------------

### Breaking changes

Expand Down Expand Up @@ -116,6 +114,8 @@ v0.38.0-rc.0 (2023-11-16)

- Updated windows exporter to use prometheus-community/windows_exporter commit 1836cd1. (@mattdurham)

- Allow agent to start with `module.git` config if cached before. (@hainenber)

### Bugfixes

- Set exit code 1 on grafana-agentctl non-runnable command. (@fgouteroux)
Expand Down Expand Up @@ -167,6 +167,12 @@ v0.38.0-rc.0 (2023-11-16)
- Added Kubernetes service resolver to static node's loadbalancing exporter
and to Flow's `otelcol.exporter.loadbalancing`. (@ptodev)

- Fix default configuration file `grafana-agent-flow.river` used in downstream
packages. (@bricewge)

- Fix converter output for prometheus.exporter.windows to not unnecessarily add
empty blocks. (@erikbaranowski)

### Other changes

- Bump `mysqld_exporter` version to v0.15.0. (@marctc)
Expand Down
18 changes: 16 additions & 2 deletions component/module/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package git

import (
"context"
"errors"
"path/filepath"
"reflect"
"sync"
Expand Down Expand Up @@ -91,8 +92,15 @@ func New(o component.Options, args Arguments) (*Component, error) {
argsChanged: make(chan struct{}, 1),
}

// Only acknowledge the error from Update if it's not a
// vcs.UpdateFailedError; vcs.UpdateFailedError means that the Git repo
// exists but we were just unable to update it.
if err := c.Update(args); err != nil {
return nil, err
if errors.As(err, &vcs.UpdateFailedError{}) {
level.Error(c.log).Log("msg", "failed to update repository", "err", err)
} else {
return nil, err
}
}
return c, nil
}
Expand Down Expand Up @@ -193,10 +201,16 @@ func (c *Component) Update(args component.Arguments) (err error) {
}

// Create or update the repo field.
// Failure to update repository makes the module loader temporarily use cached contents on disk
if c.repo == nil || !reflect.DeepEqual(repoOpts, c.repoOpts) {
r, err := vcs.NewGitRepo(context.Background(), repoPath, repoOpts)
if err != nil {
return err
if errors.As(err, &vcs.UpdateFailedError{}) {
level.Error(c.log).Log("msg", "failed to update repository", "err", err)
c.updateHealth(err)
} else {
return err
}
}
c.repo = r
c.repoOpts = repoOpts
Expand Down
28 changes: 18 additions & 10 deletions component/module/git/internal/vcs/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,24 @@ func NewGitRepo(ctx context.Context, storagePath string, opts GitRepoOptions) (*
}

// Fetch the latest contents. This may be a no-op if we just did a clone.
err = repo.FetchContext(ctx, &git.FetchOptions{
fetchRepoErr := repo.FetchContext(ctx, &git.FetchOptions{
RemoteName: "origin",
Force: true,
Auth: opts.Auth.Convert(),
})
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
return nil, UpdateFailedError{
Repository: opts.Repository,
Inner: err,
if fetchRepoErr != nil && !errors.Is(fetchRepoErr, git.NoErrAlreadyUpToDate) {
workTree, err := repo.Worktree()
if err != nil {
return nil, err
}
return &GitRepo{
opts: opts,
repo: repo,
workTree: workTree,
}, UpdateFailedError{
Repository: opts.Repository,
Inner: fetchRepoErr,
}
}

// Finally, hard reset to our requested revision.
Expand All @@ -92,7 +100,7 @@ func NewGitRepo(ctx context.Context, storagePath string, opts GitRepoOptions) (*
opts: opts,
repo: repo,
workTree: workTree,
}, nil
}, err
}

func isRepoCloned(dir string) bool {
Expand All @@ -103,15 +111,16 @@ func isRepoCloned(dir string) bool {
// Update updates the repository by fetching new content and re-checking out to
// latest version of Revision.
func (repo *GitRepo) Update(ctx context.Context) error {
err := repo.repo.FetchContext(ctx, &git.FetchOptions{
var err error
fetchRepoErr := repo.repo.FetchContext(ctx, &git.FetchOptions{
RemoteName: "origin",
Force: true,
Auth: repo.opts.Auth.Convert(),
})
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
if fetchRepoErr != nil && !errors.Is(fetchRepoErr, git.NoErrAlreadyUpToDate) {
return UpdateFailedError{
Repository: repo.opts.Repository,
Inner: err,
Inner: fetchRepoErr,
}
}

Expand All @@ -120,7 +129,6 @@ func (repo *GitRepo) Update(ctx context.Context) error {
if err != nil {
return InvalidRevisionError{Revision: repo.opts.Revision}
}

err = repo.workTree.Reset(&git.ResetOptions{
Commit: hash,
Mode: git.HardReset,
Expand Down
190 changes: 187 additions & 3 deletions component/otelcol/receiver/vcenter/vcenter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,144 @@ func TestArguments_UnmarshalRiver(t *testing.T) {
password = "pass"
collection_interval = "2m"
resource_attributes {
vcenter.cluster.name {
enabled = true
}
vcenter.datastore.name {
enabled = true
}
vcenter.host.name {
enabled = true
}
vcenter.resource_pool.inventory_path {
enabled = false
}
vcenter.resource_pool.name {
enabled = true
}
vcenter.vm.name {
enabled = true
}
}
metrics {
vcenter.cluster.cpu.effective {
enabled = false
}
vcenter.cluster.cpu.limit {
enabled = true
}
vcenter.cluster.host.count {
enabled = true
}
vcenter.cluster.memory.effective {
enabled = true
}
vcenter.cluster.memory.limit {
enabled = true
}
vcenter.cluster.memory.used {
enabled = true
}
vcenter.cluster.vm.count {
enabled = true
}
vcenter.datastore.disk.usage {
enabled = true
}
vcenter.datastore.disk.utilization {
enabled = true
}
vcenter.host.cpu.usage {
enabled = true
}
vcenter.host.cpu.utilization {
enabled = true
}
vcenter.host.disk.latency.avg {
enabled = true
}
vcenter.host.disk.latency.max {
enabled = true
}
vcenter.host.disk.throughput {
enabled = true
}
vcenter.host.memory.usage {
enabled = true
}
vcenter.host.memory.utilization {
enabled = true
}
vcenter.host.network.packet.count {
enabled = true
}
vcenter.host.network.packet.errors {
enabled = true
}
vcenter.host.network.throughput {
enabled = true
}
vcenter.host.network.usage {
enabled = true
}
vcenter.resource_pool.cpu.shares {
enabled = true
}
vcenter.resource_pool.cpu.usage {
enabled = true
}
vcenter.resource_pool.memory.shares {
enabled = true
}
vcenter.resource_pool.memory.usage {
enabled = true
}
vcenter.vm.cpu.usage {
enabled = true
}
vcenter.vm.cpu.utilization {
enabled = true
}
vcenter.vm.disk.latency.avg {
enabled = true
}
vcenter.vm.disk.latency.max {
enabled = true
}
vcenter.vm.disk.throughput {
enabled = true
}
vcenter.vm.disk.usage {
enabled = true
}
vcenter.vm.disk.utilization {
enabled = true
}
vcenter.vm.memory.ballooned {
enabled = true
}
vcenter.vm.memory.swapped {
enabled = true
}
vcenter.vm.memory.swapped_ssd {
enabled = true
}
vcenter.vm.memory.usage {
enabled = true
}
vcenter.vm.network.packet.count {
enabled = true
}
vcenter.vm.network.throughput {
enabled = true
}
vcenter.vm.network.usage {
enabled = true
}
}
output { /* no-op */ }
`

Expand All @@ -36,7 +174,53 @@ func TestArguments_UnmarshalRiver(t *testing.T) {
require.Equal(t, time.Second, otelArgs.ScraperControllerSettings.InitialDelay)
require.Equal(t, 0*time.Second, otelArgs.ScraperControllerSettings.Timeout)

require.Equal(t, true, otelArgs.Metrics.VcenterClusterCPUEffective.Enabled)
require.Equal(t, false, otelArgs.Metrics.VcenterVMMemoryUtilization.Enabled)
require.Equal(t, true, otelArgs.ResourceAttributes.VcenterClusterName.Enabled)
// Verify ResourceAttributesConfig fields
require.True(t, otelArgs.ResourceAttributes.VcenterClusterName.Enabled)
require.True(t, otelArgs.ResourceAttributes.VcenterDatastoreName.Enabled)
require.True(t, otelArgs.ResourceAttributes.VcenterHostName.Enabled)
require.False(t, otelArgs.ResourceAttributes.VcenterResourcePoolInventoryPath.Enabled)
require.True(t, otelArgs.ResourceAttributes.VcenterResourcePoolName.Enabled)
require.True(t, otelArgs.ResourceAttributes.VcenterVMName.Enabled)
require.True(t, otelArgs.ResourceAttributes.VcenterVMID.Enabled)

// Verify MetricsConfig fields
require.False(t, otelArgs.Metrics.VcenterClusterCPUEffective.Enabled)
require.True(t, otelArgs.Metrics.VcenterClusterCPULimit.Enabled)
require.True(t, otelArgs.Metrics.VcenterClusterHostCount.Enabled)
require.True(t, otelArgs.Metrics.VcenterClusterMemoryEffective.Enabled)
require.True(t, otelArgs.Metrics.VcenterClusterMemoryLimit.Enabled)
require.True(t, otelArgs.Metrics.VcenterClusterMemoryUsed.Enabled)
require.True(t, otelArgs.Metrics.VcenterClusterVMCount.Enabled)
require.True(t, otelArgs.Metrics.VcenterDatastoreDiskUsage.Enabled)
require.True(t, otelArgs.Metrics.VcenterDatastoreDiskUtilization.Enabled)
require.True(t, otelArgs.Metrics.VcenterHostCPUUsage.Enabled)
require.True(t, otelArgs.Metrics.VcenterHostCPUUtilization.Enabled)
require.True(t, otelArgs.Metrics.VcenterHostDiskLatencyAvg.Enabled)
require.True(t, otelArgs.Metrics.VcenterHostDiskLatencyMax.Enabled)
require.True(t, otelArgs.Metrics.VcenterHostDiskThroughput.Enabled)
require.True(t, otelArgs.Metrics.VcenterHostMemoryUsage.Enabled)
require.True(t, otelArgs.Metrics.VcenterHostMemoryUtilization.Enabled)
require.True(t, otelArgs.Metrics.VcenterHostNetworkPacketCount.Enabled)
require.True(t, otelArgs.Metrics.VcenterHostNetworkPacketErrors.Enabled)
require.True(t, otelArgs.Metrics.VcenterHostNetworkThroughput.Enabled)
require.True(t, otelArgs.Metrics.VcenterHostNetworkUsage.Enabled)
require.True(t, otelArgs.Metrics.VcenterResourcePoolCPUShares.Enabled)
require.True(t, otelArgs.Metrics.VcenterResourcePoolCPUUsage.Enabled)
require.True(t, otelArgs.Metrics.VcenterResourcePoolMemoryShares.Enabled)
require.True(t, otelArgs.Metrics.VcenterResourcePoolMemoryUsage.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMCPUUsage.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMCPUUtilization.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMDiskLatencyAvg.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMDiskLatencyMax.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMDiskThroughput.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMDiskUsage.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMDiskUtilization.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMMemoryBallooned.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMMemorySwapped.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMMemorySwappedSsd.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMMemoryUsage.Enabled)
require.False(t, otelArgs.Metrics.VcenterVMMemoryUtilization.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMNetworkPacketCount.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMNetworkThroughput.Enabled)
require.True(t, otelArgs.Metrics.VcenterVMNetworkUsage.Enabled)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package build

import (
"strings"

"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/component/prometheus/exporter/windows"
"github.com/grafana/agent/pkg/integrations/windows_exporter"
Expand All @@ -13,12 +15,12 @@ func (b *IntegrationsConfigBuilder) appendWindowsExporter(config *windows_export

func toWindowsExporter(config *windows_exporter.Config) *windows.Arguments {
return &windows.Arguments{
EnabledCollectors: splitByCommaNullOnEmpty(config.EnabledCollectors),
EnabledCollectors: strings.Split(config.EnabledCollectors, ","),
Dfsr: windows.DfsrConfig{
SourcesEnabled: splitByCommaNullOnEmpty(config.Dfsr.SourcesEnabled),
SourcesEnabled: strings.Split(config.Dfsr.SourcesEnabled, ","),
},
Exchange: windows.ExchangeConfig{
EnabledList: splitByCommaNullOnEmpty(config.Exchange.EnabledList),
EnabledList: strings.Split(config.Exchange.EnabledList, ","),
},
IIS: windows.IISConfig{
AppBlackList: config.IIS.AppBlackList,
Expand All @@ -40,7 +42,7 @@ func toWindowsExporter(config *windows_exporter.Config) *windows.Arguments {
Where: config.MSMQ.Where,
},
MSSQL: windows.MSSQLConfig{
EnabledClasses: splitByCommaNullOnEmpty(config.MSSQL.EnabledClasses),
EnabledClasses: strings.Split(config.MSSQL.EnabledClasses, ","),
},
Network: windows.NetworkConfig{
BlackList: config.Network.BlackList,
Expand Down
Loading

0 comments on commit 4c5c6d9

Please sign in to comment.