at master 1.2 kB view raw
1{ pkgs, lib, ... }: 2{ 3 name = "fluentd"; 4 5 nodes.machine = 6 { pkgs, ... }: 7 { 8 services.fluentd = { 9 enable = true; 10 config = '' 11 <source> 12 @type http 13 port 9880 14 </source> 15 16 <match **> 17 type copy 18 <store> 19 @type file 20 format json 21 path /tmp/fluentd 22 symlink_path /tmp/current-log 23 </store> 24 <store> 25 @type stdout 26 </store> 27 </match> 28 ''; 29 }; 30 }; 31 32 testScript = 33 let 34 testMessage = "an example log message"; 35 36 payload = pkgs.writeText "test-message.json" ( 37 builtins.toJSON { 38 inherit testMessage; 39 } 40 ); 41 in 42 '' 43 machine.start() 44 machine.wait_for_unit("fluentd.service") 45 machine.wait_for_open_port(9880) 46 47 machine.succeed( 48 "curl -fsSL -X POST -H 'Content-type: application/json' -d @${payload} http://localhost:9880/test.tag" 49 ) 50 51 # blocking flush 52 machine.succeed("systemctl stop fluentd") 53 54 machine.succeed("grep '${testMessage}' /tmp/current-log") 55 ''; 56}