Open Distro for Elasticsearch JobScheduler plugin provides a framework for Elasticsearch plugin developers to schedule periodical jobs running within Elasticsearch nodes. You can schedule jobs by specify an interval, or using Unix Cron expression to define more flexible schedule to execute your job.
Elasticsearch plugin developers can easily extend JobScheduler plugin to schedule jobs like running aggregation query against raw data and save the aggregated data into a new index every hour, or keep monitoring the shard allocation by calling Elasticsearch API and post the output to a Webhook.
The JobScheduler plugin uses the Gradle build system.
- Checkout this package from version control.
- To build from command line set
JAVA_HOME
to point to a JDK >=13 - Run
./gradlew build
Then you will find the built artifact located at build/distributions
directory
Once you have built the plugin from source code, run
elasticsearch-plugin install file://${PLUGIN_ZIP_FILE_PATH}
to install the JobScheduler plugin to your Elasticsearch.
JobScheduler plugin provides a SPI for other plugins to implement. Essentially, you need to
- Define your JobParameter type by implementing
ScheduledJobParameter
interface - Implement your JobParameter parser function that can deserialize your JobParameter from XContent
- Create your JobRunner implementation by implementing
ScheduledJobRunner
interface - Create your own plugin which implements
JobSchedulerExtension
interface- don't forget to create the service provider configuration file in your resources folder and bundle it into your plugin artifact
Please refer to the sample-extension-plugin
subproject in this project, which provides a complete
example of using JobScheduler to run periodical jobs.
The sample extension plugin takes an index name as input and logs the index shards to elasticsearch logs according to the specified Schedule. And it also exposes a REST endpoint for end users to create/delete jobs.
This project has adopted an Open Source Code of Conduct.
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our vulnerability reporting page. Please do not create a public GitHub issue.
See the LICENSE file for our project's licensing. We will ask you to confirm the licensing of your contribution.