Skip to content

Commit

Permalink
PMM-3303 Monitor internal clickhouse (#2943)
Browse files Browse the repository at this point in the history
* PMM-3303 Monitor internal clickhouse

* PMM-3303 Fix linter

* PMM-3303 Fix tests

---------

Co-authored-by: Roman Novikov <[email protected]>
  • Loading branch information
BupycHuk and rnovikovP authored May 7, 2024
1 parent 0ed5396 commit 87ab44e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion managed/services/victoriametrics/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ func AddInternalServicesToScrape(cfg *config.Config, s models.MetricsResolutions
scrapeConfigForAlertmanager(s.MR),
scrapeConfigForGrafana(s.MR),
scrapeConfigForPMMManaged(s.MR),
scrapeConfigForQANAPI2(s.MR))
scrapeConfigForQANAPI2(s.MR),
scrapeConfigForClickhouse(s.MR))
// TODO Refactor to remove boolean positional parameter when Prometheus is removed
if dbaas {
cfg.ScrapeConfigs = append(cfg.ScrapeConfigs, scrapeConfigForDBaaSController(s.MR))
Expand Down
15 changes: 15 additions & 0 deletions managed/services/victoriametrics/scrape_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ func scrapeConfigForAlertmanager(interval time.Duration) *config.ScrapeConfig {
}
}

func scrapeConfigForClickhouse(mr time.Duration) *config.ScrapeConfig {
return &config.ScrapeConfig{
JobName: "clickhouse",
ScrapeInterval: config.Duration(mr),
ScrapeTimeout: scrapeTimeout(mr),
MetricsPath: "/metrics",
ServiceDiscoveryConfig: config.ServiceDiscoveryConfig{
StaticConfigs: []*config.Group{{
Targets: []string{"127.0.0.1:9363"},
Labels: map[string]string{"instance": "pmm-server"},
}},
},
}
}

func scrapeConfigForGrafana(interval time.Duration) *config.ScrapeConfig {
return &config.ScrapeConfig{
JobName: "grafana",
Expand Down
22 changes: 22 additions & 0 deletions managed/services/victoriametrics/victoriametrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,17 @@ scrape_configs:
labels:
instance: pmm-server
follow_redirects: false
- job_name: clickhouse
honor_timestamps: false
scrape_interval: 10s
scrape_timeout: 9s
metrics_path: /metrics
static_configs:
- targets:
- 127.0.0.1:9363
labels:
instance: pmm-server
follow_redirects: false
- job_name: mongodb_exporter_agent_id_cfec996c-4fe6-41d9-83cb-e1a3b1fe10a8_hr
honor_timestamps: false
scrape_interval: 5s
Expand Down Expand Up @@ -890,6 +901,17 @@ scrape_configs:
labels:
instance: pmm-server
follow_redirects: false
- job_name: clickhouse
honor_timestamps: false
scrape_interval: 10s
scrape_timeout: 9s
metrics_path: /metrics
static_configs:
- targets:
- 127.0.0.1:9363
labels:
instance: pmm-server
follow_redirects: false
`) + "\n"
newcfg, err := svc.marshalConfig(svc.loadBaseConfig())
assert.NoError(t, err)
Expand Down
11 changes: 11 additions & 0 deletions managed/testdata/victoriametrics/promscrape.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,14 @@ scrape_configs:
labels:
instance: pmm-server
follow_redirects: false
- job_name: clickhouse
honor_timestamps: false
scrape_interval: 10s
scrape_timeout: 9s
metrics_path: /metrics
static_configs:
- targets:
- 127.0.0.1:9363
labels:
instance: pmm-server
follow_redirects: false

0 comments on commit 87ab44e

Please sign in to comment.