Fixed bug with multiple filters/inputs being dropped.

This commit is contained in:
Eric Fontana
2014-09-16 07:04:28 -04:00
parent e15ded5405
commit 2e82d8d7b5
7 changed files with 86 additions and 24 deletions

View File

@@ -127,29 +127,29 @@ namespace TimberWinR
if (x.TimberWinR.Inputs != null)
{
if (x.TimberWinR.Inputs.WindowsEvents != null)
c._events = x.TimberWinR.Inputs.WindowsEvents.ToList();
c._events.AddRange(x.TimberWinR.Inputs.WindowsEvents.ToList());
if (x.TimberWinR.Inputs.IISW3CLogs != null)
c._iisw3clogs = x.TimberWinR.Inputs.IISW3CLogs.ToList();
c._iisw3clogs.AddRange(x.TimberWinR.Inputs.IISW3CLogs.ToList());
if (x.TimberWinR.Inputs.Stdins != null)
c._stdins = x.TimberWinR.Inputs.Stdins.ToList();
c._stdins.AddRange(x.TimberWinR.Inputs.Stdins.ToList());
if (x.TimberWinR.Inputs.Logs != null)
c._logs = x.TimberWinR.Inputs.Logs.ToList();
c._logs.AddRange(x.TimberWinR.Inputs.Logs.ToList());
if (x.TimberWinR.Inputs.Tcps != null)
c._tcps = x.TimberWinR.Inputs.Tcps.ToList();
c._tcps.AddRange(x.TimberWinR.Inputs.Tcps.ToList());
}
if (x.TimberWinR.Outputs != null)
{
if (x.TimberWinR.Outputs.Redis != null)
c._redisOutputs = x.TimberWinR.Outputs.Redis.ToList();
c._redisOutputs.AddRange(x.TimberWinR.Outputs.Redis.ToList());
if (x.TimberWinR.Outputs.Elasticsearch != null)
c._elasticsearchOutputs = x.TimberWinR.Outputs.Elasticsearch.ToList();
c._elasticsearchOutputs.AddRange(x.TimberWinR.Outputs.Elasticsearch.ToList());
if (x.TimberWinR.Outputs.Stdout != null)
c._stdoutOutputs = x.TimberWinR.Outputs.Stdout.ToList();
c._stdoutOutputs.AddRange(x.TimberWinR.Outputs.Stdout.ToList());
}
if (x.TimberWinR.Filters != null)
c._filters = x.TimberWinR.AllFilters.ToList();
c._filters.AddRange(x.TimberWinR.AllFilters.ToList());
c.Validate(c);

View File

@@ -93,6 +93,10 @@ namespace TimberWinR.Diagnostics
new JArray(
from i in Manager.Listeners
select new JObject(i.ToJson()))),
new JProperty("filters",
new JArray(
from f in Manager.Config.Filters
select new JObject(f.ToJson()))),
new JProperty("outputs",
new JArray(
from o in Manager.Outputs

View File

@@ -34,6 +34,17 @@ namespace TimberWinR.Parser
return true;
}
public override JObject ToJson()
{
JObject json = new JObject(
new JProperty("date",
new JObject(
new JProperty("condition", Condition),
new JProperty("addfields", AddField)
)));
return json;
}
// copy_field "field1" -> "field2"
private void AddFields(Newtonsoft.Json.Linq.JObject json)
{

View File

@@ -30,8 +30,24 @@ namespace TimberWinR.Parser
}
}
public partial class Grok : LogstashFilter
{
public override JObject ToJson()
{
JObject json = new JObject(
new JProperty("grok",
new JObject(
new JProperty("condition", Condition),
new JProperty("addfields", AddField),
new JProperty("addtags", AddTag),
new JProperty("removefields", RemoveField),
new JProperty("removetag", RemoveTag)
)));
return json;
}
// Returns: true - Filter does not apply or has been applied successfully
// Returns: false - Drop this object
public override bool Apply(JObject json)
@@ -155,7 +171,7 @@ namespace TimberWinR.Parser
for (int i = 0; i < RemoveTag.Length; i++)
{
string tagName = ExpandField(RemoveTag[i], json);
foreach(JToken token in children)
foreach (JToken token in children)
{
if (token.ToString() == tagName)
token.Remove();

View File

@@ -12,6 +12,22 @@ namespace TimberWinR.Parser
{
public partial class Json : LogstashFilter
{
public override JObject ToJson()
{
JObject json = new JObject(
new JProperty("json",
new JObject(
new JProperty("condition", Condition),
new JProperty("source", Source),
new JProperty("target", Target),
new JProperty("addfields", AddField),
new JProperty("addtags", AddTag),
new JProperty("removefields", RemoveField),
new JProperty("removetag", RemoveTag)
)));
return json;
}
public override bool Apply(JObject json)
{
if (!string.IsNullOrEmpty(Type))

View File

@@ -11,6 +11,19 @@ namespace TimberWinR.Parser
{
public partial class Mutate : LogstashFilter
{
public override JObject ToJson()
{
JObject json = new JObject(
new JProperty("mutate",
new JObject(
new JProperty("condition", Condition),
new JProperty("splits", Split),
new JProperty("rename", Rename),
new JProperty("replace", Replace)
)));
return json;
}
public override bool Apply(JObject json)
{
if (!string.IsNullOrEmpty(Type))

View File

@@ -34,6 +34,8 @@ namespace TimberWinR.Parser
}
}
public abstract JObject ToJson();
protected bool EvaluateCondition(JObject json, string condition)
{
// Create a new instance of the C# compiler