-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load Filebeat modules pipelines on -setup (#3394)
* Load Filebeat modules pipelines on -setup This adds the `-setup` CLI flag, which, for now, makes Filebeat load the pipelines at startup. In case Elasticsearch is not available when Filebeat is started with `-setup`, Filebeat will exit with an error. This also exposes an Elasticsearch client from the output. * Use an interface instead of the ES client
- Loading branch information
1 parent
77cec5a
commit c6c5e5c
Showing
15 changed files
with
344 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// +build integration | ||
|
||
package fileset | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/elastic/beats/libbeat/outputs/elasticsearch" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestLoadPipeline(t *testing.T) { | ||
client := elasticsearch.GetTestingElasticsearch() | ||
client.Request("DELETE", "/_ingest/pipeline/my-pipeline-id", "", nil, nil) | ||
|
||
content := map[string]interface{}{ | ||
"description": "describe pipeline", | ||
"processors": []map[string]interface{}{ | ||
{ | ||
"set": map[string]interface{}{ | ||
"field": "foo", | ||
"value": "bar", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
err := loadPipeline(client, "my-pipeline-id", content) | ||
assert.NoError(t, err) | ||
|
||
status, _, _ := client.Request("GET", "/_ingest/pipeline/my-pipeline-id", "", nil, nil) | ||
assert.Equal(t, 200, status) | ||
} | ||
|
||
func TestSetupNginx(t *testing.T) { | ||
client := elasticsearch.GetTestingElasticsearch() | ||
client.Request("DELETE", "/_ingest/pipeline/nginx-access-with_plugins", "", nil, nil) | ||
client.Request("DELETE", "/_ingest/pipeline/nginx-error-pipeline", "", nil, nil) | ||
|
||
modulesPath, err := filepath.Abs("../module") | ||
assert.NoError(t, err) | ||
|
||
configs := []ModuleConfig{ | ||
ModuleConfig{Module: "nginx"}, | ||
} | ||
|
||
reg, err := newModuleRegistry(modulesPath, configs, nil) | ||
assert.NoError(t, err) | ||
|
||
err = reg.Setup(client) | ||
assert.NoError(t, err) | ||
|
||
status, _, _ := client.Request("GET", "/_ingest/pipeline/nginx-access-with_plugins", "", nil, nil) | ||
assert.Equal(t, 200, status) | ||
status, _, _ = client.Request("GET", "/_ingest/pipeline/nginx-error-pipeline", "", nil, nil) | ||
assert.Equal(t, 200, status) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// +build !integration | ||
|
||
package fileset | ||
|
||
import ( | ||
|
Oops, something went wrong.