From f9b48f0b067fa99afa485c2aecf3dfec99028033 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Wed, 3 Apr 2024 12:49:22 +0300 Subject: [PATCH] PMM-3303 Monitor internal clickhouse --- managed/services/victoriametrics/prometheus.go | 8 ++++---- .../services/victoriametrics/scrape_configs.go | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/managed/services/victoriametrics/prometheus.go b/managed/services/victoriametrics/prometheus.go index 717868763f..2e6ed372c8 100644 --- a/managed/services/victoriametrics/prometheus.go +++ b/managed/services/victoriametrics/prometheus.go @@ -17,13 +17,12 @@ package victoriametrics import ( "github.com/AlekSi/pointer" + "github.com/percona/pmm/managed/models" + "github.com/percona/pmm/version" config "github.com/percona/promconfig" "github.com/pkg/errors" "github.com/sirupsen/logrus" "gopkg.in/reform.v1" - - "github.com/percona/pmm/managed/models" - "github.com/percona/pmm/version" ) // AddScrapeConfigs - adds agents scrape configuration to given scrape config, @@ -209,7 +208,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)) diff --git a/managed/services/victoriametrics/scrape_configs.go b/managed/services/victoriametrics/scrape_configs.go index 6c05e6c716..fc54b785eb 100644 --- a/managed/services/victoriametrics/scrape_configs.go +++ b/managed/services/victoriametrics/scrape_configs.go @@ -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",