16
16
forwarder_log_file: /var/log/datadog/forwarder.log
17
17
dogstatsd_log_file: /var/log/datadog/dogstatsd.log
18
18
pup_log_file: /var/log/datadog/pup.log
19
-
20
- # proxy_host: my-proxy.com
21
- # proxy_port: 3128
22
- # proxy_user: user
23
- # proxy_password: password
24
-
25
- # tags: mytag0, mytag1
26
19
${ optionalString ( cfg . tags != null ) "tags: ${ concatStringsSep "," cfg . tags } " }
27
-
28
- # collect_ec2_tags: no
29
- # recent_point_threshold: 30
30
- # use_mount: no
31
- # listen_port: 17123
32
- # graphite_listen_port: 17124
33
- # non_local_traffic: no
34
- # use_curl_http_client: False
35
- # bind_host: localhost
36
-
37
- # use_pup: no
38
- # pup_port: 17125
39
- # pup_interface: localhost
40
- # pup_url: http://localhost:17125
41
-
42
- # dogstatsd_port : 8125
43
- # dogstatsd_interval : 10
44
- # dogstatsd_normalize : yes
45
- # statsd_forward_host: address_of_own_statsd_server
46
- # statsd_forward_port: 8125
47
-
48
- # device_blacklist_re: .*\/dev\/mapper\/lxc-box.*
49
-
50
- # ganglia_host: localhost
51
- # ganglia_port: 8651
20
+ ${ cfg . extraDdConfig }
52
21
'' ;
53
22
54
- diskConfig = pkgs . writeText "disk.yaml" ''
55
- init_config:
56
-
57
- instances:
58
- - use_mount: no
59
- '' ;
60
-
61
- networkConfig = pkgs . writeText "network.yaml" ''
62
- init_config:
63
-
64
- instances:
65
- # Network check only supports one configured instance
66
- - collect_connection_state: false
67
- excluded_interfaces:
68
- - lo
69
- - lo0
70
- '' ;
71
-
72
- postgresqlConfig = pkgs . writeText "postgres.yaml" cfg . postgresqlConfig ;
73
- nginxConfig = pkgs . writeText "nginx.yaml" cfg . nginxConfig ;
74
- mongoConfig = pkgs . writeText "mongo.yaml" cfg . mongoConfig ;
75
- jmxConfig = pkgs . writeText "jmx.yaml" cfg . jmxConfig ;
76
- processConfig = pkgs . writeText "process.yaml" cfg . processConfig ;
77
-
78
23
etcfiles =
79
- let
80
- defaultConfd = import ./dd-agent-defaults.nix ;
81
- in ( map ( f : { source = "${ pkgs . dd-agent } /agent/conf.d-system/${ f } " ;
82
- target = "dd-agent/conf.d/${ f } " ;
83
- } ) defaultConfd ) ++ [
84
- { source = ddConf ;
85
- target = "dd-agent/datadog.conf" ;
86
- }
87
- { source = diskConfig ;
88
- target = "dd-agent/conf.d/disk.yaml" ;
89
- }
90
- { source = networkConfig ;
91
- target = "dd-agent/conf.d/network.yaml" ;
92
- } ] ++
93
- ( optional ( cfg . postgresqlConfig != null )
94
- { source = postgresqlConfig ;
95
- target = "dd-agent/conf.d/postgres.yaml" ;
96
- } ) ++
97
- ( optional ( cfg . nginxConfig != null )
98
- { source = nginxConfig ;
99
- target = "dd-agent/conf.d/nginx.yaml" ;
100
- } ) ++
101
- ( optional ( cfg . mongoConfig != null )
102
- { source = mongoConfig ;
103
- target = "dd-agent/conf.d/mongo.yaml" ;
104
- } ) ++
105
- ( optional ( cfg . processConfig != null )
106
- { source = processConfig ;
107
- target = "dd-agent/conf.d/process.yaml" ;
108
- } ) ++
109
- ( optional ( cfg . jmxConfig != null )
110
- { source = jmxConfig ;
111
- target = "dd-agent/conf.d/jmx.yaml" ;
112
- } ) ;
24
+ map ( i : { source = if builtins . hasAttr "config" i
25
+ then pkgs . writeText "${ i . name } .yaml" i . config
26
+ else "${ pkgs . dd-agent } /agent/conf.d-system/${ i . name } .yaml" ;
27
+ target = "dd-agent/conf.d/${ i . name } .yaml" ;
28
+ }
29
+ ) cfg . integrations ++
30
+ [ { source = ddConf ;
31
+ target = "dd-agent/datadog.conf" ;
32
+ }
33
+ ] ;
34
+
35
+ # restart triggers
36
+ etcSources = map ( i : i . source ) etcfiles ;
113
37
114
38
in {
115
39
options . services . dd-agent = {
@@ -139,44 +63,46 @@ in {
139
63
type = types . uniq ( types . nullOr types . string ) ;
140
64
} ;
141
65
142
- postgresqlConfig = mkOption {
143
- description = "Datadog PostgreSQL integration configuration" ;
144
- default = null ;
145
- type = types . uniq ( types . nullOr types . string ) ;
146
- } ;
147
-
148
- nginxConfig = mkOption {
149
- description = "Datadog nginx integration configuration" ;
150
- default = null ;
151
- type = types . uniq ( types . nullOr types . string ) ;
152
- } ;
153
-
154
- mongoConfig = mkOption {
155
- description = "MongoDB integration configuration" ;
156
- default = null ;
157
- type = types . uniq ( types . nullOr types . string ) ;
158
- } ;
159
-
160
- jmxConfig = mkOption {
161
- description = "JMX integration configuration" ;
162
- default = null ;
163
- type = types . uniq ( types . nullOr types . string ) ;
66
+ agent = mkOption {
67
+ description = "The dd-agent package to use. Useful when overriding the package." ;
68
+ default = pkgs . dd-agent ;
69
+ type = types . package ;
164
70
} ;
165
71
166
- processConfig = mkOption {
72
+ integrations = mkOption {
167
73
description = ''
168
- Process integration configuration
169
-
170
- See http://docs.datadoghq.com/integrations/process/
74
+ Any integrations to use. Default config used if none
75
+ specified. It is currently up to the user to make sure that
76
+ the dd-agent package used has all the dependencies chosen
77
+ integrations require in scope.
78
+ '' ;
79
+ type = types . listOf ( types . attrsOf types . string ) ;
80
+ default = [ ] ;
81
+ example = ''
82
+ [ { name = "elastic";
83
+ config = '''
84
+ init_config:
85
+
86
+ instances:
87
+ - url: http://localhost:9200
88
+ ''' ;
89
+ }
90
+ { name = "nginx"; }
91
+ { name = "ntp"; }
92
+ { name = "network"; }
93
+ ]
171
94
'' ;
172
- default = null ;
173
- type = types . uniq ( types . nullOr types . string ) ;
174
95
} ;
175
96
97
+ extraDdConfig = mkOption {
98
+ description = "Extra settings to append to datadog agent config." ;
99
+ default = "" ;
100
+ type = types . string ;
101
+ } ;
176
102
} ;
177
103
178
104
config = mkIf cfg . enable {
179
- environment . systemPackages = [ pkgs . "dd- agent" pkgs . sysstat pkgs . procps ] ;
105
+ environment . systemPackages = [ cfg . agent pkgs . sysstat pkgs . procps ] ;
180
106
181
107
users . extraUsers . datadog = {
182
108
description = "Datadog Agent User" ;
190
116
191
117
systemd . services . dd-agent = {
192
118
description = "Datadog agent monitor" ;
193
- path = [ pkgs . "dd- agent" pkgs . python pkgs . sysstat pkgs . procps ] ;
119
+ path = [ cfg . agent pkgs . python pkgs . sysstat pkgs . procps ] ;
194
120
wantedBy = [ "multi-user.target" ] ;
195
121
serviceConfig = {
196
122
ExecStart = "${ pkgs . dd-agent } /bin/dd-agent foreground" ;
@@ -199,28 +125,12 @@ in {
199
125
Restart = "always" ;
200
126
RestartSec = 2 ;
201
127
} ;
202
- restartTriggers = [ pkgs . dd-agent ddConf diskConfig networkConfig postgresqlConfig nginxConfig mongoConfig jmxConfig processConfig ] ;
203
- } ;
204
-
205
- systemd . services . dogstatsd = {
206
- description = "Datadog statsd" ;
207
- path = [ pkgs . "dd-agent" pkgs . python pkgs . procps ] ;
208
- wantedBy = [ "multi-user.target" ] ;
209
- serviceConfig = {
210
- ExecStart = "${ pkgs . dd-agent } /bin/dogstatsd start" ;
211
- User = "datadog" ;
212
- Group = "datadog" ;
213
- Type = "forking" ;
214
- PIDFile = "/tmp/dogstatsd.pid" ;
215
- Restart = "always" ;
216
- RestartSec = 2 ;
217
- } ;
218
- restartTriggers = [ pkgs . dd-agent ddConf diskConfig networkConfig postgresqlConfig nginxConfig mongoConfig jmxConfig processConfig ] ;
128
+ restartTriggers = [ pkgs . dd-agent ddConf ] ++ etcSources ;
219
129
} ;
220
130
221
- systemd . services . dd-jmxfetch = lib . mkIf ( cfg . jmxConfig != null ) {
131
+ systemd . services . dd-jmxfetch = lib . mkIf ( builtins . any ( i : i . name == "jmx" ) cfg . integrations ) {
222
132
description = "Datadog JMX Fetcher" ;
223
- path = [ pkgs . "dd- agent" pkgs . python pkgs . sysstat pkgs . procps pkgs . jdk ] ;
133
+ path = [ cfg . agent pkgs . python pkgs . sysstat pkgs . procps pkgs . jdk ] ;
224
134
wantedBy = [ "multi-user.target" ] ;
225
135
serviceConfig = {
226
136
ExecStart = "${ pkgs . dd-agent } /bin/dd-jmxfetch" ;
229
139
Restart = "always" ;
230
140
RestartSec = 2 ;
231
141
} ;
232
- restartTriggers = [ pkgs . dd- agent ddConf diskConfig networkConfig postgresqlConfig nginxConfig mongoConfig jmxConfig ] ;
142
+ restartTriggers = [ cfg . agent ddConf ] ++ etcSources ;
233
143
} ;
234
144
235
145
environment . etc = etcfiles ;
0 commit comments