Skip to content

Commit

Permalink
cluster/prometheus: tikv accelerate rules if version 3 (#1463)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvisa authored Jul 1, 2021
1 parent 1d98db5 commit 6d88e56
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integrate-cluster-cmd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
matrix:
cases:
- 'test_cmd'
# - "test_cmd_tls_native_ssh"
# - 'test_cmd_tls_native_ssh'
- 'test_upgrade'
# - "test_upgrade_tls"
- 'test_upgrade_tls'
env:
working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
steps:
Expand Down
2 changes: 2 additions & 0 deletions embed/templates/config/prometheus.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ rule_files:
{{- end}}
{{- if .TiKVStatusAddrs}}
- 'tikv.rules.yml'
{{- if .HasTiKVAccelerateRules}}
- 'tikv.accelerate.rules.yml'
{{- end}}
{{- end}}
{{- if .TiFlashStatusAddrs}}
- 'tiflash.rules.yml'
{{- end}}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/spec/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (i *MonitorInstance) InitConfig(

// transfer config
fp = filepath.Join(paths.Cache, fmt.Sprintf("prometheus_%s_%d.yml", i.GetHost(), i.GetPort()))
cfig := config.NewPrometheusConfig(clusterName, enableTLS)
cfig := config.NewPrometheusConfig(clusterName, clusterVersion, enableTLS)
if monitoredOptions != nil {
cfig.AddBlackbox(i.GetHost(), uint64(monitoredOptions.BlackboxExporterPort))
}
Expand Down
14 changes: 11 additions & 3 deletions pkg/cluster/template/config/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"text/template"

"github.com/pingcap/tiup/embed"
"golang.org/x/mod/semver"
)

// PrometheusConfig represent the data to generate Prometheus config
Expand All @@ -46,6 +47,7 @@ type PrometheusConfig struct {
BlackboxAddr string
KafkaExporterAddr string
GrafanaAddr string
HasTiKVAccelerateRules bool

DMMasterAddrs []string
DMWorkerAddrs []string
Expand All @@ -55,11 +57,17 @@ type PrometheusConfig struct {
}

// NewPrometheusConfig returns a PrometheusConfig
func NewPrometheusConfig(cluster string, enableTLS bool) *PrometheusConfig {
return &PrometheusConfig{
ClusterName: cluster,
func NewPrometheusConfig(clusterName, clusterVersion string, enableTLS bool) *PrometheusConfig {
cfg := &PrometheusConfig{
ClusterName: clusterName,
TLSEnabled: enableTLS,
}

// tikv.accelerate.rules.yml was first introduced in v4.0.0
if semver.Compare(clusterVersion, "v4.0.0") >= 0 {
cfg.HasTiKVAccelerateRules = true
}
return cfg
}

// AddKafka add a kafka address
Expand Down

0 comments on commit 6d88e56

Please sign in to comment.