NOTE: You are looking at documentation for an older release. For the latest information, see the current release documentation.
PostgreSQL statement metricset
editPostgreSQL statement metricset
editThis is the statement
metricset of the PostgreSQL module.
This module collects information from the pg_stat_statements
view, that keeps
track of planning and execution statistics of all SQL statements executed by
the server.
pg_stat_statements
is included by an additional module in PostgreSQL. This
module requires additional shared memory, and is disabled by default.
You can enable it by adding this module to the configuration as a shared preloaded library.
shared_preload_libraries = 'pg_stat_statements' pg_stat_statements.max = 10000 pg_stat_statements.track = all
Preloading this library in your server will increase the memory usage of your PostgreSQL server. Use it with care.
Once the server is started with this module, it starts collecting statistics
about all statements executed. To make these statistics available in the
pg_stat_statements
view, the following statement needs to be executed in the
server:
CREATE EXTENSION pg_stat_statements;
You can read more about the available options for this module in the official documentation.
The PostgreSQL module of Filebeat is also able to collect information about statements executed in the server from its logs. You may chose which one is better for your needings. An important difference is that the Metricbeat module collects aggregated information when the statement is executed several times, but cannot know when each statement was executed. This information can be obtained from logs.
Fields
editFor a description of each field in the metricset, see the exported fields section.
Here is an example document generated by this metricset:
{ "@timestamp": "2017-10-12T08:05:34.853Z", "beat": { "hostname": "host.example.com", "name": "host.example.com" }, "metricset": { "host": "postgresql:5432", "module": "postgresql", "name": "statement", "rtt": 115 }, "postgresql": { "statement": { "user": { "id": 10 }, "database": { "oid": "12407" }, "query": { "id": "3240664890", "text": "SELECT pg_sleep(?);", "calls": "2", "rows": "2", "time": { "total": 120066.497, "min": 60029.533, "max": 60036.964, "mean": 60033.2485, "stddev": 3.71549999999843 }, "memory": { "shared": { "hit": 0, "read": 0, "dirtied": 0, "written": 0, }, "local": { "hit": 0, "read": 0, "dirtied": 0, "written": 0, }, "temp": { "read": 0, "written": 0, } } } } } }