Skip to content

Commit

Permalink
Merge branch 'main' into converter-diagnostics-wording
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbaranowski committed Oct 17, 2023
2 parents 9dc804d + 744d93b commit 55f689a
Show file tree
Hide file tree
Showing 55 changed files with 615 additions and 211 deletions.
126 changes: 63 additions & 63 deletions .drone/drone.yml

Large diffs are not rendered by default.

43 changes: 42 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ Main (unreleased)

- Remove `otelcol.exporter.jaeger` component (@hainenber)

- In the mysqld exporter integration, some metrics are removed and others are renamed. (@marctc)
- Removed metrics:
- "mysql_last_scrape_failed" (gauge)
- "mysql_exporter_scrapes_total" (counter)
- "mysql_exporter_scrape_errors_total" (counter)
- Metric names in the `info_schema.processlist` collector have been [changed](https://github.com/prometheus/mysqld_exporter/pull/603).
- Metric names in the `info_schema.replica_host` collector have been [changed](https://github.com/prometheus/mysqld_exporter/pull/496).
- Changes related to `replication_group_member_stats collector`:
- metric "transaction_in_queue" was Counter instead of Gauge
- renamed 3 metrics starting with `mysql_perf_schema_transaction_` to start with `mysql_perf_schema_transactions_` to be consistent with column names.
- exposing only server's own stats by matching `MEMBER_ID` with `@@server_uuid` resulting "member_id" label to be dropped.

### Other changes

- Bump `mysqld_exporter` version to v0.15.0. (@marctc)

### Features

- Added a new `stage.decolorize` stage to `loki.process` component which
Expand All @@ -30,12 +46,37 @@ Main (unreleased)
- Fixed an issue where `loki.process` validation for stage `metric.counter` was
allowing invalid combination of configuration options. (@thampiotr)

- Fixed issue where adding a module after initial start, that failed to load then subsequently resolving the issue would cause the module to
permanently fail to load with `id already exists` error. (@mattdurham)

### Enhancements

- The `loki.write` WAL now has snappy compression enabled by default. (@thepalbi)

- Allow converting labels to structured metadata with Loki's structured_metadata stage. (@gonzalesraul)

v0.37.2 (2023-10-16)
-----------------

### Bugfixes

- Fix the handling of the `--cluster.join-addresses` flag causing an invalid
comparison with the mutually-exclusive `--cluster.discover-peers`. (@tpaschalis)

- Fix an issue with the static to flow converter for blackbox exporter modules
config not being included in the river output. (@erikbaranowski)

- Fix issue with default values in `discovery.nomad`. (@marctc)

### Enhancements

- The `loki.write` WAL now has snappy compression enabled by default. (@thepalbi)
- Update Prometheus dependency to v2.47.2. (@tpaschalis)

- Allow Out of Order writing to the WAL for metrics. (@mattdurham)

### Other changes

- Use Go 1.21.3 for builds. (@tpaschalis)

v0.37.1 (2023-10-10)
-----------------
Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agent-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.

FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.2 as build
FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.3 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.

FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.2 as build
FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.3 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agent/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM grafana/agent-build-image:0.30.2-windows as builder
FROM grafana/agent-build-image:0.30.3-windows as builder
ARG VERSION
ARG RELEASE_BUILD=1

Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agentctl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.

FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.2 as build
FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.3 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agentctl/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM grafana/agent-build-image:0.30.2-windows as builder
FROM grafana/agent-build-image:0.30.3-windows as builder
ARG VERSION
ARG RELEASE_BUILD=1

Expand Down
4 changes: 2 additions & 2 deletions component/discovery/nomad/nomad.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ func init() {
type Arguments struct {
AllowStale bool `river:"allow_stale,attr,optional"`
HTTPClientConfig config.HTTPClientConfig `river:",squash"`
Namespace string `river:"namespace,attr"`
Namespace string `river:"namespace,attr,optional"`
RefreshInterval time.Duration `river:"refresh_interval,attr,optional"`
Region string `river:"region,attr,optional"`
Server string `river:"server,attr"`
Server string `river:"server,attr,optional"`
TagSeparator string `river:"tag_separator,attr,optional"`
}

Expand Down
22 changes: 21 additions & 1 deletion component/loki/process/stages/structured_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ func (s *structuredMetadataStage) Run(in chan Entry) chan Entry {
processLabelsConfigs(s.logger, e.Extracted, s.cfgs, func(labelName model.LabelName, labelValue model.LabelValue) {
e.StructuredMetadata = append(e.StructuredMetadata, logproto.LabelAdapter{Name: string(labelName), Value: string(labelValue)})
})
return e
return s.extractFromLabels(e)
})
}

func (s *structuredMetadataStage) extractFromLabels(e Entry) Entry {
labels := e.Labels
foundLabels := []model.LabelName{}

for lName, lSrc := range s.cfgs.Values {
labelKey := model.LabelName(*lSrc)
if lValue, ok := labels[labelKey]; ok {
e.StructuredMetadata = append(e.StructuredMetadata, logproto.LabelAdapter{Name: lName, Value: string(lValue)})
foundLabels = append(foundLabels, labelKey)
}
}

// Remove found labels, do this after append to structure metadata
for _, fl := range foundLabels {
delete(labels, fl)
}
e.Labels = labels
return e
}
32 changes: 32 additions & 0 deletions component/loki/process/stages/structured_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ stage.labels {
}
`

var pipelineStagesStructuredMetadataFromStaticLabels = `
stage.static_labels {
values = {"component" = "querier", "pod" = "loki-querier-664f97db8d-qhnwg"}
}
stage.structured_metadata {
values = {"pod" = ""}
}
`

var pipelineStagesStructuredMetadataFromStaticLabelsDifferentKey = `
stage.static_labels {
values = {"component" = "querier", "pod" = "loki-querier-664f97db8d-qhnwg"}
}
stage.structured_metadata {
values = {"pod_name" = "pod"}
}
`

func Test_StructuredMetadataStage(t *testing.T) {
tests := map[string]struct {
pipelineStagesYaml string
Expand Down Expand Up @@ -104,6 +124,18 @@ func Test_StructuredMetadataStage(t *testing.T) {
expectedStructuredMetadata: push.LabelsAdapter{push.LabelAdapter{Name: "app", Value: "loki"}},
expectedLabels: model.LabelSet{model.LabelName("component"): model.LabelValue("ingester")},
},
"expected structured metadata and regular labels to be extracted with static labels stage and to be added to entry": {
pipelineStagesYaml: pipelineStagesStructuredMetadataFromStaticLabels,
logLine: `sample log line`,
expectedStructuredMetadata: push.LabelsAdapter{push.LabelAdapter{Name: "pod", Value: "loki-querier-664f97db8d-qhnwg"}},
expectedLabels: model.LabelSet{model.LabelName("component"): model.LabelValue("querier")},
},
"expected structured metadata and regular labels to be extracted with static labels stage using different structured key": {
pipelineStagesYaml: pipelineStagesStructuredMetadataFromStaticLabelsDifferentKey,
logLine: `sample log line`,
expectedStructuredMetadata: push.LabelsAdapter{push.LabelAdapter{Name: "pod_name", Value: "loki-querier-664f97db8d-qhnwg"}},
expectedLabels: model.LabelSet{model.LabelName("component"): model.LabelValue("querier")},
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
Expand Down
6 changes: 5 additions & 1 deletion component/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sync"
"time"

"github.com/go-kit/log/level"
"github.com/grafana/agent/component"
)

Expand Down Expand Up @@ -71,7 +72,10 @@ func (c *ModuleComponent) LoadFlowSource(args map[string]any, contentValue strin

// RunFlowController runs the flow controller that all module components start.
func (c *ModuleComponent) RunFlowController(ctx context.Context) {
c.mod.Run(ctx)
err := c.mod.Run(ctx)
if err != nil {
level.Error(c.opts.Logger).Log("msg", "error running module", "id", c.opts.ID, "err", err)
}
}

// CurrentHealth contains the implementation details for CurrentHealth in a module component.
Expand Down
7 changes: 4 additions & 3 deletions component/prometheus/exporter/blackbox/blackbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/grafana/agent/component/prometheus/exporter"
"github.com/grafana/agent/pkg/integrations"
"github.com/grafana/agent/pkg/integrations/blackbox_exporter"
"github.com/grafana/agent/pkg/util"
"github.com/grafana/river/rivertypes"
)

Expand Down Expand Up @@ -92,7 +93,6 @@ type Arguments struct {
Config rivertypes.OptionalSecret `river:"config,attr,optional"`
Targets TargetBlock `river:"target,block"`
ProbeTimeoutOffset time.Duration `river:"probe_timeout_offset,attr,optional"`
ConfigStruct blackbox_config.Config
}

// SetToDefault implements river.Defaulter.
Expand All @@ -106,7 +106,8 @@ func (a *Arguments) Validate() error {
return errors.New("config and config_file are mutually exclusive")
}

err := yaml.UnmarshalStrict([]byte(a.Config.Value), &a.ConfigStruct)
var blackboxConfig blackbox_config.Config
err := yaml.UnmarshalStrict([]byte(a.Config.Value), &blackboxConfig)
if err != nil {
return fmt.Errorf("invalid backbox_exporter config: %s", err)
}
Expand All @@ -118,7 +119,7 @@ func (a *Arguments) Validate() error {
func (a *Arguments) Convert() *blackbox_exporter.Config {
return &blackbox_exporter.Config{
BlackboxConfigFile: a.ConfigFile,
BlackboxConfig: a.ConfigStruct,
BlackboxConfig: util.RawYAML(a.Config.Value),
BlackboxTargets: a.Targets.Convert(),
ProbeTimeoutOffset: a.ProbeTimeoutOffset.Seconds(),
}
Expand Down
43 changes: 41 additions & 2 deletions component/prometheus/exporter/blackbox/blackbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/river"
blackbox_config "github.com/prometheus/blackbox_exporter/config"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v2"
)

func TestUnmarshalRiver(t *testing.T) {
Expand Down Expand Up @@ -56,8 +58,11 @@ func TestUnmarshalRiverWithInlineConfig(t *testing.T) {
err := river.Unmarshal([]byte(riverCfg), &args)
require.NoError(t, err)
require.Equal(t, "", args.ConfigFile)
require.Equal(t, args.ConfigStruct.Modules["http_2xx"].Prober, "http")
require.Equal(t, args.ConfigStruct.Modules["http_2xx"].Timeout, 5*time.Second)
var blackboxConfig blackbox_config.Config
err = yaml.UnmarshalStrict([]byte(args.Config.Value), &blackboxConfig)
require.NoError(t, err)
require.Equal(t, blackboxConfig.Modules["http_2xx"].Prober, "http")
require.Equal(t, blackboxConfig.Modules["http_2xx"].Timeout, 5*time.Second)
require.Equal(t, 2, len(args.Targets))
require.Equal(t, 500*time.Millisecond, args.ProbeTimeoutOffset)
require.Contains(t, "target_a", args.Targets[0].Name)
Expand All @@ -67,6 +72,40 @@ func TestUnmarshalRiverWithInlineConfig(t *testing.T) {
require.Contains(t, "http://grafana.com", args.Targets[1].Target)
require.Contains(t, "http_2xx", args.Targets[1].Module)
}

func TestUnmarshalRiverWithInlineConfigYaml(t *testing.T) {
riverCfg := `
config = "modules:\n http_2xx:\n prober: http\n timeout: 5s\n"
target "target_a" {
address = "http://example.com"
module = "http_2xx"
}
target "target_b" {
address = "http://grafana.com"
module = "http_2xx"
}
probe_timeout_offset = "0.5s"
`
var args Arguments
err := river.Unmarshal([]byte(riverCfg), &args)
require.NoError(t, err)
require.Equal(t, "", args.ConfigFile)
var blackboxConfig blackbox_config.Config
err = yaml.UnmarshalStrict([]byte(args.Config.Value), &blackboxConfig)
require.NoError(t, err)
require.Equal(t, blackboxConfig.Modules["http_2xx"].Prober, "http")
require.Equal(t, blackboxConfig.Modules["http_2xx"].Timeout, 5*time.Second)
require.Equal(t, 2, len(args.Targets))
require.Equal(t, 500*time.Millisecond, args.ProbeTimeoutOffset)
require.Contains(t, "target_a", args.Targets[0].Name)
require.Contains(t, "http://example.com", args.Targets[0].Target)
require.Contains(t, "http_2xx", args.Targets[0].Module)
require.Contains(t, "target_b", args.Targets[1].Name)
require.Contains(t, "http://grafana.com", args.Targets[1].Target)
require.Contains(t, "http_2xx", args.Targets[1].Module)
}

func TestUnmarshalRiverWithInvalidInlineConfig(t *testing.T) {
var tests = []struct {
testname string
Expand Down
15 changes: 13 additions & 2 deletions component/prometheus/exporter/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ var DefaultArguments = Arguments{
Filter: ".*",
RemovePrefix: "/var/lib/mysql",
},
PerfSchemaMemoryEvents: PerfSchemaMemoryEvents{
RemovePrefix: "memory/",
},
Heartbeat: Heartbeat{
Database: "heartbeat",
Table: "heartbeat",
Expand Down Expand Up @@ -72,8 +75,10 @@ type Arguments struct {
InfoSchemaTables InfoSchemaTables `river:"info_schema.tables,block,optional"`
PerfSchemaEventsStatements PerfSchemaEventsStatements `river:"perf_schema.eventsstatements,block,optional"`
PerfSchemaFileInstances PerfSchemaFileInstances `river:"perf_schema.file_instances,block,optional"`
Heartbeat Heartbeat `river:"heartbeat,block,optional"`
MySQLUser MySQLUser `river:"mysql.user,block,optional"`
PerfSchemaMemoryEvents PerfSchemaMemoryEvents `river:"perf_schema.memory_events,block,optional"`

Heartbeat Heartbeat `river:"heartbeat,block,optional"`
MySQLUser MySQLUser `river:"mysql.user,block,optional"`
}

// InfoSchemaProcessList configures the info_schema.processlist collector
Expand Down Expand Up @@ -101,6 +106,11 @@ type PerfSchemaFileInstances struct {
RemovePrefix string `river:"remove_prefix,attr,optional"`
}

// PerfSchemaMemoryEvents configures the perf_schema.memory_events collector
type PerfSchemaMemoryEvents struct {
RemovePrefix string `river:"remove_prefix,attr,optional"`
}

// Heartbeat controls the heartbeat collector
type Heartbeat struct {
Database string `river:"database,attr,optional"`
Expand Down Expand Up @@ -144,6 +154,7 @@ func (a *Arguments) Convert() *mysqld_exporter.Config {
PerfSchemaEventsStatementsTextLimit: a.PerfSchemaEventsStatements.TextLimit,
PerfSchemaFileInstancesFilter: a.PerfSchemaFileInstances.Filter,
PerfSchemaFileInstancesRemovePrefix: a.PerfSchemaFileInstances.RemovePrefix,
PerfSchemaMemoryEventsRemovePrefix: a.PerfSchemaMemoryEvents.RemovePrefix,
HeartbeatDatabase: a.Heartbeat.Database,
HeartbeatTable: a.Heartbeat.Table,
HeartbeatUTC: a.Heartbeat.UTC,
Expand Down
10 changes: 10 additions & 0 deletions component/prometheus/exporter/mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func TestRiverConfigUnmarshal(t *testing.T) {
remove_prefix = "instances_remove"
}
perf_schema.memory_events {
remove_prefix = "innodb/"
}
heartbeat {
database = "heartbeat_database"
table = "heartbeat_table"
Expand Down Expand Up @@ -69,6 +73,7 @@ func TestRiverConfigUnmarshal(t *testing.T) {
require.Equal(t, 5, args.PerfSchemaEventsStatements.TextLimit)
require.Equal(t, "instances_filter", args.PerfSchemaFileInstances.Filter)
require.Equal(t, "instances_remove", args.PerfSchemaFileInstances.RemovePrefix)
require.Equal(t, "innodb/", args.PerfSchemaMemoryEvents.RemovePrefix)
require.Equal(t, "heartbeat_database", args.Heartbeat.Database)
require.Equal(t, "heartbeat_table", args.Heartbeat.Table)
require.True(t, args.Heartbeat.UTC)
Expand Down Expand Up @@ -105,6 +110,10 @@ func TestRiverConfigConvert(t *testing.T) {
remove_prefix = "instances_remove"
}
perf_schema.memory_events {
remove_prefix = "innodb/"
}
heartbeat {
database = "heartbeat_database"
table = "heartbeat_table"
Expand Down Expand Up @@ -136,6 +145,7 @@ func TestRiverConfigConvert(t *testing.T) {
require.Equal(t, 5, c.PerfSchemaEventsStatementsTextLimit)
require.Equal(t, "instances_filter", c.PerfSchemaFileInstancesFilter)
require.Equal(t, "instances_remove", c.PerfSchemaFileInstancesRemovePrefix)
require.Equal(t, "innodb/", c.PerfSchemaMemoryEventsRemovePrefix)
require.Equal(t, "heartbeat_database", c.HeartbeatDatabase)
require.Equal(t, "heartbeat_table", c.HeartbeatTable)
require.True(t, c.HeartbeatUTC)
Expand Down
2 changes: 1 addition & 1 deletion component/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Module interface {
//
// Run blocks until the provided context is canceled. The ID of a module as defined in
// ModuleController.NewModule will not be released until Run returns.
Run(context.Context)
Run(context.Context) error
}

// ExportFunc is used for onExport of the Module
Expand Down
Loading

0 comments on commit 55f689a

Please sign in to comment.