Skip to content

Commit 762daa5

Browse files
author
Seth Cleveland
committed
Adding resource definition for postgres custom metrics (for validation)
1 parent a98533f commit 762daa5

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

manifests/integrations/postgres.pp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@
4444
$password,
4545
$tags = [],
4646
$tables = [],
47-
$custom_metrics = [],
47+
$custom_metrics = {},
4848
) inherits datadog_agent::params {
4949
include datadog_agent
5050

5151
validate_array($tags)
5252
validate_array($tables)
53-
validate_array($custom_metrics)
5453

5554
file { "${datadog_agent::params::conf_dir}/postgres.yaml":
5655
ensure => file,
@@ -61,4 +60,6 @@
6160
require => Package[$datadog_agent::params::package_name],
6261
notify => Service[$datadog_agent::params::service_name],
6362
}
63+
64+
create_resources("datadog_agent::integrations::postgres_custom_metric", $custom_metrics)
6465
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
##
2+
# The postgres_custom_metric defines a custom sql metric.
3+
# https://help.datadoghq.com/hc/en-us/articles/208385813-Postgres-custom-metric-collection-explained
4+
#
5+
# $query:
6+
# The custom metric SQL query. It must contain a '%s' for defining the metrics.
7+
#
8+
# $metrics:
9+
# a hash of column name to metric definition. a metric definition is an array
10+
# consisting of two columns -- the datadog metric name and the metric type.
11+
#
12+
# $relation:
13+
# ?
14+
#
15+
# $descriptor:
16+
# an array that maps an sql column's to a tag. Each descriptor consists of two
17+
# fields -- column name, and datadog tag.
18+
define datadog_agent::integrations::postgres_custom_metric(
19+
$query,
20+
$metrics,
21+
$relation = false,
22+
$descriptors = [],
23+
) {
24+
validate_re($query, '^.*%s.*$')
25+
validate_hash($metrics)
26+
validate_array($descriptors)
27+
}

0 commit comments

Comments
 (0)