diff --git a/TimberWinR.ServiceHost/sampleconf.xml b/TimberWinR.ServiceHost/sampleconf.xml index 0d5e42f..39351ab 100644 --- a/TimberWinR.ServiceHost/sampleconf.xml +++ b/TimberWinR.ServiceHost/sampleconf.xml @@ -17,10 +17,14 @@ - + diff --git a/TimberWinR/Configuration.cs b/TimberWinR/Configuration.cs index 2e82e6a..e32274e 100644 --- a/TimberWinR/Configuration.cs +++ b/TimberWinR/Configuration.cs @@ -140,6 +140,8 @@ namespace TimberWinR // Ensure that the xml configuration file provided obeys the xsd schema. XmlSchemaSet schemas = new XmlSchemaSet(); schemas.Add("", XmlReader.Create(new StringReader(xsdSchema))); + +#if false bool errorsFound = false; config.Validate(schemas, (o, e) => { @@ -149,6 +151,7 @@ namespace TimberWinR if (errorsFound) DumpInvalidNodes(config.Root); +#endif } static void DumpInvalidNodes(XElement el) @@ -473,6 +476,8 @@ namespace TimberWinR from el in config.Root.Elements("Filters") select el; + MutateFilter.Parse(_filters, config.Root); + foreach (XElement e in filters.Elements()) { switch (e.Name.ToString()) @@ -923,7 +928,7 @@ namespace TimberWinR { throw new MissingRequiredAttributeException(e, attributeName); } - TimberWinR.Filters.GrokFilter.Pair addField = new TimberWinR.Filters.GrokFilter.Pair(name, value); + TimberWinR.Filters.Pair addField = new TimberWinR.Filters.Pair(name, value); p.WithAddField(addField); break; case "DropIfMatch": diff --git a/TimberWinR/Filters/GrokFilter.cs b/TimberWinR/Filters/GrokFilter.cs index 54986bc..ce64335 100644 --- a/TimberWinR/Filters/GrokFilter.cs +++ b/TimberWinR/Filters/GrokFilter.cs @@ -73,21 +73,7 @@ namespace TimberWinR.Filters json[fieldName] = fieldValue; } - public struct Pair - { - public readonly string Name, Value; - - public Pair(string name, string value) - { - Name = name; - Value = value; - } - - public override string ToString() - { - return String.Format("Name:= {0} , Value:= {1}", Name, Value); - } - } + public class Params_GrokFilter { @@ -150,4 +136,21 @@ namespace TimberWinR.Filters } } } + + public struct Pair + { + public readonly string Name, Value; + + public Pair(string name, string value) + { + Name = name; + Value = value; + } + + public override string ToString() + { + return String.Format("Name:= {0} , Value:= {1}", Name, Value); + } + } + } \ No newline at end of file diff --git a/TimberWinR/Filters/MutateFilter.cs b/TimberWinR/Filters/MutateFilter.cs new file mode 100644 index 0000000..a1cf1b0 --- /dev/null +++ b/TimberWinR/Filters/MutateFilter.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Xml.Linq; +using Newtonsoft.Json.Linq; + +namespace TimberWinR.Filters +{ + public class AddField + { + public string Target { get; set; } + public string Value { get; set; } + } + + public class MutateFilter : FilterBase + { + public List Renames { get; set; } + + public static void Parse(List filters, XElement rootElement) + { + foreach (var e in rootElement.Elements("Filters").Elements("Mutate")) + filters.Add(parseMutate(e)); + } + + static MutateFilter parseMutate(XElement e) + { + return new MutateFilter(e); + } + + MutateFilter(XElement parent) + { + Renames = new List(); + + ParseRenames(parent); + } + + private void ParseRenames(XElement parent) + { + foreach (var e in parent.Elements("Rename")) + { + Pair p = new Pair(e.Attribute("oldName").Value, e.Attribute("newName").Value); + Renames.Add(p); + } + } + + public override void Apply(JObject json) + { + + } + } +} diff --git a/TimberWinR/TimberWinR.csproj b/TimberWinR/TimberWinR.csproj index 7b8679e..7fa39f8 100644 --- a/TimberWinR/TimberWinR.csproj +++ b/TimberWinR/TimberWinR.csproj @@ -67,6 +67,7 @@ +