Git Product home page Git Product logo

greenplum_exporter's Introduction

Greenplum-exporter

基于go语言为Greenplum集成普罗米修斯(prometheus)的监控数据采集器。

项目地址:

一、编译方法

  • centos系统下编译

(1) 环境安装

wget https://gomirrors.org/dl/go/go1.14.12.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.14.12.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct

(2) 软件编译

git clone https://github.com/tangyibo/greenplum_exporter
cd greenplum_exporter/ && make build
cd bin && ls -l
  • docker环境下编译
git clone https://github.com/tangyibo/greenplum_exporter
cd greenplum_exporter/
sh docker-build.sh

二、 启动采集器

  • centos系统下
export GPDB_DATA_SOURCE_URL=postgres://gpadmin:[email protected]:5432/postgres?sslmode=disable
./greenplum_exporter --web.listen-address="0.0.0.0:9297" --web.telemetry-path="/metrics" --log.level=error
  • docker运行
docker run -d -p 9297:9297 -e GPDB_DATA_SOURCE_URL=postgres://gpadmin:[email protected]:5432/postgres?sslmode=disable inrgihc/greenplum-exporter:latest 

注:环境变量GPDB_DATA_SOURCE_URL指定了连接Greenplum数据库的连接串(请使用gpadmin账号连接postgres库),该连接串以postgres://为前缀,具体格式如下:

postgres://gpadmin:[email protected]:5432/postgres?sslmode=disable
postgres://[数据库连接账号,必须为gpadmin]:[账号密码,即gpadmin的密码]@[数据库的IP地址]:[数据库端口号]/[数据库名称,必须为postgres]?[参数名]=[参数值]&[参数名]=[参数值]

然后访问监控指标的URL地址: http://127.0.0.1:9297/metrics

更多启动参数:

usage: greenplum_exporter [<flags>]

Flags:
  -h, --help                   Show context-sensitive help (also try --help-long and --help-man).
      --web.listen-address="0.0.0.0:9297"  
                               web endpoint
      --web.telemetry-path="/metrics"  
                               Path under which to expose metrics.
      --disableDefaultMetrics  do not report default metrics(go metrics and process metrics)
      --version                Show application version.
      --log.level="info"       Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]
      --log.format="logger:stderr"  
                               Set the log target and format. Example: "logger:syslog?appname=bob&local=7" or "logger:stdout?json=true"

三、支持的监控指标

