
监控踩坑概览
安装监控
Docker安装
uname -ryum -y updatesudo yum remove -y docker*yum install -y yum-utilsyum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache
yum install -y docker-cesystemctl start docker && systemctl enable dockerdocker versioncd etc/docker然后编辑
vim daemon.json{
"registry-mirrors": ["https://jbw52uwf.mirror.aliyuncs.com"]
}
systemctl daemon-reload
systemctl restart docker
下载Prometheus
docker run -d -p 9090:9090 -v etc/prometheus:/etc/prometheus prom/prometheusvim prometheus.yml# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["192.168.56.10:9090"]
# 主要修改这里,添加文件形式的扫描
- job_name: "node"
file_sd_configs:
- refresh_interval: 10s
files:
- "/etc/prometheus/conf/node*.yaml"
mkdir conf)然后通过cd命令进入目录(
cd etc/prometheus/conf)接着使用vim编辑器来修改文件(
vim node-ms.yaml)
- targets:
- "ip:port"
labels:
hostname: pg
下载Grafana
docker run -d -p 3000:3000 --name=grafana --volume grafana-storage:/var/lib/grafana grafana/grafana-enterprise配置数据源


下载Exporter
docker run --net=host -e DATA_SOURCE_NAME="postgresql://opentenbase:@ip:port/postgres?sslmode=disable" quay.io/prometheuscommunity/postgres-exporterCREATE OR REPLACE FUNCTION __tmp_create_user() returns void as $$
BEGIN
IF NOT EXISTS (
SELECT -- SELECT list can stay empty for this
FROM pg_catalog.pg_user
WHERE usename = 'postgres_exporter') THEN
CREATE USER postgres_exporter;
END IF;
END;
$$ language plpgsql;
SELECT __tmp_create_user();
DROP FUNCTION __tmp_create_user();
ALTER USER postgres_exporter WITH PASSWORD 'password';
ALTER USER postgres_exporter SET SEARCH_PATH TO postgres_exporter,pg_catalog;
GRANT CONNECT ON DATABASE postgres TO postgres_exporter;
-- OpenTenBase中集成的PostgreSQL版本是10,所以可以执行以下语句,历史版本可前往开源地址进行查看。
GRANT pg_monitor to postgres_exporter;
postgres_exporter启动报错修复
panic: Error converting setting "session_memory_size" value "3M" to float: strconv.ParseFloat: parsing "3M": invalid syntax
goroutine 42 [running]:
main.(*pgSetting).metric(0xc000081720, 0xc0000d5c50?)
/app/cmd/postgres_exporter/pg_setting.go:87 +0x325
main.querySettings(0x0?, 0xc00010d290)
/app/cmd/postgres_exporter/pg_setting.go:56 +0x287
main.(*Server).Scrape(0xc00010d290, 0xc000028011?, 0x90?)
/app/cmd/postgres_exporter/server.go:121 +0xcb
main.(*Exporter).scrapeDSN(0xc0000000c0, 0x44d406?, {0xc000028011, 0x46})
/app/cmd/postgres_exporter/datasource.go:115 +0x1c5
main.(*Exporter).scrape(0xc0000000c0, 0x0?)
/app/cmd/postgres_exporter/postgres_exporter.go:679 +0x16c
main.(*Exporter).Collect(0xc0000000c0, 0xc00003ff60?)
/app/cmd/postgres_exporter/postgres_exporter.go:568 +0x25
github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func1()
/go/pkg/mod/github.com/prometheus/client_golang@v1.17.0/prometheus/registry.go:457 +0xe7
created by github.com/prometheus/client_golang/prometheus.(*Registry).Gather in goroutine 18
/go/pkg/mod/github.com/prometheus/client_golang@v1.17.0/prometheus/registry.go:547 +0xbab
SELECT name, setting, COALESCE(unit, ''), short_desc, vartype FROM pg_settings WHERE vartype IN ('bool', 'integer', 'real') AND name != 'sync_commit_cancel_wait';


配置监控面板





贡献代码
AtomGit
https://atomgit.com/opentenbase/OpenTenBase
GitHub
https://github.com/OpenTenBase/OpenTenBase
文章转载自OpenAtom OpenTenBase,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




