diff --git a/TimberWinR.ServiceHost/sampleconf.xml b/TimberWinR.ServiceHost/sampleconf.xml index aae2822..7f7c12d 100644 --- a/TimberWinR.ServiceHost/sampleconf.xml +++ b/TimberWinR.ServiceHost/sampleconf.xml @@ -15,26 +15,12 @@ - - - - - - - - - - - - MMM d HH:mm:ss - MMM dd HH:mm:ss - ISO8601 - - - MMM d HH:mm:ss - MMM dd HH:mm:ss - ISO8601 - + + + MMM d HH:mm:ss + MMM dd HH:mm:ss + ISO8601 + diff --git a/TimberWinR.UnitTests/Configuration.cs b/TimberWinR.UnitTests/Configuration.cs index ff93ddf..18eae67 100644 --- a/TimberWinR.UnitTests/Configuration.cs +++ b/TimberWinR.UnitTests/Configuration.cs @@ -332,7 +332,7 @@ namespace TimberWinR.UnitTests bool dropIfMatch = true; string removeField = "ip1"; - TimberWinR.Configuration.Grok grok = c.Groks.ToArray()[0]; + TimberWinR.Filters.GrokFilter grok = c.Groks.ToArray()[0]; Assert.AreEqual(match, grok.Match); Assert.AreEqual(addField, grok.AddField); diff --git a/TimberWinR/Configuration.cs b/TimberWinR/Configuration.cs index 2afb1c0..bb08b30 100644 --- a/TimberWinR/Configuration.cs +++ b/TimberWinR/Configuration.cs @@ -8,6 +8,7 @@ using System.Xml.Linq; using System.IO; using System.Globalization; using TimberWinR.Inputs; +using TimberWinR.Filters; using System.Xml.Schema; using NLog; @@ -115,9 +116,9 @@ namespace TimberWinR get { return _iisw3clogs; } } - private static List _groks = new List(); + private static List _groks = new List(); - public IEnumerable Groks + public IEnumerable Groks { get { return _groks; } } @@ -476,7 +477,7 @@ namespace TimberWinR { case "Grok": Params_Grok args = parseParams_Grok(e.Elements()); - Grok grok = new Grok(args); + GrokFilter grok = new GrokFilter(args); _groks.Add(grok); break; case "Mutate": @@ -1476,39 +1477,7 @@ namespace TimberWinR } } - public class Grok - { - public string Match { get; private set; } - public string Field { get; private set; } - public Pair AddField { get; private set; } - public bool DropIfMatch { get; private set; } - public string RemoveField { get; private set; } - - public Grok(Params_Grok args) - { - Match = args.Match; - Field = args.Field; - AddField = args.AddField; - DropIfMatch = args.DropIfMatch; - RemoveField = args.RemoveField; - } - - public override string ToString() - { - StringBuilder sb = new StringBuilder(); - sb.Append("Grok\n"); - foreach (var prop in this.GetType().GetProperties()) - { - if (prop != null) - { - sb.Append(String.Format("\t{0}: {1}\n", prop.Name, prop.GetValue(this, null))); - } - - } - return sb.ToString(); - } - } - + public class Params_Grok { public string Match { get; private set; } diff --git a/TimberWinR/Filters/DateFilter.cs b/TimberWinR/Filters/DateFilter.cs new file mode 100644 index 0000000..ef31a37 --- /dev/null +++ b/TimberWinR/Filters/DateFilter.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TimberWinR.Filters +{ + public class DateFilter : FilterBase + { + public override void Apply(Newtonsoft.Json.Linq.JObject json) + { + throw new NotImplementedException(); + } + } +} diff --git a/TimberWinR/Filters/FilterBase.cs b/TimberWinR/Filters/FilterBase.cs new file mode 100644 index 0000000..ddf30b1 --- /dev/null +++ b/TimberWinR/Filters/FilterBase.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Newtonsoft.Json.Linq; + +namespace TimberWinR.Filters +{ + public abstract class FilterBase + { + public abstract void Apply(JObject json); + } +} diff --git a/TimberWinR/Filters/GrokFilter.cs b/TimberWinR/Filters/GrokFilter.cs new file mode 100644 index 0000000..f9f65e4 --- /dev/null +++ b/TimberWinR/Filters/GrokFilter.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TimberWinR.Filters +{ + public class GrokFilter : FilterBase + { + public string Match { get; private set; } + public string Field { get; private set; } + public TimberWinR.Configuration.Pair AddField { get; private set; } + public bool DropIfMatch { get; private set; } + public string RemoveField { get; private set; } + + public GrokFilter(TimberWinR.Configuration.Params_Grok args) + { + Match = args.Match; + Field = args.Field; + AddField = args.AddField; + DropIfMatch = args.DropIfMatch; + RemoveField = args.RemoveField; + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("Grok\n"); + foreach (var prop in this.GetType().GetProperties()) + { + if (prop != null) + { + sb.Append(String.Format("\t{0}: {1}\n", prop.Name, prop.GetValue(this, null))); + } + + } + return sb.ToString(); + } + + public override void Apply(Newtonsoft.Json.Linq.JObject json) + { + throw new NotImplementedException(); + } + } + +} diff --git a/TimberWinR/TimberWinR.csproj b/TimberWinR/TimberWinR.csproj index 5a9d9c8..7b8679e 100644 --- a/TimberWinR/TimberWinR.csproj +++ b/TimberWinR/TimberWinR.csproj @@ -64,6 +64,9 @@ + + +