-
Notifications
You must be signed in to change notification settings - Fork 259
Expand file tree
/
Copy pathmysql.pp
More file actions
143 lines (138 loc) · 5.04 KB
/
mysql.pp
File metadata and controls
143 lines (138 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Class: datadog_agent::integrations::mysql
#
# This class will install the necessary configuration for the mysql integration
#
# See the sample mysql.d/conf.yaml for all available configuration options
# https://github.com/DataDog/integrations-core/blob/master/mysql/datadog_checks/mysql/data/conf.yaml.example
#
# Parameters:
# $password
# The mysql password for the datadog user
# $host:
# The host mysql is running on
# $user
# The mysql user for the datadog user
# $sock
# Connect mysql via unix socket
# $tags
# Optional array of tags
# $replication
# replication option
# $galera_cluster
# galera cluster option
# $extra_status_metrics
# extra status metrics
# $extra_innodb_metrics
# extra innodb metrics
# $extra_performance_metrics
# extra performance metrics, query run time, 95th precentile avg
# $schema_size_metrics
# schema size metrics
# $disable_innodb_metrics
# disable innodb metrics, used with older versions of MySQL without innodb engine support.
# $dbm
# Database Monitoring for Application Performance Monitoring (APM)
# $queries
# Custom metrics based on MySQL query
# Sample Usage:
#
# class { 'datadog_agent::integrations::mysql' :
# host => 'localhost',
# password => 'some_pass',
# user => 'datadog'
# }
# Sample Usage (Instance):
# class { 'datadog_agent::integrations::mysql' :
# instances => [{
# host => 'localhost',
# password => 'mypassword',
# user => 'datadog',
# port => '3306',
# tags => ['instance:mysql1'],
# replication => '0',
# galera_cluster => '0',
# extra_status_metrics => 'true',
# extra_innodb_metrics => 'true',
# extra_performance_metrics => 'true',
# schema_size_metrics => 'true',
# disable_innodb_metrics => 'false',
# dbm => 'false',
# queries => [
# {
# query => 'SELECT TIMESTAMPDIFF(second,MAX(create_time),NOW()) as last_accessed FROM requests',
# metric => 'app.seconds_since_last_request',
# type => 'gauge',
# field => 'last_accessed',
# },
# ],
# }
# }
#
#
class datadog_agent::integrations::mysql (
String $host = 'localhost',
String $user = 'datadog',
Variant[String, Integer] $port = 3306,
Optional[String] $password = undef,
Optional[String] $sock = undef,
Array $tags = [],
String $replication = '0',
String $galera_cluster = '0',
Boolean $extra_status_metrics = false,
Boolean $extra_innodb_metrics = false,
Boolean $extra_performance_metrics = false,
Boolean $schema_size_metrics = false,
Boolean $disable_innodb_metrics = false,
Optional[Boolean] $dbm = undef,
Array $queries = [],
Optional[Array] $instances = undef,
Array $logs = [],
) inherits datadog_agent::params {
require datadog_agent
if ($host == undef and $sock == undef) or
($host != undef and $port == undef and $sock == undef) {
fail('invalid MySQL configuration')
}
if !$instances and $host {
$_instances = [{
'host' => $host,
'password' => $password,
'user' => $user,
'port' => $port,
'sock' => $sock,
'tags' => $tags,
'replication' => $replication,
'galera_cluster' => $galera_cluster,
'extra_status_metrics' => $extra_status_metrics,
'extra_innodb_metrics' => $extra_innodb_metrics,
'extra_performance_metrics' => $extra_performance_metrics,
'schema_size_metrics' => $schema_size_metrics,
'disable_innodb_metrics' => $disable_innodb_metrics,
'dbm' => $dbm,
'queries' => $queries,
}]
} elsif !$instances {
$_instances = []
} else {
$_instances = $instances
}
$dst_dir = "${datadog_agent::params::conf_dir}/mysql.d"
file { $dst_dir:
ensure => directory,
owner => $datadog_agent::dd_user,
group => $datadog_agent::params::dd_group,
mode => $datadog_agent::params::permissions_directory,
require => Package[$datadog_agent::params::package_name],
notify => Service[$datadog_agent::params::service_name],
}
$dst = "${dst_dir}/conf.yaml"
file { $dst:
ensure => file,
owner => $datadog_agent::dd_user,
group => $datadog_agent::params::dd_group,
mode => $datadog_agent::params::permissions_protected_file,
content => template('datadog_agent/agent-conf.d/mysql.yaml.erb'),
require => Package[$datadog_agent::params::package_name],
notify => Service[$datadog_agent::params::service_name],
}
}