No. 指标名称 类型 标签组 度量单位 指标描述 数据源获取方法
1 greenplum_cluster_state Gauge version; master(master主机名);standby(standby主机名) boolean gp 可达状态 ?:1→ 可用;0→ 不可用 SELECT count(*) from gp_dist_random('gp_id'); select version(); SELECT hostname from p_segment_configuration where content=-1 and role='p';
2 greenplum_cluster_uptime Gauge - int 启动持续的时间 select extract(epoch from now() - pg_postmaster_start_time());
3 greenplum_cluster_sync Gauge - int Master同步Standby状态? 1→ 正常;0→ 异常 SELECT count(*) from pg_stat_replication where state='streaming'
4 greenplum_cluster_max_connections Gauge - int 最大连接个数 show max_connections; show superuser_reserved_connections;
5 greenplum_cluster_total_connections Gauge - int 当前连接个数 select count(*) total, count(*) filter(where current_query='') idle, count(*) filter(where current_query<>'') active, count(*) filter(where current_query<>'' and not waiting) running, count(*) filter(where current_query<>'' and waiting) waiting from pg_stat_activity where procpid <> pg_backend_pid();
6 greenplum_cluster_idle_connections Gauge - int idle连接数 同上
7 greenplum_cluster_active_connections Gauge - int active query 同上
8 greenplum_cluster_running_connections Gauge - int query executing 同上
9 greenplum_cluster_waiting_connections Gauge - int query waiting execute 同上
10 greenplum_node_segment_status Gauge hostname; address; dbid; content; preferred_role; port; replication_port int segment的状态status: 1(U)→ up; 0(D)→ down select * from gp_segment_configuration;
11 greenplum_node_segment_role Gauge hostname; address; dbid; content; preferred_role; port; replication_port int segment的role角色: 1(P)→ primary; 2(M)→ mirror 同上
12 greenplum_node_segment_mode Gauge hostname; address; dbid; content; preferred_role; port; replication_port int segment的mode:1(S)→ Synced; 2(R)→ Resyncing; 3(C)→ Change Tracking; 4(N)→ Not Syncing 同上
13 greenplum_node_segment_disk_free_mb_size Gauge hostname MB segment主机磁盘空间剩余大小(MB) SELECT dfhostname as segment_hostname,sum(dfspace)/count(dfspace)/(1024*1024) as segment_disk_free_gb from gp_toolkit.gp_disk_free GROUP BY dfhostname
14 greenplum_cluster_total_connections_per_client Gauge client int 每个客户端的total连接数 select usename, count() total, count() filter(where current_query='') idle, count(*) filter(where current_query<>'') active from pg_stat_activity group by 1;
15 greenplum_cluster_idle_connections_per_client Gauge client int 每个客户端的idle连接数 同上
16 greenplum_cluster_active_connections_per_client Gauge client int 每个客户端的active连接数 同上
17 greenplum_cluster_total_online_user_count Gauge - int 在线账号数 同上
18 greenplum_cluster_total_client_count Gauge - int 当前所有连接的客户端个数 同上
19 greenplum_cluster_total_connections_per_user Gauge usename int 每个账号的total连接数 select client_addr, count() total, count() filter(where current_query='') idle, count(*) filter(where current_query<>'') active from pg_stat_activity group by 1;
20 greenplum_cluster_idle_connections_per_user Gauge usename int 每个账号的idle连接数 同上
21 greenplum_cluster_active_connections_per_user Gauge usename int 每个账号的active连接数 同上
22 greenplum_cluster_config_last_load_time_seconds Gauge - int 系统配置加载时间 SELECT pg_conf_load_time()
23 greenplum_node_database_name_mb_size Gauge dbname MB 每个数据库占用的存储空间大小 SELECT dfhostname as segment_hostname,sum(dfspace)/count(dfspace)/(1024*1024) as segment_disk_free_gb from gp_toolkit.gp_disk_free GROUP BY dfhostname
24 greenplum_node_database_table_total_count Gauge dbname - 每个数据库内表的总数量 SELECT count(*) as total from information_schema.tables where table_schema not in ('gp_toolkit','information_schema','pg_catalog');
25 greenplum_exporter_total_scraped Counter - int - -
26 greenplum_exporter_total_error Counter - int - -
27 greenplum_exporter_scrape_duration_second Gauge - int - -
28 greenplum_server_users_name_list Gauge - int 用户总数 SELECT usename from pg_catalog.pg_user;
29 greenplum_server_users_total_count Gauge - int 用户明细 同上
30 greenplum_server_locks_table_detail Gauge pid;datname;usename;locktype;mode;application_name;state;lock_satus;query int 锁信息 SELECT * from pg_locks
31 greenplum_server_database_hit_cache_percent_rate Gauge - float 缓存命中率 select sum(blks_hit)/(sum(blks_read)+sum(blks_hit))*100 from pg_stat_database;
32 greenplum_server_database_transition_commit_percent_rate Gauge - float 事务提交率 select sum(xact_commit)/(sum(xact_commit)+sum(xact_rollback))*100 from pg_stat_database;
32 greenplum_server_database_table_bloat_list Gauge - int 数据膨胀列表 select * from gp_toolkit.gp_bloat_diag;
33 greenplum_server_database_table_skew_list Gauge - int 数据倾斜列表 select * from gp_toolkit.gp_skew_coefficients;

四、Grafana图

  • Dashboard

Grafana Dashboard ID: 13822

Grafana Dashboard URL: https://grafana.com/grafana/dashboards/13822

  • 配置教程

可参考文章:https://blog.csdn.net/inrgihc/article/details/108686638

五、问题反馈

如果您看到或使用了本工具,或您觉得本工具对您有价值,请为此项目点个赞!!

greenplum_exporter's People

Contributors

cobolbaby avatar tangyibo avatar yuqaf1989 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

greenplum_exporter's Issues

