Skip to content

Commit

Permalink
Release 0.34.2 (#4214)
Browse files Browse the repository at this point in the history
* Remove mongodb exporter for the time being (#4165)

* Remove mongodb exporter for the time being

  - We need to remove mongodb exporter until licensing issues with one
    of its dependencies have been resolved.
  - Keeps the configuration and boilerplate code, making the actual
    exporter a no-op that always returns an error.
  - Hopefully we will be able to bring it back before the next release.

* Remove unnecesary dependency

* Update snowflake and blackbox_exporter libraries. (#4181)

* update github.com/snowflakedb/gosnowflake

* update github.com/prometheus/blackbox_exporter

* Fix relabel bug (#4187)

* prometheus.relabel: do a more resilient empty label check (#4190)

Checking for a labelset to be nil is not always correct; an dropped
metric from relabel will return a non-nil, but still empty labelset.

* Switch to using capped LRU cache instead of raw map. (#4191)

* Switch to using capped LRU cache instead of raw map.

* switch to lru 2

* changelog for 0.34.2

* update versions for 0.34.2

* Fix several issues with statsd exporter (#4189)

- Static and Flow: statsd_exporter failed when specifying mappings.
    This was caused by an unmarshal/marshal/unmarshal sequence that set some wrong
    defaults.
  - Flow: Fixes defaults for `listen_udp` and `listen_tcp` arguments and
    updates documentation accordingly.
  - Flow: Fixes an issue where an undefined `mapping_config_path`
    argument would cause a load error.

Co-authored-by: Marc Tuduri <[email protected]>

* Fix wording and CHANGELOG entry (#4167)

* Fix wording and CHANGELOG entry

  - Clarify that that the integration is disabled (not fully removed).

* Update CHANGELOG.md

Co-authored-by: Mischa Thompson <[email protected]>

---------

Co-authored-by: Mischa Thompson <[email protected]>

* Extend statsd integration to configure relay endpoint (#4030)

* configure relay for statsd integration

* update tests to cover relay attributes

* update docs

* update flow docs for statsd relay attributes

* update changelog

* Update docs/sources/flow/reference/components/prometheus.exporter.statsd.md

Co-authored-by: Clayton Cornell <[email protected]>

* Update CHANGELOG.md

---------

Co-authored-by: Armin <[email protected]>
Co-authored-by: Clayton Cornell <[email protected]>
Co-authored-by: Jorge Creixell <[email protected]>
Co-authored-by: Jorge Creixell <[email protected]>

---------

Co-authored-by: Jorge Creixell <[email protected]>
Co-authored-by: Piotr <[email protected]>
Co-authored-by: Robert Fratto <[email protected]>
Co-authored-by: mattdurham <[email protected]>
Co-authored-by: Marc Tuduri <[email protected]>
Co-authored-by: Mischa Thompson <[email protected]>
Co-authored-by: Armin <[email protected]>
Co-authored-by: Armin <[email protected]>
Co-authored-by: Clayton Cornell <[email protected]>
Co-authored-by: Jorge Creixell <[email protected]>
  • Loading branch information
11 people authored Jun 21, 2023
1 parent d4a7192 commit 32600df
Show file tree
Hide file tree
Showing 27 changed files with 416 additions and 365 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ This document contains a historical list of changes between releases. Only
changes that impact end-user behavior are listed; changes to documentation or
internal API changes are not present.

v0.34.2 (2023-06-20)
--------------------

### Enhancements

- Replace map cache in prometheus.relabel with an LRU cache. (@mattdurham)
- Integrations: Extend `statsd` integration to configure relay endpoint. (@arminaaki)

### Bugfixes

- Fix a bug where `prometheus.relabel` would not correctly relabel when there is a cache miss. (@thampiotr)
- Fix a bug where `prometheus.relabel` would not correctly relabel exemplars or metadata. (@tpaschalis)
- Fixes several issues with statsd exporter. (@jcreixell, @marctc)

### Other changes

- Mongodb integration has been disabled for the time being due to licensing issues. (@jcreixell)

v0.34.1 (2023-06-12)
--------------------

Expand Down
41 changes: 23 additions & 18 deletions component/prometheus/exporter/statsd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/grafana/agent/pkg/integrations/statsd_exporter"
"github.com/prometheus/statsd_exporter/pkg/mapper"
"gopkg.in/yaml.v3"
)

type Arguments struct {
Expand All @@ -27,6 +27,9 @@ type Arguments struct {
ParseInfluxDB bool `river:"parse_influxdb_tags,attr,optional"`
ParseLibrato bool `river:"parse_librato_tags,attr,optional"`
ParseSignalFX bool `river:"parse_signalfx_tags,attr,optional"`

RelayAddr string `river:"relay_addr,attr,optional"`
RelayPacketLength int `river:"relay_packet_length,attr,optional"`
}

// DefaultConfig holds non-zero default options for the Config when it is
Expand All @@ -49,13 +52,23 @@ var DefaultConfig = Arguments{
ParseInfluxDB: statsd_exporter.DefaultConfig.ParseInfluxDB,
ParseLibrato: statsd_exporter.DefaultConfig.ParseLibrato,
ParseSignalFX: statsd_exporter.DefaultConfig.ParseSignalFX,

RelayPacketLength: statsd_exporter.DefaultConfig.RelayPacketLength,
}

// Convert gives a config suitable for use with github.com/grafana/agent/pkg/integrations/statsd_exporter.
func (c *Arguments) Convert() (*statsd_exporter.Config, error) {
mappingConfig, err := readMappingFromYAML(c.MappingConfig)
if err != nil {
return nil, fmt.Errorf("failed to convert statsd config: %w", err)
var (
mappingConfig any
err error
)

if c.MappingConfig != "" {
mappingConfig, err = readMappingFile(c.MappingConfig)

if err != nil {
return nil, fmt.Errorf("failed to convert statsd config: %w", err)
}
}

return &statsd_exporter.Config{
Expand All @@ -73,6 +86,8 @@ func (c *Arguments) Convert() (*statsd_exporter.Config, error) {
ParseInfluxDB: c.ParseInfluxDB,
ParseLibrato: c.ParseLibrato,
ParseSignalFX: c.ParseSignalFX,
RelayAddr: c.RelayAddr,
RelayPacketLength: c.RelayPacketLength,
MappingConfig: mappingConfig,
}, nil
}
Expand All @@ -85,24 +100,14 @@ func (c *Arguments) UnmarshalRiver(f func(interface{}) error) error {
return f((*args)(c))
}

// function to read a yaml file from a path and convert it to a mapper.MappingConfig
// this is used to convert the MappingConfig field in to a mapper.MappingConfig
// which is used by the statsd_exporter
func readMappingFromYAML(path string) (*mapper.MetricMapper, error) {
yfile, err := os.Open(path)
func readMappingFile(path string) (any, error) {
file, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("failed to read mapping config file: %w", err)
}

yBytes := make([]byte, 0)
count, err := yfile.Read(yBytes)
if err != nil {
return nil, fmt.Errorf("failed to read mapping config file: %w", err)
}

statsdMapper := mapper.MetricMapper{}

err = statsdMapper.InitFromYAMLString(string(yBytes[:count]))
var statsdMapper any
err = yaml.Unmarshal(file, &statsdMapper)
if err != nil {
return nil, fmt.Errorf("failed to load mapping config: %w", err)
}
Expand Down
64 changes: 42 additions & 22 deletions component/prometheus/exporter/statsd/statsd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

var (
exampleRiverConfig = `
listen_udp = "1010"
listen_tcp = "1011"
listen_udp = ":1010"
listen_tcp = ":1011"
listen_unixgram = "unix"
unix_socket_mode = "prom"
mapping_config_path = "./testdata/mapTest.yaml"
Expand All @@ -24,6 +24,8 @@ var (
parse_influxdb_tags = false
parse_librato_tags = false
parse_signalfx_tags = false
relay_addr = "localhost:7125"
relay_packet_length = 2000
`
duration1m, _ = time.ParseDuration("1m")
)
Expand All @@ -33,8 +35,8 @@ func TestRiverUnmarshal(t *testing.T) {
err := river.Unmarshal([]byte(exampleRiverConfig), &args)
require.NoError(t, err)

require.Equal(t, "1010", args.ListenUDP)
require.Equal(t, "1011", args.ListenTCP)
require.Equal(t, ":1010", args.ListenUDP)
require.Equal(t, ":1011", args.ListenTCP)
require.Equal(t, "unix", args.ListenUnixgram)
require.Equal(t, "prom", args.UnixSocketMode)
require.Equal(t, 1, args.ReadBuffer)
Expand All @@ -47,27 +49,45 @@ func TestRiverUnmarshal(t *testing.T) {
require.Equal(t, false, args.ParseLibrato)
require.Equal(t, false, args.ParseSignalFX)
require.Equal(t, `./testdata/mapTest.yaml`, args.MappingConfig)
require.Equal(t, "localhost:7125", args.RelayAddr)
require.Equal(t, 2000, args.RelayPacketLength)
}

func TestConvert(t *testing.T) {
var args Arguments
err := river.Unmarshal([]byte(exampleRiverConfig), &args)
require.NoError(t, err)
t.Run("with valid config", func(t *testing.T) {
var args Arguments
err := river.Unmarshal([]byte(exampleRiverConfig), &args)
require.NoError(t, err)

configStatsd, err := args.Convert()
require.NoError(t, err)
configStatsd, err := args.Convert()
require.NoError(t, err)

require.Equal(t, "1010", args.ListenUDP)
require.Equal(t, "1011", args.ListenTCP)
require.Equal(t, "unix", args.ListenUnixgram)
require.Equal(t, "prom", args.UnixSocketMode)
require.Equal(t, 1, args.ReadBuffer)
require.Equal(t, 2, args.CacheSize)
require.Equal(t, "random", args.CacheType)
require.Equal(t, 1000, args.EventQueueSize)
require.Equal(t, duration1m, configStatsd.EventFlushInterval)
require.Equal(t, true, configStatsd.ParseDogStatsd)
require.Equal(t, false, configStatsd.ParseInfluxDB)
require.Equal(t, false, configStatsd.ParseLibrato)
require.Equal(t, false, configStatsd.ParseSignalFX)
require.Equal(t, ":1010", args.ListenUDP)
require.Equal(t, ":1011", args.ListenTCP)
require.Equal(t, "unix", args.ListenUnixgram)
require.Equal(t, "prom", args.UnixSocketMode)
require.Equal(t, 1, args.ReadBuffer)
require.Equal(t, 2, args.CacheSize)
require.Equal(t, "random", args.CacheType)
require.Equal(t, 1000, args.EventQueueSize)
require.Equal(t, duration1m, configStatsd.EventFlushInterval)
require.Equal(t, true, configStatsd.ParseDogStatsd)
require.Equal(t, false, configStatsd.ParseInfluxDB)
require.Equal(t, false, configStatsd.ParseLibrato)
require.Equal(t, false, configStatsd.ParseSignalFX)
require.Equal(t, "localhost:7125", configStatsd.RelayAddr)
require.Equal(t, 2000, configStatsd.RelayPacketLength)
require.NotNil(t, configStatsd.MappingConfig)
})

t.Run("with empty config", func(t *testing.T) {
var args Arguments
err := river.Unmarshal([]byte(""), &args)
require.NoError(t, err)

configStatsd, err := args.Convert()
require.NoError(t, err)

require.Nil(t, configStatsd.MappingConfig)
})
}
Loading

0 comments on commit 32600df

Please sign in to comment.