Skip to content

Commit

Permalink
Parameterize metrics collector args
Browse files Browse the repository at this point in the history
Allows passing extra args to metrics exporter to e.g. enable/configure
additional metrics collectors.
  • Loading branch information
stankevich committed Jan 30, 2020
1 parent 9cb9694 commit 2b3567d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
7 changes: 7 additions & 0 deletions config/crds/mysql_v1alpha1_mysqlcluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ spec:
is removed from service.
format: int64
type: integer
metricsExporterExtraArgs:
description: MetricsExporterExtraArgs is a list of extra command line
arguments to pass to MySQL metrics exporter. See https://github.com/prometheus/mysqld_exporter
for the list of available flags.
items:
type: string
type: array
minAvailable:
description: The number of pods from that set that must still be available
after the eviction, even in the absence of the evicted pod Defaults
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/mysql/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ type MysqlClusterSpec struct {
// Set a custom offset for Server IDs. ServerID for each node will be the index of the statefulset, plus offset
// +optional
ServerIDOffset *int `json:"serverIDOffset,omitempty"`

// MetricsExporterExtraArgs is a list of extra command line arguments to pass to MySQL metrics exporter.
// See https://github.com/prometheus/mysqld_exporter for the list of available flags.
// +optional
MetricsExporterExtraArgs []string `json:"metricsExporterExtraArgs,omitempty"`
}

// MysqlConf defines type for extra cluster configs. It's a simple map between
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/mysql/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions pkg/controller/mysqlcluster/internal/syncer/statefullset.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,22 @@ func (s *sfsSyncer) ensureContainersSpec() []core.Container {
})

// METRICS container
exporterCommand := []string{
fmt.Sprintf("--web.listen-address=0.0.0.0:%d", ExporterPort),
fmt.Sprintf("--web.telemetry-path=%s", ExporterPath),
"--collect.heartbeat",
fmt.Sprintf("--collect.heartbeat.database=%s", constants.OperatorDbName),
}

if len(s.cluster.Spec.MetricsExporterExtraArgs) > 0 {
exporterCommand = append(exporterCommand, s.cluster.Spec.MetricsExporterExtraArgs...)
}

exporter := s.ensureContainer(containerExporterName,
s.opt.MetricsExporterImage,
[]string{
fmt.Sprintf("--web.listen-address=0.0.0.0:%d", ExporterPort),
fmt.Sprintf("--web.telemetry-path=%s", ExporterPath),
"--collect.heartbeat",
fmt.Sprintf("--collect.heartbeat.database=%s", constants.OperatorDbName),
},
exporterCommand,
)

exporter.Ports = ensurePorts(core.ContainerPort{
Name: ExporterPortName,
ContainerPort: ExporterPort,
Expand Down

0 comments on commit 2b3567d

Please sign in to comment.