服务启动后无法访问 http://0.0.0.0:9297/metrics

Greenplum Database 6.18.2

[root@iZ2ze0ree1kf7ccu4p1vcyZ ~]# systemctl status greenplum_exporter
● greenplum_exporter.service - greenplum exporter 
  Loaded: loaded (/etc/systemd/system/greenplum_exporter.service; enabled; vendor preset: disabled)  
 Active: active (running) since Wed 2022-08-03 23:07:37 CST; 17min ago Main PID: 325168 (greenplum_expor)
 Tasks: 6 (limit: 47779)
  Memory: 13.0M
  CGroup: /system.slice/greenplum_exporter.service
           └─325168 /usr/local/greenplum_exporter/bin/greenplum_exporter --log.level=error

Aug 03 23:07:37 iZ2ze0ree1kf7ccu4p1vcyZ systemd[1]: greenplum_exporter.service: Succeeded.
Aug 03 23:07:37 iZ2ze0ree1kf7ccu4p1vcyZ systemd[1]: Stopped greenplum exporter.
Aug 03 23:07:37 iZ2ze0ree1kf7ccu4p1vcyZ systemd[1]: Started greenplum exporter.
[root@iZ2ze0ree1kf7ccu4p1vcyZ ~]# netstat -tlnp | grep 9297tcp6       0      0 :::9297                 :::*                    LISTEN      325168/greenplum_ex 

exporter连接问题

在docker容器中运行该命令

 docker run -d -p 9297:9297 --name gp_exporter  -e GPDB_DATA_SOURCE_URL=postgres://gpadmin:LcGp\[email protected]:5432/postgres?sslmode=disable  docker.io/inrgihc/greenplum_exporter:1.1

报错:
time="2021-10-20T09:27:57Z" level=error msg="check database connection failed, error:pq: syntax error at or near "["" source="collector.go:83"
请问是哪里的问题,求大神解答

各数据库表数量不正确

GP版本:6.3
GP_exporter:1.1
你好,我配置的test库连接,但其他数据库的表数量都是test库的表数量,如何解决?
image
image

locks_scraper failed: converting NULL to string is unsupported

time="2022-03-17T03:56:10Z" level=error msg="get metrics for scraper, error:sql: Scan error on column index 6, name "state": converting NULL to string is unsupported" source="locks.go:122"
time="2022-03-17T03:56:10Z" level=error msg="get metrics for scraper:locks_scraper failed, error:sql: Scan error on column index 6, name "state": converting NULL to string is unsupported" source="collector.go:100"

非管理员用户监控时需要配置的权限

  • 赋权操作,避免报“权限不足”
\c postgres;
GRANT USAGE ON SCHEMA gp_toolkit to gp_monitor;
GRANT ALL ON ALL TABLES IN SCHEMA gp_toolkit to gp_monitor;
  • 特别注意

pg_stat_activity 的访问权限,普通用户查看的时候虽然不报权限不足,但看到的信息不全。

Grafana Dashboard问题汇总

现在的 Dashboard 强制约束了 Prometheus 数据源的名称,这个在导入时不太友好,还请加个变量通用化一点。

支持greenplum4.x

怎么支持greenplum4.x的数据库呢
目前启动之后访问ip:9297/metrics
会报错 error:pq: syntax error at or near "[""
连接数据库失败了,但是我找了一下,go都是这样连接pg数据库的

Confirm your license.

Hello, I'm a DBA at Kakao in Korea. I implemented a greenplum exporter to monitor Greenplum, and our next step was to make our code open-source.
However, I noticed that many aspects of our code have similarities with this GitHub snippet, because queries in our code and the exporter implementation are based on Greenplum and Prometheus, respectively. We'd like to reconfirm that there's no license of your code, you've noted in the LICENSE file. Please confirm if we can use freely.
We are looking forward to your reply.
Thank you.

gp5.x数据膨胀/切斜缺少指标数据采集

image
这俩指标没加吗?我拉取最新代码编译的,监控gp5.x集群。没有这俩指标,以--log.level=info启动查看日志也没有指标对应的数据库查询。请问是bug还是不支持gp5.x。谢谢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.