{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/beats/pulls/comments/63683062","id":63683062,"diff_hunk":"@@ -11,247 +11,308 @@ import (\n \t\"github.com/elastic/beats/libbeat/logp\"\n )\n \n+type RangeValue struct {\n+\tgte *float64\n+\tgt  *float64\n+\tlte *float64\n+\tlt  *float64\n+}\n+\n+type EqualsValue struct {\n+\tInt uint64\n+\tStr string\n+}\n+\n type Condition struct {\n-\tEquals   map[string]EqualsValue\n-\tContains map[string]string\n-\tRegexp   map[string]*regexp.Regexp\n-\tRange    map[string]RangeValue\n+\tequals   map[string]EqualsValue\n+\tcontains map[string]string\n+\tregexp   map[string]*regexp.Regexp\n+\trangexp  map[string]RangeValue\n+}\n+\n+func AvailableCondition(name string) bool {\n+\n+\tswitch name {\n+\tcase \"equals\", \"contains\", \"range\", \"regexp\":\n+\t\treturn true\n+\tdefault:\n+\t\treturn false\n+\t}\n }\n \n func NewCondition(config ConditionConfig) (*Condition, error) {\n \n \tc := Condition{}\n-\tc.Equals = map[string]EqualsValue{}\n-\tc.Contains = map[string]string{}\n-\tc.Regexp = map[string]*regexp.Regexp{}\n-\tc.Range = map[string]RangeValue{}\n \n-\tif err := c.AddEquals(config.Equals); err != nil {\n-\t\treturn nil, err\n-\t}\n-\tif err := c.AddContains(config.Contains); err != nil {\n-\t\treturn nil, err\n-\t}\n-\tif err := c.AddRegexp(config.Regexp); err != nil {\n-\t\treturn nil, err\n-\t}\n-\tif err := c.AddRange(config.Range); err != nil {\n-\t\treturn nil, err\n+\tif config.Equals != nil {\n+\t\tif err := c.setEquals(config.Equals); err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\t} else if config.Contains != nil {\n+\t\tif err := c.setContains(config.Contains); err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\t} else if config.Regexp != nil {\n+\t\tif err := c.setRegexp(config.Regexp); err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\t} else if config.Range != nil {\n+\t\tif err := c.setRange(config.Range); err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\t} else {\n+\t\t// empty condition\n+\t\treturn nil, nil\n \t}\n \n \treturn &c, nil\n }\n \n-func (c *Condition) AddEquals(equals map[string]string) error {\n+func (c *Condition) setEquals(cfg *ConditionFilter) error {\n \n-\tfor field, value := range equals {\n+\tc.equals = map[string]EqualsValue{}\n \n-\t\ti, err := strconv.Atoi(value)\n+\tfor field, value := range cfg.fields {\n+\t\tuint_value, err := extractInt(value)\n \t\tif err == nil {\n-\t\t\tc.Equals[field] = EqualsValue{Int: i}\n+\t\t\tc.equals[field] = EqualsValue{Int: uint_value}\n \t\t} else {\n-\t\t\tc.Equals[field] = EqualsValue{Str: value}\n+\t\t\ts_value, err := extractString(value)\n+\t\t\tif err != nil {\n+\t\t\t\treturn err\n+\t\t\t}\n+\t\t\tc.equals[field] = EqualsValue{Str: s_value}\n \t\t}\n \t}\n+\n \treturn nil\n }\n \n-func (c *Condition) AddContains(contains map[string]string) error {\n+func (c *Condition) setContains(cfg *ConditionFilter) error {\n+\n+\tc.contains = map[string]string{}\n+\n+\tfor field, value := range cfg.fields {\n+\t\tswitch v := value.(type) {\n+\t\tcase string:\n+\t\t\tc.contains[field] = v\n+\t\tdefault:\n+\t\t\treturn fmt.Errorf(\"unexpected type %T of %v\", value, value)\n+\t\t}\n+\t}\n \n-\tc.Contains = contains\n \treturn nil\n }\n \n-func (c *Condition) AddRegexp(r map[string]*regexp.Regexp) error {\n-\tfor field, reg := range r {\n-\t\tc.Regexp[field] = reg\n+func (c *Condition) setRegexp(cfg *ConditionFilter) error {\n+\n+\tc.regexp = map[string]*regexp.Regexp{}\n+\tfor field, value := range cfg.fields {\n+\t\tswitch v := value.(type) {\n+\t\tcase string:\n+\t\t\tc.regexp[field] = regexp.MustCompile(v)","path":"libbeat/filter/condition.go","position":132,"original_position":132,"commit_id":"59b3c46e4f9fb23099c54bb4e1c9733ed360ac8b","original_commit_id":"779046eab9530aefb72d1c744d7e3c1b8a010c1a","user":{"login":"monicasarbu","id":11757159,"avatar_url":"https://avatars.githubusercontent.com/u/11757159?v=3","gravatar_id":"","url":"https://api.github.com/users/monicasarbu","html_url":"https://github.com/monicasarbu","followers_url":"https://api.github.com/users/monicasarbu/followers","following_url":"https://api.github.com/users/monicasarbu/following{/other_user}","gists_url":"https://api.github.com/users/monicasarbu/gists{/gist_id}","starred_url":"https://api.github.com/users/monicasarbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monicasarbu/subscriptions","organizations_url":"https://api.github.com/users/monicasarbu/orgs","repos_url":"https://api.github.com/users/monicasarbu/repos","events_url":"https://api.github.com/users/monicasarbu/events{/privacy}","received_events_url":"https://api.github.com/users/monicasarbu/received_events","type":"User","site_admin":false},"body":"Good spot, thanks!","created_at":"2016-05-18T10:58:27Z","updated_at":"2016-05-18T10:58:27Z","html_url":"https://github.com/elastic/beats/pull/1623#discussion_r63683062","pull_request_url":"https://api.github.com/repos/elastic/beats/pulls/1623","_links":{"self":{"href":"https://api.github.com/repos/elastic/beats/pulls/comments/63683062"},"html":{"href":"https://github.com/elastic/beats/pull/1623#discussion_r63683062"},"pull_request":{"href":"https://api.github.com/repos/elastic/beats/pulls/1623"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/beats/pulls/1623","id":69812931,"html_url":"https://github.com/elastic/beats/pull/1623","diff_url":"https://github.com/elastic/beats/pull/1623.diff","patch_url":"https://github.com/elastic/beats/pull/1623.patch","issue_url":"https://api.github.com/repos/elastic/beats/issues/1623","number":1623,"state":"open","locked":false,"title":"Use dots in field names and make filters pluggable","user":{"login":"monicasarbu","id":11757159,"avatar_url":"https://avatars.githubusercontent.com/u/11757159?v=3","gravatar_id":"","url":"https://api.github.com/users/monicasarbu","html_url":"https://github.com/monicasarbu","followers_url":"https://api.github.com/users/monicasarbu/followers","following_url":"https://api.github.com/users/monicasarbu/following{/other_user}","gists_url":"https://api.github.com/users/monicasarbu/gists{/gist_id}","starred_url":"https://api.github.com/users/monicasarbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monicasarbu/subscriptions","organizations_url":"https://api.github.com/users/monicasarbu/orgs","repos_url":"https://api.github.com/users/monicasarbu/repos","events_url":"https://api.github.com/users/monicasarbu/events{/privacy}","received_events_url":"https://api.github.com/users/monicasarbu/received_events","type":"User","site_admin":false},"body":"This PR includes the following changes:\r\n\r\n- [x] Each filtering action is a plugin, so you can easily add a new action to the filtering\r\n- [x] Add drop_event action \r\n- [x] Be able to pass fields that contain `.` in the condition:\r\n<code>\r\n  equals:\r\n    process.pid: 34443\r\n</code>\r\n- [x] Add a sample example in libbeat.yml\r\n- [x] Add system tests for Topbeat, Packetbeat, Filebeat \r\n\r\n\r\nI will update the documentation in a separate PR as well as system tests for Metricbeat.","created_at":"2016-05-12T10:26:30Z","updated_at":"2016-05-18T10:58:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"241a845854ce378edeeeb7acc75f04aae0cf0959","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/beats/pulls/1623/commits","review_comments_url":"https://api.github.com/repos/elastic/beats/pulls/1623/comments","review_comment_url":"https://api.github.com/repos/elastic/beats/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/beats/issues/1623/comments","statuses_url":"https://api.github.com/repos/elastic/beats/statuses/59b3c46e4f9fb23099c54bb4e1c9733ed360ac8b","head":{"label":"monicasarbu:use_dots_field_in_condition","ref":"use_dots_field_in_condition","sha":"59b3c46e4f9fb23099c54bb4e1c9733ed360ac8b","user":{"login":"monicasarbu","id":11757159,"avatar_url":"https://avatars.githubusercontent.com/u/11757159?v=3","gravatar_id":"","url":"https://api.github.com/users/monicasarbu","html_url":"https://github.com/monicasarbu","followers_url":"https://api.github.com/users/monicasarbu/followers","following_url":"https://api.github.com/users/monicasarbu/following{/other_user}","gists_url":"https://api.github.com/users/monicasarbu/gists{/gist_id}","starred_url":"https://api.github.com/users/monicasarbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monicasarbu/subscriptions","organizations_url":"https://api.github.com/users/monicasarbu/orgs","repos_url":"https://api.github.com/users/monicasarbu/repos","events_url":"https://api.github.com/users/monicasarbu/events{/privacy}","received_events_url":"https://api.github.com/users/monicasarbu/received_events","type":"User","site_admin":false},"repo":{"id":47255032,"name":"beats","full_name":"monicasarbu/beats","owner":{"login":"monicasarbu","id":11757159,"avatar_url":"https://avatars.githubusercontent.com/u/11757159?v=3","gravatar_id":"","url":"https://api.github.com/users/monicasarbu","html_url":"https://github.com/monicasarbu","followers_url":"https://api.github.com/users/monicasarbu/followers","following_url":"https://api.github.com/users/monicasarbu/following{/other_user}","gists_url":"https://api.github.com/users/monicasarbu/gists{/gist_id}","starred_url":"https://api.github.com/users/monicasarbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monicasarbu/subscriptions","organizations_url":"https://api.github.com/users/monicasarbu/orgs","repos_url":"https://api.github.com/users/monicasarbu/repos","events_url":"https://api.github.com/users/monicasarbu/events{/privacy}","received_events_url":"https://api.github.com/users/monicasarbu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/monicasarbu/beats","description":"Moved here: https://github.com/elastic/beats","fork":true,"url":"https://api.github.com/repos/monicasarbu/beats","forks_url":"https://api.github.com/repos/monicasarbu/beats/forks","keys_url":"https://api.github.com/repos/monicasarbu/beats/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monicasarbu/beats/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monicasarbu/beats/teams","hooks_url":"https://api.github.com/repos/monicasarbu/beats/hooks","issue_events_url":"https://api.github.com/repos/monicasarbu/beats/issues/events{/number}","events_url":"https://api.github.com/repos/monicasarbu/beats/events","assignees_url":"https://api.github.com/repos/monicasarbu/beats/assignees{/user}","branches_url":"https://api.github.com/repos/monicasarbu/beats/branches{/branch}","tags_url":"https://api.github.com/repos/monicasarbu/beats/tags","blobs_url":"https://api.github.com/repos/monicasarbu/beats/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monicasarbu/beats/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monicasarbu/beats/git/refs{/sha}","trees_url":"https://api.github.com/repos/monicasarbu/beats/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monicasarbu/beats/statuses/{sha}","languages_url":"https://api.github.com/repos/monicasarbu/beats/languages","stargazers_url":"https://api.github.com/repos/monicasarbu/beats/stargazers","contributors_url":"https://api.github.com/repos/monicasarbu/beats/contributors","subscribers_url":"https://api.github.com/repos/monicasarbu/beats/subscribers","subscription_url":"https://api.github.com/repos/monicasarbu/beats/subscription","commits_url":"https://api.github.com/repos/monicasarbu/beats/commits{/sha}","git_commits_url":"https://api.github.com/repos/monicasarbu/beats/git/commits{/sha}","comments_url":"https://api.github.com/repos/monicasarbu/beats/comments{/number}","issue_comment_url":"https://api.github.com/repos/monicasarbu/beats/issues/comments{/number}","contents_url":"https://api.github.com/repos/monicasarbu/beats/contents/{+path}","compare_url":"https://api.github.com/repos/monicasarbu/beats/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monicasarbu/beats/merges","archive_url":"https://api.github.com/repos/monicasarbu/beats/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monicasarbu/beats/downloads","issues_url":"https://api.github.com/repos/monicasarbu/beats/issues{/number}","pulls_url":"https://api.github.com/repos/monicasarbu/beats/pulls{/number}","milestones_url":"https://api.github.com/repos/monicasarbu/beats/milestones{/number}","notifications_url":"https://api.github.com/repos/monicasarbu/beats/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monicasarbu/beats/labels{/name}","releases_url":"https://api.github.com/repos/monicasarbu/beats/releases{/id}","deployments_url":"https://api.github.com/repos/monicasarbu/beats/deployments","created_at":"2015-12-02T10:50:02Z","updated_at":"2015-12-02T10:50:07Z","pushed_at":"2016-05-18T10:37:00Z","git_url":"git://github.com/monicasarbu/beats.git","ssh_url":"git@github.com:monicasarbu/beats.git","clone_url":"https://github.com/monicasarbu/beats.git","svn_url":"https://github.com/monicasarbu/beats","homepage":"","size":30120,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"4ffab18c27c26a338520acca443393dad6d2c44c","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":16554739,"name":"beats","full_name":"elastic/beats","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/beats","description":":tropical_fish: Beats - Lightweight shippers for Elasticsearch & Logstash ","fork":false,"url":"https://api.github.com/repos/elastic/beats","forks_url":"https://api.github.com/repos/elastic/beats/forks","keys_url":"https://api.github.com/repos/elastic/beats/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/beats/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/beats/teams","hooks_url":"https://api.github.com/repos/elastic/beats/hooks","issue_events_url":"https://api.github.com/repos/elastic/beats/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/beats/events","assignees_url":"https://api.github.com/repos/elastic/beats/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/beats/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/beats/tags","blobs_url":"https://api.github.com/repos/elastic/beats/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/beats/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/beats/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/beats/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/beats/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/beats/languages","stargazers_url":"https://api.github.com/repos/elastic/beats/stargazers","contributors_url":"https://api.github.com/repos/elastic/beats/contributors","subscribers_url":"https://api.github.com/repos/elastic/beats/subscribers","subscription_url":"https://api.github.com/repos/elastic/beats/subscription","commits_url":"https://api.github.com/repos/elastic/beats/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/beats/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/beats/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/beats/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/beats/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/beats/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/beats/merges","archive_url":"https://api.github.com/repos/elastic/beats/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/beats/downloads","issues_url":"https://api.github.com/repos/elastic/beats/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/beats/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/beats/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/beats/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/beats/labels{/name}","releases_url":"https://api.github.com/repos/elastic/beats/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/beats/deployments","created_at":"2014-02-05T19:01:02Z","updated_at":"2016-05-18T10:21:48Z","pushed_at":"2016-05-18T10:37:01Z","git_url":"git://github.com/elastic/beats.git","ssh_url":"git@github.com:elastic/beats.git","clone_url":"https://github.com/elastic/beats.git","svn_url":"https://github.com/elastic/beats","homepage":"https://www.elastic.co/products/beats","size":35775,"stargazers_count":2771,"watchers_count":2771,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":424,"mirror_url":null,"open_issues_count":233,"forks":424,"open_issues":233,"watchers":2771,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/beats/pulls/1623"},"html":{"href":"https://github.com/elastic/beats/pull/1623"},"issue":{"href":"https://api.github.com/repos/elastic/beats/issues/1623"},"comments":{"href":"https://api.github.com/repos/elastic/beats/issues/1623/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/beats/pulls/1623/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/beats/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/beats/pulls/1623/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/beats/statuses/59b3c46e4f9fb23099c54bb4e1c9733ed360ac8b"}}}}