|
17 | 17 | # $username |
18 | 18 | # The username for the datadog user |
19 | 19 | # $ssl |
20 | | -# Boolean to enable SSL |
| 20 | +# This option determines whether or not and with what priority a secure SSL TCP/IP connection |
| 21 | +# is negotiated with the server. There are six modes: |
| 22 | +# - `disable`: Only tries a non-SSL connection. |
| 23 | +# - `allow`: First tries a non-SSL connection; if if fails, tries an SSL connection. |
| 24 | +# - `prefer`: First tries an SSL connection; if it fails, tries a non-SSL connection. |
| 25 | +# - `require`: Only tries an SSL connection. If a root CA file is present, verifies the certificate in |
| 26 | +# the same way as if verify-ca was specified. |
| 27 | +# - `verify-ca`: Only tries an SSL connection, and verifies that the server certificate is issued by a |
| 28 | +# trusted certificate authority (CA). |
| 29 | +# - `verify-full`: Only tries an SSL connection and verifies that the server certificate is issued by a |
| 30 | +# trusted CA and that the requested server host name matches the one in the certificate. |
| 31 | +# |
| 32 | +# For a detailed description of how these options work see https://www.postgresql.org/docs/current/libpq-ssl.html |
21 | 33 | # $use_psycopg2 |
22 | 34 | # Boolean to flag connecting to postgres with psycopg2 instead of pg8000. |
23 | 35 | # Warning, psycopg2 doesn't support ssl mode. |
|
41 | 53 | # (10 + 10 per index) |
42 | 54 | # $tags |
43 | 55 | # Optional array of tags |
| 56 | +# $custom_metrics |
| 57 | +# A hash of custom metrics with the following keys - query, metrics, |
| 58 | +# relation, descriptors. Refer to this guide for details on those fields: |
| 59 | +# https://help.datadoghq.com/hc/en-us/articles/208385813-Postgres-custom-metric-collection-explained |
44 | 60 | # |
45 | 61 | # Sample Usage: |
46 | 62 | # |
|
50 | 66 | # username => 'datadog', |
51 | 67 | # password => 'some_pass', |
52 | 68 | # ssl => false, |
| 69 | +# custom_metrics => { |
| 70 | +# a_custom_query => { |
| 71 | +# query => "select tag_column, %s from table", |
| 72 | +# relation => false, |
| 73 | +# metrics => { |
| 74 | +# value_column => ["value_column.datadog.tag", "GAUGE"] |
| 75 | +# }, |
| 76 | +# descriptors => [ |
| 77 | +# ["tag_column", "tag_column.datadog.tag"] |
| 78 | +# ] |
| 79 | +# } |
| 80 | +# } |
53 | 81 | # } |
54 | 82 | # |
55 | 83 | # Hiera Usage: |
|
59 | 87 | # dbname: 'postgres' |
60 | 88 | # username: 'datadog' |
61 | 89 | # password: 'some_pass' |
62 | | -# ssl: false |
| 90 | +# ssl: 'allow' |
| 91 | +# custom_metrics: |
| 92 | +# a_custom_query: |
| 93 | +# query: 'select tag_column, %s from table' |
| 94 | +# relation: false |
| 95 | +# metrics: |
| 96 | +# value_column: ["value_column.datadog.tag", "GAUGE"] |
| 97 | +# descriptors: |
| 98 | +# - ["tag_column", "tag_column.datadog.tag"] |
63 | 99 | # |
64 | 100 | class datadog_agent::integrations::postgres ( |
65 | 101 | Optional[String] $password = undef, |
66 | 102 | String $host = 'localhost', |
67 | 103 | String $dbname = 'postgres', |
68 | 104 | Variant[String, Integer] $port = '5432', |
69 | 105 | String $username = 'datadog', |
70 | | - Boolean $ssl = false, |
| 106 | + String $ssl = 'allow', |
71 | 107 | Boolean $use_psycopg2 = false, |
72 | 108 | Boolean $collect_function_metrics = false, |
73 | 109 | Boolean $collect_count_metrics = false, |
|
76 | 112 | Boolean $collect_default_database = false, |
77 | 113 | Array[String] $tags = [], |
78 | 114 | Array[String] $tables = [], |
| 115 | + Hash $custom_metrics = {}, |
79 | 116 | Optional[Array] $instances = undef, |
80 | 117 | ) inherits datadog_agent::params { |
81 | 118 | require datadog_agent |
|
103 | 140 | 'use_psycopg2' => $use_psycopg2, |
104 | 141 | 'tags' => $tags, |
105 | 142 | 'tables' => $tables, |
| 143 | + 'custom_metrics' => $custom_metrics, |
106 | 144 | 'collect_function_metrics' => $collect_function_metrics, |
107 | 145 | 'collect_count_metrics' => $collect_count_metrics, |
108 | 146 | 'collect_activity_metrics' => $collect_activity_metrics, |
|
124 | 162 | require => Package[$datadog_agent::params::package_name], |
125 | 163 | notify => Service[$datadog_agent::params::service_name], |
126 | 164 | } |
| 165 | + |
| 166 | + create_resources('datadog_agent::integrations::postgres_custom_metric', $custom_metrics) |
127 | 167 | } |
0 commit comments