Adding PostgreSQL Databases/Tables Size Dashboard to the Percona Monitoring and Management ...

栏目: IT技术 · 发布时间: 5年前

内容简介:It will use some custom queries in order to fetch such information, so we need to create a file with a custom query. Postgresql exporter is processing such files by default, so you should place your file into one of the paths referred to below, to the desi

Adding PostgreSQL Databases/Tables Size Dashboard to the Percona Monitoring and Management ... This blog post is about how you can gain detailed information in Percona Monitoring and Management (PMM2) of PostgreSQL disk usage. We take a look at using a catalog called pg_class , which catalogs tables and most everything else that has columns or is otherwise similar to a table. This includes indexes, sequences, views, materialized views, composite types, and toast tables.

It will use some custom queries in order to fetch such information, so we need to create a file with a custom query. Postgresql exporter is processing such files by default, so you should place your file into one of the paths referred to below, to the desired scraping interval and restart the exporter.

/usr/local/percona/pmm2/collectors/custom-queries/postgresql/low-resolution

/usr/local/percona/pmm2/collectors/custom-queries/postgresql/medium-resolution

/usr/local/percona/pmm2/collectors/custom-queries/postgresql/high-resolution

# /etc/init.d/pmm-agent restart
Stopping pmm-agent:                                        [  OK  ]
Starting pmm-agent:                                        [  OK  ]

FYI, the metrics scraping interval can be set on the tab “PMM Settings”:

Adding PostgreSQL Databases/Tables Size Dashboard to the Percona Monitoring and Management ...

Setting up Query Monitoring in PMM for Postgres

First of all, we have to enable the extension dblink . It’s a PostgreSQL contrib extension that allows users to connect to other databases and run arbitrary queries in them.

postgres=# CREATE EXTENSION dblink;
CREATE EXTENSION
 
postgres=# \dx
                                       List of installed extensions
        Name        | Version |   Schema   |                         Description                           
--------------------+---------+------------+--------------------------------------------------------------
 dblink             | 1.2     | public     | connect to other PostgreSQL databases from within a database
 pg_stat_statements | 1.6     | public     | track execution statistics of all SQL statements executed 
 plpgsql            | 1.0     | pg_catalog | PL/pgSQL procedural language
(3 rows)

The next step is to create a query for collecting data from tables. We propose using our bash script that generates a query and forms other fields for a custom query file. You have to specify the database name, or names, that will be monitored. You can store the result of the script in a separate file or can extend an existing file with queries.

$ ./postgres_query_size_generator.sh sbtest sbtest2 >> queries-postgres-2.yml

Now it’s time to restart exporter and check the newly collected metrics.

  • pg_class_rows
  • pg_class_total
  • pg_class_index
  • pg_class_toast

Also, you can upload our dashboard in order to checks queries through the Grafana interface. It has got all PMM2 elements such as variables, menu, annotations.

Here is a screenshot from our test installation.

Adding PostgreSQL Databases/Tables Size Dashboard to the Percona Monitoring and Management ...


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

绝对价值

绝对价值

[美] 伊塔马尔·西蒙森 艾曼纽·罗森 / 钱峰 / 中国友谊出版公司 / 2014-7 / 45.00元

绝对价值指的是经用户体验的产品质量,即使用某件产品或者享受某项服务的切实感受。 过去,消费就像是押宝。一件商品好不好,一家餐馆的环境如何,没有亲身体验过消费者无从得知,只能根据营销人员提供的有限信息去猜测。品牌、原产地、价位、广告,这些重要的质量线索左右着消费者的选择。 然而,互联网和新兴科技以一种前所未有的速度改变了商业环境。当消费者可以在购买前查看到交易记录和消费者评价,通过便捷的......一起来看看 《绝对价值》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具