seqcli
seqcli copied to clipboard
Powershell tail
I'm not sure why but Get-Content .\myLogFile.log -Tail 1 -Wait | seqcli ingest -json does not work.
Nothing gets to logged to seq, not sure even how to debug it
But this works
Get-Content .\neptune20211008.log -Tail 1 -Wait | % { $_ | seqcli ingest -json }
I suspect the latter is not optimized cause it will ingest one line at a time
Howdy! Is it possible the argument 1 to -Tail is throwing things off? I.e. if you just -Tail without the count, does it work as expected?
You're right about the performance of the second option above - invoking seqcli for each line will be slow 👍
The -Tail needs a value. It means read the last X lines. Without the -Wait it works. from the docs the -Wait argument "Keeps the file open after all existing lines have been output. While waiting, Get-Content checks the file once each second and outputs new lines if present" Maybe there is no good way to do this in posh...
Well I figured out why the first one does not work. Powershell pipelines are they're own kind of thing https://www.sapien.com/blog/2019/05/13/advanced-powershell-functions-begin-to-process-to-end/
But I still have the problem how to pipe efficiently. My best guess would be a manual loop+sleep and calling ingest in each iteration
Closing this one as stale, but thanks for all the discussion 👍