From e67d7f47a7ec3f3e823a8ab279df3df10992dc3c Mon Sep 17 00:00:00 2001 From: Pierre Le Noan <144696725+pierreln-dd@users.noreply.github.com> Date: Wed, 12 Nov 2025 10:02:35 +0100 Subject: [PATCH 1/3] Update query duration metrics in metadata.csv --- postgres/metadata.csv | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/postgres/metadata.csv b/postgres/metadata.csv index 0dee2e32cbe82..c09ef56516066 100644 --- a/postgres/metadata.csv +++ b/postgres/metadata.csv @@ -108,8 +108,8 @@ postgresql.pg_stat_statements.dealloc,count,,,,The number of times pg_stat_state postgresql.queries.blk_read_time,count,,nanosecond,,"Total time spent reading blocks per query_signature, db, and user. (DBM only)",0,postgres, postgres queries block read time,, postgresql.queries.blk_write_time,count,,nanosecond,,"Total time spent writing blocks per query_signature, db, and user. (DBM only)",0,postgres, postgres queries block write time,, postgresql.queries.count,count,,query,,"The total query execution count per query_signature, db, and user. (DBM only)",0,postgres,postgres queries count,, -postgresql.queries.duration.max,gauge,,nanosecond,,"The age of the longest running query per user, db and app. (DBM only)",0,postgres,postgres queries duration max,, -postgresql.queries.duration.sum,gauge,,nanosecond,,"The sum of the age of all running queries per user, db and app. (DBM only)",0,postgres,postgres queries duration sum,, +postgresql.queries.duration.max,gauge,,nanosecond,,"The age of the longest completed query per user, db and app. (DBM only)",0,postgres,postgres queries duration max,, +postgresql.queries.duration.sum,gauge,,nanosecond,,"The sum of the age of all completed queries per user, db and app. (DBM only)",0,postgres,postgres queries duration sum,, postgresql.queries.local_blks_dirtied,count,,block,,"Total number of local blocks dirtied per query_signature, db, and user. (DBM only)",0,postgres,postgres queries local blocks dirtied,, postgresql.queries.local_blks_hit,count,,block,,"Total number of local block cache hits per query_signature, db, and user. (DBM only)",0,postgres,postgres queries local blocks hit,, postgresql.queries.local_blks_read,count,,block,,"Total number of local blocks read per query_signature, db, and user. (DBM only)",0,postgres,postgres queries local blocks read,, @@ -236,4 +236,4 @@ postgresql.wal_receiver.last_msg_receipt_age,gauge,,second,,Time since the recep postgresql.wal_receiver.last_msg_send_age,gauge,,second,,The age of the latest message's send time received from the WAL sender. This metric is tagged with status.,0,postgres,wal receiver send age,, postgresql.wal_receiver.latest_end_age,gauge,,second,,Time since the reception of the last message from the WAL sender with an WAL location update. This metric is tagged with status.,0,postgres,wal receiver latest end,, postgresql.wal_receiver.received_timeline,gauge,,,,"Timeline number of last write-ahead log location received and flushed to disk, the initial value of this field being the timeline number of the first log location used when WAL receiver is started. This metric is tagged with status.",0,postgres,wal receiver tli,, -postgresql.wal_size,gauge,,byte,,The sum of all WAL files on disk.,-1,postgres,wal size,, \ No newline at end of file +postgresql.wal_size,gauge,,byte,,The sum of all WAL files on disk.,-1,postgres,wal size,, From bccf04e7c86b2580509fe9190769d58990d7456b Mon Sep 17 00:00:00 2001 From: Pierre Le Noan <144696725+pierreln-dd@users.noreply.github.com> Date: Thu, 13 Nov 2025 09:55:58 +0100 Subject: [PATCH 2/3] Update query duration metrics in metadata.csv Change from completed to executed --- postgres/metadata.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postgres/metadata.csv b/postgres/metadata.csv index c09ef56516066..f401cac8cce32 100644 --- a/postgres/metadata.csv +++ b/postgres/metadata.csv @@ -108,8 +108,8 @@ postgresql.pg_stat_statements.dealloc,count,,,,The number of times pg_stat_state postgresql.queries.blk_read_time,count,,nanosecond,,"Total time spent reading blocks per query_signature, db, and user. (DBM only)",0,postgres, postgres queries block read time,, postgresql.queries.blk_write_time,count,,nanosecond,,"Total time spent writing blocks per query_signature, db, and user. (DBM only)",0,postgres, postgres queries block write time,, postgresql.queries.count,count,,query,,"The total query execution count per query_signature, db, and user. (DBM only)",0,postgres,postgres queries count,, -postgresql.queries.duration.max,gauge,,nanosecond,,"The age of the longest completed query per user, db and app. (DBM only)",0,postgres,postgres queries duration max,, -postgresql.queries.duration.sum,gauge,,nanosecond,,"The sum of the age of all completed queries per user, db and app. (DBM only)",0,postgres,postgres queries duration sum,, +postgresql.queries.duration.max,gauge,,nanosecond,,"The age of the longest executed query per user, db and app. (DBM only)",0,postgres,postgres queries duration max,, +postgresql.queries.duration.sum,gauge,,nanosecond,,"The sum of the age of all executed queries per user, db and app. (DBM only)",0,postgres,postgres queries duration sum,, postgresql.queries.local_blks_dirtied,count,,block,,"Total number of local blocks dirtied per query_signature, db, and user. (DBM only)",0,postgres,postgres queries local blocks dirtied,, postgresql.queries.local_blks_hit,count,,block,,"Total number of local block cache hits per query_signature, db, and user. (DBM only)",0,postgres,postgres queries local blocks hit,, postgresql.queries.local_blks_read,count,,block,,"Total number of local blocks read per query_signature, db, and user. (DBM only)",0,postgres,postgres queries local blocks read,, From 182660b24375ab80bacfaac12f803950357b4328 Mon Sep 17 00:00:00 2001 From: pierreln-dd Date: Thu, 20 Nov 2025 15:15:15 +0100 Subject: [PATCH 3/3] sync config file --- .../postgres/data/conf.yaml.example | 79 ++++++++++--------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/postgres/datadog_checks/postgres/data/conf.yaml.example b/postgres/datadog_checks/postgres/data/conf.yaml.example index ecd7669cdecf4..e28beb4b60f34 100644 --- a/postgres/datadog_checks/postgres/data/conf.yaml.example +++ b/postgres/datadog_checks/postgres/data/conf.yaml.example @@ -309,48 +309,51 @@ instances: ## Each query must have 2 fields, and can have a third optional field: ## ## 1. query - The SQL to execute. It can be a simple statement or a multi-line script. - ## Use the pipe `|` if you require a multi-line script. + ## Use the pipe `|` if you require a multi-line script. ## 2. columns - The list representing each column, ordered sequentially from left to right. - ## The number of columns must equal the number of columns returned in the query. - ## There are 2 required pieces of data: - ## 1. name - The suffix to append to `.` to form - ## the full metric name. If `type` is a `tag` type, this column is considered a tag and applied - ## to every metric collected by this particular query. - ## 2. type - The submission method (gauge, monotonic_count, etc.). - ## This can also be set to the following `tag` types to tag each metric in the row with the name - ## and value of the item in this column: - ## 1. tag - This is the default tag type - ## 2. tag_list - This allows multiple values to be attached to the tag name. For example: - ## ``` - ## query = { - ## "name": "example", - ## "query": "...", - ## "columns": [ - ## {"name": "server_tag", "type": "tag_list"}, - ## {"name": "foo", "type": "gauge"}, - ## ] - ## } - ## ``` - ## May result in: - ## ``` - ## gauge("foo", tags=["server_tag:us", "server_tag:primary", "server_tag:default"]) - ## gauge("foo", tags=["server_tag:eu"]) - ## gauge("foo", tags=["server_tag:eu", "server_tag:primary"]) - ## ``` - ## 3. tag_not_null - This only sets tags in the metric if the value is not null - ## You can use the `count` type to perform aggregation for queries that return multiple rows with - ## the same or no tags. - ## Columns without a name are ignored. To skip a column, enter: - ## ``` - ## - {} - ## ``` + ## The number of columns must equal the number of columns returned in the query. + ## There are 2 required pieces of data: + ## a. name - The suffix to append to `.` to form + ## the full metric name. If `type` is a `tag` type, this column is + ## considered a tag and applied to every + ## metric collected by this particular query. + ## b. type - The submission method (gauge, monotonic_count, etc.). + ## This can also be set to the following `tag` types to + ## tag each metric in the row with the name and value + ## of the item in this column: + ## i. tag - This is the default tag type + ## ii. tag_list - This allows multiple values to be attached + ## to the tag name. For example: + ## + ## query = { + ## "name": "example", + ## "query": "...", + ## "columns": [ + ## {"name": "server_tag", "type": "tag_list"}, + ## {"name": "foo", "type": "gauge"}, + ## ] + ## } + ## + ## May result in: + ## gauge("foo", tags=[ + ## "server_tag:us", + ## "server_tag:primary", + ## "server_tag:default" + ## ]) + ## gauge("foo", tags=["server_tag:eu"]) + ## gauge("foo", tags=["server_tag:eu", "server_tag:primary"]) + ## iii. tag_not_null - This only sets tags in the metric if the value is not null + ## You can use the `count` type to perform aggregation + ## for queries that return multiple rows with the same or no tags. + ## Columns without a name are ignored. To skip a column, enter: + ## - {} ## 3. tags (optional) - A list of tags to apply to each metric. ## 4. collection_interval (optional) - The frequency at which to collect the metrics. ## If collection_interval is not set, the query will be run every check run. - ## If the collection interval is less than check collection interval, the query will be run every check - ## run. - ## If the collection interval is greater than check collection interval, the query will NOT BE RUN - ## exactly at the collection interval. + ## If the collection interval is less than check collection interval, + ## the query will be run every check run. + ## If the collection interval is greater than check collection interval, + ## the query will NOT BE RUN exactly at the collection interval. ## The query will be run at the next check run after the collection interval has passed. ## 5. metric_prefix (optional) - The prefix to apply to each metric. #