Skip to content

Commit

Permalink
Merge pull request #238 from childe/fix-http-pattern-paths
Browse files Browse the repository at this point in the history
return filepath of grok patterns if it's http(s)
  • Loading branch information
childe committed Dec 2, 2023
2 parents 5c04854 + 7cbad6d commit f62f5d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions filter/grok.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func (grok *Grok) loadPatterns() {
}

func getFiles(filepath string) ([]string, error) {
if strings.HasPrefix(filepath, "http://") || strings.HasPrefix(filepath, "https://") {
return []string{filepath}, nil
}

fi, err := os.Stat(filepath)
if err != nil {
return nil, err
Expand Down
9 changes: 9 additions & 0 deletions filter/grok_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ package filter

import "testing"

func TestGetPath(t *testing.T) {
filepath := "https://raw.githubusercontent.com/vjeantet/grok/master/patterns/grok-patterns"
_, err := getFiles(filepath)
if err != nil {
t.Errorf("getFiles error:%s", err)
}
}

func TestGrokFilter(t *testing.T) {
config := make(map[interface{}]interface{})
match := make([]interface{}, 2)
Expand Down Expand Up @@ -30,6 +38,7 @@ func TestGrokFilter(t *testing.T) {
}
}
}

func TestTarget(t *testing.T) {
config := make(map[interface{}]interface{})
match := make([]interface{}, 2)
Expand Down

0 comments on commit f62f5d4

Please sign in to comment.