# Can we modify .opendistro-alerting-alert index and add our own field?

**URL:** <https://forum.opensearch.org/t/can-we-modify-opendistro-alerting-alert-index-and-add-our-own-field/7764>\
**Category:** Alerting\
**Created:** [November 29, 2021, 5:52am UTC](https://forum.opensearch.org/t/can-we-modify-opendistro-alerting-alert-index-and-add-our-own-field/7764 "2021-11-29T05:52:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mann](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@mann](https://forum.opensearch.org/u/mann)\
**Post date:** [November 29, 2021, 5:52am UTC](https://forum.opensearch.org/t/can-we-modify-opendistro-alerting-alert-index-and-add-our-own-field/7764/1 "2021-11-29T05:52:42Z")

</div>

I am trying to modify .opendistro-alerting-alerts which store all the information related to monitors, triggers, and destination. I would like to add one more field inside trigger along with severity is risk\_score can I do that? If it is possible how to achieve that?

@pablo @searchymcsearchface

Basically, I have been able to update the mapping of .opendistro-alerting-alerts, but while using this API(POST - \_plugins/\_alerting/monitors) to create a new monitor doesn’t add risk\_score in it.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/f/fd64903b7dedef5d0036a59d28e9a6c6c2759732.png)

---

<div class="post-metadata">

**Author:** ![qreshi](https://avatars.discourse-cdn.com/v4/letter/q/aca169/32.png) [@qreshi](https://forum.opensearch.org/u/qreshi)\
**Post date:** [November 29, 2021, 5:36pm UTC](https://forum.opensearch.org/t/can-we-modify-opendistro-alerting-alert-index-and-add-our-own-field/7764/2 "2021-11-29T17:36:29Z")

</div>

Hi @mann,

If I’m understanding correctly and you’re looking to update the information present in the Alerts you can follow what was mentioned [here](https://forum.opensearch.org/t/modify-rest-api-for-get-alerts/7441/2).

However, if you’re trying to update the Monitor config itself, you’ll want to make changes to the [Monitor data model](https://github.com/opensearch-project/alerting/blob/main/alerting/src/main/kotlin/org/opensearch/alerting/model/Monitor.kt) class to add any fields, including updating [toXContent](https://github.com/opensearch-project/alerting/blob/main/alerting/src/main/kotlin/org/opensearch/alerting/model/Monitor.kt#L157) and [parsing](https://github.com/opensearch-project/alerting/blob/main/alerting/src/main/kotlin/org/opensearch/alerting/model/Monitor.kt#L239) logic. Then you can update the [Monitor mappings](https://github.com/opensearch-project/alerting/blob/main/core/src/main/resources/mappings/scheduled-jobs.json#L6-L252) to account for those new fields.

---

<div class="post-metadata">

**Author:** ![mann](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@mann](https://forum.opensearch.org/u/mann)\
**Post date:** [November 29, 2021, 6:28pm UTC](https://forum.opensearch.org/t/can-we-modify-opendistro-alerting-alert-index-and-add-our-own-field/7764/3 "2021-11-29T18:28:13Z")

</div>

Thanks @qreshi. That is helpful.

---

<div class="post-metadata">

**Author:** ![mann](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@mann](https://forum.opensearch.org/u/mann)\
**Post date:** [December 2, 2021, 8:54am UTC](https://forum.opensearch.org/t/can-we-modify-opendistro-alerting-alert-index-and-add-our-own-field/7764/4 "2021-12-02T08:54:02Z")

</div>

@qreshi @skkosuri-amzn @pablo I have started setting up the alerting plugin with [opensearch](https://github.com/opensearch-project/OpenSearch) as a developer mode, first I clone the OpenSearch and run the`./gradlew run` command on my Linux VM, as by default alerting is not integrated with OpenSearch so for that what steps do I need to follow to integrate [alerting](https://github.com/opensearch-project/alerting) plugin with my running OpenSearch and start editing the code to get my required outputs?

---

<div class="post-metadata">

**Author:** ![qreshi](https://avatars.discourse-cdn.com/v4/letter/q/aca169/32.png) [@qreshi](https://forum.opensearch.org/u/qreshi)\
**Post date:** [December 2, 2021, 7:04pm UTC](https://forum.opensearch.org/t/can-we-modify-opendistro-alerting-alert-index-and-add-our-own-field/7764/5 "2021-12-02T19:04:01Z")

</div>

@mann If you clone the Alerting repo and run `./gradlew run` there it will start up an OpenSearch cluster with Alerting on it so you can test any changes you’re making. You can refer to the [developer guide](https://github.com/opensearch-project/alerting/blob/main/DEVELOPER_GUIDE.md) for other useful commands as well.

---

<div class="post-metadata">

**Author:** ![mann](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@mann](https://forum.opensearch.org/u/mann)\
**Post date:** [December 3, 2021, 10:39am UTC](https://forum.opensearch.org/t/can-we-modify-opendistro-alerting-alert-index-and-add-our-own-field/7764/6 "2021-12-03T10:39:09Z")

</div>

I am facing the build failure, can you help me with that? Please find attached a screenshot for your reference.

OS - MAC OS Catalina V10.15.5  
JDK - 14.0.2  
Gradle - 5.5.1

 ![image (2)](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/1/1784ee584099a1fd13834265c7477e67a446bd2c.png)

---

<div class="post-metadata">

**Author:** ![mann](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@mann](https://forum.opensearch.org/u/mann)\
**Post date:** [December 7, 2021, 7:02am UTC](https://forum.opensearch.org/t/can-we-modify-opendistro-alerting-alert-index-and-add-our-own-field/7764/7 "2021-12-07T07:02:59Z")

</div>

@qreshi I am able to run on a Linux environment, and I was successfully able to integrate my own field under monitor config. Now as I am trying to understand the code workflow, can you let me know how to start or enable a debugger such that I can able to identify the files which are executed and their order.

For now, I manually added logger messages and tried to understand the workflow, once a Create Monitor API triggers.

1. RestIndexMonitorActions.kt - prepareRequest
2. Monitor.kt (Model) - Parse
3. Trigger.kt (Model) - Parse
4. QueryLevelTrigger (Model) - Parse
5. Monitor.kt - Init (2 Times)
6. RestIndexMonitorActions.kt - indexMonitorResponse
7. IndexMonitorRequest.kt - validate
8. TransportIndexMonitorAction.kt - doExecute method
9. TransportIndexMonitorAction.kt - checkIndicesAndExecute method
10. TransportIndexMonitorAction.kt - resolveUserAndStart
11. Monitor.kt - Init
12. TransportIndexMonitorAction.kt - Start (.opendistro-alerting-config) Index Created
13. TransportIndexMonitorAction.kt - onCreateMappingResponse (.opendistro-alerting-config) Set Mapping
14. TransportIndexMonitorAction.kt - prepareMonitorIndexing
15. TransportIndexMonitorAction.kt - validateActionThrottle
16. TransportIndexMonitorAction.kt - onSearchResponse
17. TransportIndexMonitorAction.kt - indexMonitor
18. Monitor.kt - Init
19. Monitor.kt - CreateXContentBuilder
20. Monitor.kt - Parse
21. Trigger.kt - Parse
22. QueryLevelTrigger.kt - Parse
23. Monitor.kt - Init (2 times) Scheduling Job Id - Monitor
24. TransportIndexMonitorAction.kt - checkShardFailures
25. IndexMonitorRequest.kt - toXContent
26. Monitor.kt - CreateXContentBuilder
