/* Ċ Ġ* ĠĠ ĠCopyright Ġ 2 0 1 9 ĠAmazon . com , ĠInc . Ġor Ġits Ġaffiliates . ĠAll ĠRights ĠReserved . Ċ Ġ* Ċ Ġ* ĠĠ ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "). Ċ Ġ* ĠĠ ĠYou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠĠ ĠA Ġcopy Ġof Ġthe ĠLicense Ġis Ġlocated Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠĠ Ġor Ġin Ġthe Ġ" license " Ġfile Ġaccompanying Ġthis Ġfile . ĠThis Ġfile Ġis Ġdistributed Ċ Ġ* ĠĠ Ġon Ġan Ġ" AS ĠIS " ĠBASIS , ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ċ Ġ* ĠĠ Ġexpress Ġor Ġimplied . ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ċ Ġ* ĠĠ Ġpermissions Ġand Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ package Ġcom . amazon . opend ist ro fore lastic search . alert ing Ċ Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . alerts . Alert Indices Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . core . Job Sw eeper Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . core . Scheduled Job Indices Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . core . action . node . Scheduled Jobs Stats Action Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . core . action . node . Scheduled Jobs Stats Transport Action Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . core . model . Http Input Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . core . model . Scheduled Job Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . core . model . Search Input Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . core . rest handler . Rest Scheduled Job Stats Handler Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . core . schedule . Job Scheduler Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . core . settings . Scheduled Job Settings Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . model . Monitor Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . rest handler . Rest Ack nowledge Alert Action Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . rest handler . Rest Delete Destination Action Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . rest handler . Rest Delete Monitor Action Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . rest handler . Rest Execute Monitor Action Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . rest handler . Rest Get Monitor Action Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . rest handler . Rest Index Destination Action Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . rest handler . Rest Index Monitor Action Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . rest handler . Rest Search Monitor Action Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . script . Trigger Script Ċ import Ġcom . amazon . opend ist ro fore lastic search . alert ing . settings . Alert ing Settings Ċ import Ġorg . elasticsearch . action . Action Request Ċ import Ġorg . elasticsearch . action . Action Response Ċ import Ġorg . elasticsearch . client . Client Ċ import Ġorg . elasticsearch . cluster . metadata . Index Name Expression Resolver Ċ import Ġorg . elasticsearch . cluster . node . Discovery Nodes Ċ import Ġorg . elasticsearch . cluster . service . Cluster Service Ċ import Ġorg . elasticsearch . common . io . stream . Named Write able Registry Ċ import Ġorg . elasticsearch . common . settings . Cluster Settings Ċ import Ġorg . elasticsearch . common . settings . Index Scoped Settings Ċ import Ġorg . elasticsearch . common . settings . Setting Ċ import Ġorg . elasticsearch . common . settings . Settings Ċ import Ġorg . elasticsearch . common . settings . Settings Filter Ċ import Ġorg . elasticsearch . common . x content . Named X Content Registry Ċ import Ġorg . elasticsearch . env . Environment Ċ import Ġorg . elasticsearch . env . Node Environment Ċ import Ġorg . elasticsearch . index . Index Module Ċ import Ġorg . elasticsearch . pain less . spi . P ain less Extension Ċ import Ġorg . elasticsearch . pain less . spi . Whitelist Ċ import Ġorg . elasticsearch . pain less . spi . Whitelist Loader Ċ import Ġorg . elasticsearch . plugins . Action Plugin Ċ import Ġorg . elasticsearch . plugins . Plugin Ċ import Ġorg . elasticsearch . plugins . Script Plugin Ċ import Ġorg . elasticsearch . rest . RestController Ċ import Ġorg . elasticsearch . rest . Rest Handler Ċ import Ġorg . elasticsearch . script . Script Context Ċ import Ġorg . elasticsearch . script . Script Service Ċ import Ġorg . elasticsearch . thread pool . ThreadPool Ċ import Ġorg . elasticsearch . watcher . Resource Watcher Service Ċ import Ġjava . util . function . Supplier Ċ Ċ /** Ċ Ġ* ĠEntry Ġpoint Ġof Ġthe ĠOpen Dist ro Ġfor ĠElasticsearch Ġalert ing Ġplugin Ċ Ġ* ĠThis Ġclass Ġinitializes Ġthe Ġ[ Rest Get Monitor Action ], Ġ[ Rest Delete Monitor Action ], Ġ[ Rest Index Monitor Action ] Ġrest Ġhandlers . Ċ Ġ* ĠIt Ġalso Ġadds Ġ[ Monitor . X CONTENT _ REGISTRY ], Ġ[ Search Input . X CONTENT _ REGISTRY ] Ġto Ġthe Ċ Ġ* Ġ[ Named X Content Registry ] Ġso Ġthat Ġwe Ġare Ġable Ġto Ġdeserialize Ġthe Ġcustom Ġnamed Ġobjects . Ċ Ġ*/ Ċ internal Ġclass ĠAlert ing Plugin Ġ: ĠP ain less Extension , ĠAction Plugin , ĠScript Plugin , ĠPlugin () Ġ{ ĊĠĠĠ Ġoverride Ġfun ĠgetContext Wh itel ists (): ĠMap < Script Context <* >, ĠList < Whitelist >> Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġwhitelist Ġ= ĠWh itelist Loader . load From Resource Files ( java Class , Ġ" com . amazon . opend ist ro fore lastic search . alert ing . txt ") ĊĠĠĠĠĠĠĠ Ġreturn Ġmap Of ( Trigger Script . CONTEXT Ġto ĠlistOf ( whitelist )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġ@ Jvm Field Ġval ĠK IB ANA _ USER _ AGENT Ġ= Ġ" K ibana " ĊĠĠĠĠĠĠĠ Ġ@ Jvm Field Ġval ĠUI _ METADATA _ EXCL UDE Ġ= ĠarrayOf (" monitor .${ Monitor . UI _ METADATA _ FIELD }") ĊĠĠĠĠĠĠĠ Ġ@ Jvm Field Ġval ĠMON ITOR _ BASE _ URI Ġ= Ġ"/ _ opend ist ro /_ alert ing / monitor s " ĊĠĠĠĠĠĠĠ Ġ@ Jvm Field Ġval ĠDEST INATION _ BASE _ URI Ġ= Ġ"/ _ opend ist ro /_ alert ing / dest inations " ĊĠĠĠĠĠĠĠ Ġ@ Jvm Field Ġval ĠAL ERT ING _ JOB _ TYPES Ġ= ĠlistOf (" monitor ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġlateinit Ġvar Ġrunner : ĠMonitor Runner ĊĠĠĠ Ġlateinit Ġvar Ġscheduler : ĠJob Scheduler ĊĠĠĠ Ġlateinit Ġvar Ġsw eeper : ĠJob Sw eeper ĊĠĠĠ Ġlateinit Ġvar Ġscheduled Job Indices : ĠScheduled Job Indices ĊĠĠĠ Ġlateinit Ġvar Ġthread Pool : ĠThreadPool ĊĠĠĠ Ġlateinit Ġvar Ġalert Indices : ĠAlert Indices ĊĠĠĠ Ġlateinit Ġvar Ġcluster Service : ĠCluster Service ĊĊĠĠĠ Ġoverride Ġfun Ġget Rest Handlers ( ĊĠĠĠĠĠĠĠ Ġsettings : ĠSettings , ĊĠĠĠĠĠĠĠ Ġrest Controller : ĠRest Controller , ĊĠĠĠĠĠĠĠ Ġcluster Settings : ĠCluster Settings , ĊĠĠĠĠĠĠĠ Ġindex Scoped Settings : ĠIndex Scoped Settings , ĊĠĠĠĠĠĠĠ Ġsettings Filter : ĠSettings Filter , ĊĠĠĠĠĠĠĠ Ġindex Name Expression Resolver : ĠIndex Name Expression Resolver ?, ĊĠĠĠĠĠĠĠ Ġnodes In Cluster : ĠSupplier < Discovery Nodes > ĊĠĠĠ Ġ): ĠList < Rest Handler > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠlistOf ( Rest Get Monitor Action ( rest Controller ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRest Delete Monitor Action ( rest Controller ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRest Index Monitor Action ( settings , Ġrest Controller , Ġscheduled Job Indices , Ġcluster Service ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRest Search Monitor Action ( rest Controller ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRest Execute Monitor Action ( settings , Ġrest Controller , Ġrunner ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRest Ack nowledge Alert Action ( rest Controller ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRest Scheduled Job Stats Handler ( rest Controller , Ġ"_ alert ing "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRest Index Destination Action ( settings , Ġrest Controller , Ġscheduled Job Indices , Ġcluster Service ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRest Delete Destination Action ( rest Controller )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Actions (): ĠList < Action Plugin . Action Handler < out ĠAction Request , Ġout ĠAction Response >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠlistOf ( Action Plugin . Action Handler ( Scheduled Jobs Stats Action . INSTANCE , ĠScheduled Jobs Stats Transport Action :: class . java )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Named X Content (): ĠList < Named X Content Registry . Entry > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠlistOf ( Monitor . X CONTENT _ REGISTRY , ĠSearch Input . X CONTENT _ REGISTRY , ĠHttp Input . X CONTENT _ REGISTRY ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġcreate Components ( ĊĠĠĠĠĠĠĠ Ġclient : ĠClient , ĊĠĠĠĠĠĠĠ Ġcluster Service : ĠCluster Service , ĊĠĠĠĠĠĠĠ Ġthread Pool : ĠThreadPool , ĊĠĠĠĠĠĠĠ Ġresource Watcher Service : ĠResource Watcher Service , ĊĠĠĠĠĠĠĠ Ġscript Service : ĠScript Service , ĊĠĠĠĠĠĠĠ Ġx Content Registry : ĠNamed X Content Registry , ĊĠĠĠĠĠĠĠ Ġenvironment : ĠEnvironment , ĊĠĠĠĠĠĠĠ Ġnode Environment : ĠNode Environment , ĊĠĠĠĠĠĠĠ Ġnamed Write able Registry : ĠNamed Write able Registry ĊĠĠĠ Ġ): ĠCollection < Any > Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠNeed Ġto Ġfigure Ġout Ġhow Ġto Ġuse Ġthe ĠElasticsearch ĠDI Ġclasses Ġrather Ġthan Ġhand w iring Ġthings Ġhere . ĊĠĠĠĠĠĠĠ Ġval Ġsettings Ġ= Ġenvironment . settings () ĊĠĠĠĠĠĠĠ Ġalert Indices Ġ= ĠAlert Indices ( settings , Ġclient , Ġthread Pool , Ġcluster Service ) ĊĠĠĠĠĠĠĠ Ġrunner Ġ= ĠMonitor Runner ( settings , Ġclient , Ġthread Pool , Ġscript Service , Ġx Content Registry , Ġalert Indices , Ġcluster Service ) ĊĠĠĠĠĠĠĠ Ġscheduled Job Indices Ġ= ĠScheduled Job Indices ( client . admin (), Ġcluster Service ) ĊĠĠĠĠĠĠĠ Ġscheduler Ġ= ĠJob Scheduler ( thread Pool , Ġrunner ) ĊĠĠĠĠĠĠĠ Ġsw eeper Ġ= ĠJob Sw eeper ( environment . settings (), Ġclient , Ġcluster Service , Ġthread Pool , Ġx Content Registry , Ġscheduler , ĠAL ERT ING _ JOB _ TYPES ) ĊĠĠĠĠĠĠĠ Ġthis . thread Pool Ġ= Ġthread Pool ĊĠĠĠĠĠĠĠ Ġthis . cluster Service Ġ= Ġcluster Service ĊĠĠĠĠĠĠĠ Ġreturn ĠlistOf ( sw eeper , Ġscheduler , Ġrunner , Ġscheduled Job Indices ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Settings (): ĠList < Setting <* >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠScheduled Job Settings . REQUEST _ TIMEOUT , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠScheduled Job Settings . SW EE P _ BACK OFF _ M ILL IS , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠScheduled Job Settings . SW EE P _ BACK OFF _ RETRY _ COUNT , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠScheduled Job Settings . SW EE P _ PERIOD , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠScheduled Job Settings . SW EE P _ PAGE _ SIZE , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠScheduled Job Settings . SW EE PER _ ENABLED , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . INPUT _ TIMEOUT , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . INDEX _ TIMEOUT , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . B UL K _ TIMEOUT , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . ALERT _ BACK OFF _ M ILL IS , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . ALERT _ BACK OFF _ COUNT , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . MOVE _ AL ER TS _ BACK OFF _ M ILL IS , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . MOVE _ AL ER TS _ BACK OFF _ COUNT , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . ALERT _ HISTORY _ ENABLED , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . ALERT _ HISTORY _ ROL LO VER _ PERIOD , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . ALERT _ HISTORY _ INDEX _ MAX _ AGE , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . ALERT _ HISTORY _ MAX _ DOCS , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . ALERT _ HISTORY _ RET ENT ION _ PERIOD , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . ALERT ING _ MAX _ MON IT ORS , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . REQUEST _ TIMEOUT , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠAlert ing Settings . MAX _ ACTION _ TH RO TT LE _ VALUE ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Index Module ( index Module : ĠIndex Module ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( index Module . index . name Ġ== ĠScheduled Job . SCHEDUL ED _ JOB S _ INDEX ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġindex Module . addIndex Operation Listener ( sw eeper ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Contexts (): ĠList < Script Context <* >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠlistOf ( Trigger Script . CONTEXT ) ĊĠĠĠ Ġ} Ċ } Ċ