seqcli icon indicating copy to clipboard operation
seqcli copied to clipboard

Powershell tail

Open pitermarx opened this issue 4 years ago • 3 comments

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

pitermarx avatar Oct 08 '21 10:10 pitermarx

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 👍

nblumhardt avatar Oct 09 '21 00:10 nblumhardt

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...

pitermarx avatar Oct 09 '21 14:10 pitermarx

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

pitermarx avatar Nov 02 '21 17:11 pitermarx

Closing this one as stale, but thanks for all the discussion 👍

nblumhardt avatar Jul 10 '24 04:07 nblumhardt