数据库线程数 dmdbms_thread_num_info
数据库事务等待数 dmdbms_trx_info
数据库死锁数 dmdbms_dead_lock_num_info
数据库的状态 dmdbms_status_info
数据库启动时间 dmdbms_start_time_info
数据库QPS数量 dmdbms_qps_count
数据库TPS数量 dmdbms_tps_count
主备集群同步延迟 dmdbms_rapply_stat
表空间总大小 dmdbms_tablespace_size_total_info
表空间空闲大小 dmdbms_tablespace_size_free_info
表空间数据文件总大小 dmdbms_tablespace_file_total_info
表空间数据文件空闲大小 dmdbms_tablespace_file_free_info
数据库会话数状态 dmdbms_session_type_info
数据库实例的错误事件 dmdbms_instance_log_error_info
查询内存池的当前使用状态 dmdbms_memory_curr_pool_info
查询内存池的配置上限 dmdbms_memory_total_pool_info
数据库活动会话执行延迟监控 dmdbms_waiting_session
数据库的最大连接数 dmdbms_connect_session
数据库授权查询 dmdbms_license_date
数据库定时任务错误 dmdbms_joblog_error_num
监控监视器进程 dmdbms_monitor_info
监控慢SQL语句 dmdbms_slow_sql_info
备库重演运行线程数 dmdbms_rapply_sys_task_num
备库重演内存堆积信息 dmdbms_rapply_sys_task_mem_used
数据库语句类型数量展示逻辑 dmdbms_statement_type_info
检查点更新 dmdbms_ckpttime_info
检查用户信息 dmdbms_user_list_info
数据库版本 dmdbms_version
数据库启动天数 dmdbms_start_day
数据库归档状态 dmdbms_arch_status
dmap进程探活 dmdbms_dmap_process_is_exit
dmserver进程探活 dmdbms_dmserver_process_is_exit
dmwatcher进程探活 dmdbms_dmwatcher_process_is_exit
dmmonitor进程探活 dmdbms_dmmonitor_process_is_exit
dmagent进程探活 dmdbms_dmagent_process_is_exit
可查看这个:https://blog.csdn.net/qq_35349982/article/details/140700625
https://github.com/gaoyuan98/dameng_exporter/releases
dameng_exporter_v1.0.0_linux_amd64.tar.gz(linux_x86平台)
dameng_exporter_v1.0.0_linux_arm64.tar.gz(linux_arm平台)
dameng_exporter_v1.0.0_windows_amd64.tar.gz(window_x64平台)
## 新建用户
create tablespace "PROMETHEUS.DBF" datafile 'PROMETHEUS.DBF' size 512 CACHE = NORMAL;
create user "PROMETHEUS" identified by "PROMETHEUS";
alter user "PROMETHEUS" default tablespace "PROMETHEUS.DBF" default index tablespace "PROMETHEUS.DBF";
## 条件允许的话 最好赋予DBA权限
grant "PUBLIC","RESOURCE","SOI","SVI","VTI" to "PROMETHEUS";
## 最小化权限
GRANT SELECT ON V$SYSSTAT TO PROMETHEUS;
GRANT SELECT ON V$SESSIONS TO PROMETHEUS;
GRANT SELECT ON V$LICENSE TO PROMETHEUS;
GRANT SELECT ON V$DATABASE TO PROMETHEUS;
GRANT SELECT ON V$DM_INI TO PROMETHEUS;
GRANT SELECT ON V$RLOGFILE TO PROMETHEUS;
GRANT SELECT ON V$TABLESPACE TO PROMETHEUS;
GRANT SELECT ON V$DATAFILE TO PROMETHEUS;
GRANT SELECT ON DBA_DATA_FILES TO PROMETHEUS;
GRANT SELECT ON DBA_FREE_SPACE TO PROMETHEUS;
GRANT SELECT ON V$TRXWAIT TO PROMETHEUS;
GRANT SELECT ON V$CKPT TO PROMETHEUS;
GRANT SELECT ON V$RAPPLY_SYS TO PROMETHEUS;
GRANT SELECT ON V$PROCESS TO PROMETHEUS;
GRANT SELECT ON V$LOCK TO PROMETHEUS;
GRANT SELECT ON V$THREADS TO PROMETHEUS;
## 启动服务
[root@VM-24-17-centos dm_prometheus]# nohup ./dameng_exporter_v1.0.0_linux_amd64 > /dev/null 2>&1 &
## 2. 访问接口
## 通过浏览器访问http://被监控端IP:9200/metrics
[root@server ~]# lsof -i:9200
修改prometheus的prometheus.yml配置文件
# 添加的是数据库监控的接口9200接口,如果是一套集群,则在targets标签后进行逗号拼接,如下图所示
# 注意 cluster_name标签不能改,提供的模板用该标签做分类
- job_name: "dm_db_single"
static_configs:
- targets: ["192.168.112.135:9200"]
labels:
cluster_name: '单机测试'
登录grafana登录,导入模板
所使用的模板在表盘中
效果图
在exporter的同级目录下创建一个custom_metrics.toml文件,注意文件权限,编写SQL即可。写法与(oracledb_exporter)类似
[[metric]]
context = "context_with_labels"
request = "SELECT 1 as value_1, 2 as value_2, 'First label' as label_1, 'Second label' as label_2 FROM DUAL"
metricsdesc = { value_1 = "Simple example returning always 1 as counter.", value_2 = "Same but returning always 2 as gauge." }
该文件在导出器中生成以下条目:
# HELP dmdbms_context_no_label_value_1 Simple example returning always 1.
# TYPE dmdbms_context_no_label_value_1 gauge
dmdbms_context_no_label_value_1{host_name="gy"} 1
# HELP dmdbms_context_no_label_value_2 Same but returning always 2.
# TYPE dmdbms_context_no_label_value_2 gauge
dmdbms_context_no_label_value_2{host_name="gy"} 2
自定义标签的例子:
[[metric]]
context = "context_with_labels"
labels = [ "label_1", "label_2" ]
request = "SELECT 1 as value_1, 2 as value_2, 'First label' as label_1, 'Second label' as label_2 FROM DUAL"
metricsdesc = { value_1 = "Simple example returning always 1 as counter.", value_2 = "Same but returning always 2 as gauge." }
# Can be counter or gauge (default)
metricstype = { value_1 = "counter" }
该文件在导出器中生成以下条目:
# HELP dmdbms_context_with_labels_value_1 Simple example returning always 1 as counter.
# TYPE dmdbms_context_with_labels_value_1 counter
dmdbms_context_with_labels_value_1{host_name="gy",label_1="First label",label_2="Second label"} 1
# HELP dmdbms_context_with_labels_value_2 Same but returning always 2 as gauge.
# TYPE dmdbms_context_with_labels_value_2 gauge
dmdbms_context_with_labels_value_2{host_name="gy",label_1="First label",label_2="Second label"} 2
[[metric]]
context = "test_table_metrics"
labels = [ "name"]
request = "SELECT name,TO_CHAR(TOTAL_SIZE*PAGE/1024/1024) AS total_size_mb FROM SYS.V$TABLESPACE"
metricsdesc = { total_size_mb = "Simple example"}
该文件在导出器中生成以下条目:
# HELP dmdbms_test_table_metrics_total_size_mb Simple example
# TYPE dmdbms_test_table_metrics_total_size_mb gauge
dmdbms_test_table_metrics_total_size_mb{host_name="gy",name="DMEAGLE"} 1024
dmdbms_test_table_metrics_total_size_mb{host_name="gy",name="DMEAGLE_DEV"} 1024
dmdbms_test_table_metrics_total_size_mb{host_name="gy",name="MAIN"} 2176
dmdbms_test_table_metrics_total_size_mb{host_name="gy",name="ROLL"} 128
dmdbms_test_table_metrics_total_size_mb{host_name="gy",name="SYSTEM"} 138
dmdbms_test_table_metrics_total_size_mb{host_name="gy",name="TEMP"} 74