| 
									
										
										
										
											2019-11-06 12:40:43 +01:00
										 |  |  | import ./make-test-python.nix ({ pkgs, ...} : { | 
					
						
							| 
									
										
										
										
											2019-01-21 11:30:11 +00:00
										 |  |  |   name = "telegraf"; | 
					
						
							| 
									
										
										
										
											2021-01-10 20:08:30 +01:00
										 |  |  |   meta = with pkgs.lib.maintainers; { | 
					
						
							| 
									
										
										
										
											2019-01-21 11:30:11 +00:00
										 |  |  |     maintainers = [ mic92 ]; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   machine = { ... }: { | 
					
						
							|  |  |  |     services.telegraf.enable = true; | 
					
						
							| 
									
										
										
										
											2020-11-18 21:30:29 +01:00
										 |  |  |     services.telegraf.environmentFiles = [(pkgs.writeText "secrets" ''
 | 
					
						
							| 
									
										
										
										
											2020-09-08 07:59:50 +02:00
										 |  |  |       SECRET=example | 
					
						
							| 
									
										
										
										
											2020-11-18 21:30:29 +01:00
										 |  |  |     '')];
 | 
					
						
							| 
									
										
										
										
											2019-01-21 11:30:11 +00:00
										 |  |  |     services.telegraf.extraConfig = { | 
					
						
							|  |  |  |       agent.interval = "1s"; | 
					
						
							|  |  |  |       agent.flush_interval = "1s"; | 
					
						
							|  |  |  |       inputs.exec = { | 
					
						
							|  |  |  |         commands = [ | 
					
						
							| 
									
										
										
										
											2020-09-08 07:59:50 +02:00
										 |  |  |           "${pkgs.runtimeShell} -c 'echo $SECRET,tag=a i=42i'" | 
					
						
							| 
									
										
										
										
											2019-01-21 11:30:11 +00:00
										 |  |  |         ]; | 
					
						
							|  |  |  |         timeout = "5s"; | 
					
						
							|  |  |  |         data_format = "influx"; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       outputs.file.files = ["/tmp/metrics.out"]; | 
					
						
							|  |  |  |       outputs.file.data_format = "influx"; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   testScript = ''
 | 
					
						
							| 
									
										
										
										
											2019-11-06 12:40:43 +01:00
										 |  |  |     start_all() | 
					
						
							| 
									
										
										
										
											2019-01-21 11:30:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-06 12:40:43 +01:00
										 |  |  |     machine.wait_for_unit("telegraf.service") | 
					
						
							|  |  |  |     machine.wait_until_succeeds("grep -q example /tmp/metrics.out") | 
					
						
							| 
									
										
										
										
											2019-01-21 11:30:11 +00:00
										 |  |  |   '';
 | 
					
						
							|  |  |  | }) |