Skip to content

Commit 456525c

Browse files
Add plugin development notes in a readme. (#209) (#213)
* Add plugin development notes in a readme. * Update README.md Co-authored-by: Cas Donoghue <[email protected]> * Update README.md Co-authored-by: Cas Donoghue <[email protected]> --------- Co-authored-by: Cas Donoghue <[email protected]> (cherry picked from commit f48b08b) Co-authored-by: Mashhur <[email protected]>
1 parent 8e4c02a commit 456525c

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

README.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,73 @@ It can be used in a Logstash pipeline to perform the transformations that are ap
77
## Documentation
88

99
Logstash provides infrastructure to automatically generate documentation for this plugin from its [asciidoc source](docs/index.asciidoc).
10-
All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
10+
All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
11+
12+
## Development
13+
### Prerequisites
14+
- Clone the [plugin repo](https://github.com/elastic/logstash-filter-elastic_integration)
15+
- Check out the branch you would like to build, such as `8.x` or `9.x/main`, etc...
16+
- Note that, `8.series` branches require JDK17 and `9.series`/`main` requires JDK21.
17+
- Set the Logstash source path in the `gradle.properties` file. Open the file and update the `LOGSTASH_PATH`.
18+
- Make sure Logstash is compiled.
19+
- Point to the Elasticsearch branch/version to build the plugin with. Open the `gradle.properties` file and update `ELASTICSEARCH_TREEISH`.
20+
21+
### Build
22+
We use Gradle tool to build this plugin. Gradle is configured to load the Logstash core jars from the `LOGSTASH_PATH` path, download the Elasticsearch version defined with `ELASTICSEARCH_TREEISH` and build the plugin.
23+
The build process may fail if the Elasticsearch interfaces the plugin is using have changed.
24+
25+
The following command builds plugin and generates the jar file, can be locally installed in Logstash core and verified:
26+
```shell
27+
./gradlew clean vendor localGem
28+
```
29+
30+
### Plugin test
31+
The recommendation to run tests to align on our common [`plugins/.ci`](https://github.com/logstash-plugins/.ci) tool.
32+
Run the following command under the plugin source dir to download the CI tool:
33+
```shell
34+
mkdir -p .ci-test && curl -sL --retry 5 --retry-delay 5 https://github.com/logstash-plugins/.ci/archive/1.x.tar.gz | tar zxvf - --keep-old-files --strip-components=1 -C .ci-test
35+
```
36+
37+
Export environment variables:
38+
```shell
39+
SNAPSHOT=false # set to true if targeting the SNAPSHOT
40+
ELASTIC_STACK_VERSION=8.17.0 # stack version to run the plugin on
41+
INTEGRATION=false # set to true if you want integration tests to run, it also requires SECURE_INTEGRATION=true
42+
```
43+
44+
Run tests on the local docker environment, make sure your docker-engine is running.
45+
```shell
46+
./.ci/docker-setup.sh && ./.ci/docker-run.sh
47+
```
48+
49+
### Running your unpublished plugin in Logstash
50+
51+
#### Run in a local Logstash clone
52+
- Edit Logstash `Gemfile` and add the local plugin path, for example:
53+
```ruby
54+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
55+
```
56+
- Install plugin
57+
```sh
58+
bin/logstash-plugin install --no-verify
59+
```
60+
- Run Logstash with your plugin
61+
```sh
62+
bin/logstash -e 'filter {awesome {}}'
63+
```
64+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
65+
66+
#### Run in an installed Logstash
67+
- Edit Logstash `Gemfile` and add the local plugin path, for example:
68+
```ruby
69+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
70+
```
71+
- Build your plugin gem
72+
```sh
73+
./gradlew clean vendor localGem
74+
```
75+
- Install the plugin from the Logstash home
76+
```sh
77+
bin/logstash-plugin install --no-verify
78+
```
79+
- Start Logstash and proceed to test the plugin

0 commit comments

Comments
 (0)