Skip to content

Commit

Permalink
Adding resource definition for postgres custom metrics (for validation)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seth Cleveland committed Aug 16, 2016
1 parent b221189 commit ba02244
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
5 changes: 3 additions & 2 deletions manifests/integrations/postgres.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@
$password,
$tags = [],
$tables = [],
$custom_metrics = [],
$custom_metrics = {},
) inherits datadog_agent::params {
include datadog_agent

validate_array($tags)
validate_array($tables)
validate_array($custom_metrics)

file { "${datadog_agent::params::conf_dir}/postgres.yaml":
ensure => file,
Expand All @@ -61,4 +60,6 @@
require => Package[$datadog_agent::params::package_name],
notify => Service[$datadog_agent::params::service_name],
}

create_resources("datadog_agent::integrations::postgres_custom_metric", $custom_metrics)
}
27 changes: 27 additions & 0 deletions manifests/integrations/postgres_custom_metric.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
##
# The postgres_custom_metric defines a custom sql metric.
# https://help.datadoghq.com/hc/en-us/articles/208385813-Postgres-custom-metric-collection-explained
#
# $query:
# The custom metric SQL query. It must contain a '%s' for defining the metrics.
#
# $metrics:
# a hash of column name to metric definition. a metric definition is an array
# consisting of two columns -- the datadog metric name and the metric type.
#
# $relation:
# ?
#
# $descriptor:
# an array that maps an sql column's to a tag. Each descriptor consists of two
# fields -- column name, and datadog tag.
define datadog_agent::integrations::postgres_custom_metric(
$query,
$metrics,
$relation = false,
$descriptors = [],
) {
validate_re($query, '^.*%s.*$')
validate_hash($metrics)
validate_array($descriptors)
}

0 comments on commit ba02244

Please sign in to comment.