Finished up log tailing.

This commit is contained in:
Eric Fontana
2014-07-22 10:26:04 -04:00
parent 1e271d5592
commit 613faaf49f
19 changed files with 352 additions and 330 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
@@ -20,9 +21,9 @@ namespace TimberWinR.ServiceHost
private static void Main(string[] args)
{
Arguments arguments = new Arguments();
HostFactory.Run(hostConfigurator =>
{
{
string cmdLine = Environment.CommandLine;
hostConfigurator.Service<TimberWinRService>(serviceConfigurator =>
@@ -55,23 +56,23 @@ namespace TimberWinR.ServiceHost
}
}
internal class TimberWinRService
{
readonly CancellationTokenSource _cancellationTokenSource;
readonly CancellationToken _cancellationToken;
readonly Task _serviceTask;
private readonly Arguments _args;
private TcpInputListener _nlogListener;
private TcpInputListener _nlogListener;
public TimberWinRService(Arguments args)
{
_args = args;
_cancellationTokenSource = new CancellationTokenSource();
_cancellationToken = _cancellationTokenSource.Token;
_serviceTask = new Task(RunService, _cancellationToken);
_serviceTask = new Task(RunService, _cancellationToken);
}
public void Start()
{
_serviceTask.Start();
@@ -82,21 +83,16 @@ namespace TimberWinR.ServiceHost
_cancellationTokenSource.Cancel();
_nlogListener.Shutdown();
}
/// <summary>
/// The Main body of the Service Worker Thread
/// </summary>
private void RunService()
{
TimberWinR.Manager manager = new TimberWinR.Manager(_args.ConfigFile);
// logaggregator.vistaprint.svc
//var outputRedis = new RedisOutput(new string[] { "tstlexiceapp006.vistaprint.svc", "tstlexiceapp007.vistaprint.svc" }, _cancellationToken);
var outputRedis = new RedisOutput(manager, new string[] { "logaggregator.vistaprint.svc" }, _cancellationToken);
// var outputRedis = new RedisOutput(new string[] { "prdlexicelgs001.vistaprint.svc" }, _cancellationToken);
var outputRedis = new RedisOutput(new string[] { "logaggregator.vistaprint.svc" }, _cancellationToken);
_nlogListener = new TcpInputListener(_cancellationToken, 5140);
outputRedis.Connect(_nlogListener);
@@ -105,18 +101,18 @@ namespace TimberWinR.ServiceHost
var elistner = new IISW3CInputListener(iisw3cConfig, _cancellationToken);
outputRedis.Connect(elistner);
}
foreach (Configuration.WindowsEvent eventConfig in manager.Config.Events)
{
var elistner = new WindowsEvtInputListener(eventConfig, _cancellationToken);
outputRedis.Connect(elistner);
}
//while (!_cancellationTokenSource.IsCancellationRequested)
//{
// System.Threading.Thread.Sleep(1000);
//}
foreach (var logConfig in manager.Config.Logs)
{
var elistner = new TailFileInputListener(logConfig, _cancellationToken);
outputRedis.Connect(elistner);
}
}
}
}

View File

@@ -60,6 +60,11 @@
<Name>TimberWinR</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="sampleconf.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<TimberWinR>
<Inputs>
<WindowsEvents>
<Event source="System,Application" binaryFormat="PRINT" />
</WindowsEvents>
<Logs>
<Log name="Syslogs" location="C:\Logs1\*.log" />
</Logs>
<IISW3CLogs>
<IISW3CLog name="Default site" location="c:\inetpub\logs\LogFiles\W3SVC1\*" />
</IISW3CLogs>
</Inputs>
<Filters>
<Grok>
<!--Single Tag-->
<Match field="Text" value="%{SYSLOGLINE}" />
<DropIfMatch value="true" />
<!--Multiple Tag allowed -->
<AddField name="field1" value="%{foo}" />
<AddField name="field2" value="%{foo}" />
<RemoveField value="ip1" />
<RemoveField value="ip2" />
<!--Verify field 'name' is unique also target unique -->
<Date field="timestamp" target="@timestamp" convertToUTC="true">
<Pattern>MMM d HH:mm:ss</Pattern>
<Pattern>MMM dd HH:mm:ss</Pattern>
<Pattern>ISO8601</Pattern>
</Date>
<Date field="timestamp2" target="@timestamp2" convertToUTC="false">
<Pattern>MMM d HH:mm:ss</Pattern>
<Pattern>MMM dd HH:mm:ss</Pattern>
<Pattern>ISO8601</Pattern>
</Date>
</Grok>
</Filters>
</TimberWinR>