Thanks for clarifying those details. There currently isn’t an Atlas alert that can be created for when an index creation is submitted. If you would like this feature to be added, I would suggest you to file a feature request via feedback.mongodb.com being sure to include all your use case details. From that platform, you will be able to interact with our Product Management team, keep track of the progress of your request, and make this visible to other users.
Is there a way for me to insert this output into a collection?
One idea based off what you have provided from the output screenshot is to log the namespace details & index details (from the output) on the application side and insert them to a collection so that you can use to monitor indexes. This could then be made to be a CRON / scheduled job so that you can check every now and then to verify the appropriate indexes are in place. Additionally, you can consider limiting access to this collection to only certain database users. Please see Configure Custom Database Roles for more information on this.
However, this leads to another problem - How or when to know when an index is removed?
- To have information about indexes created in Development and Production environments. By following the indexes, to check if there is an index that is really suitable for the wishes of the person who created it.
I believe it may be better to solve this from a workflow perspective. One suggestion could be:
Allowing your developers to create indexes in the dev environment and have some auditing to pick up when a new index is created. Since you’re on MongoDB Atlas, you could Set up Database Auditing to audit createIndex and dropIndex actions although this feature is only available on M10+ tier clusters. You can then retrieve the mongodb-audit-log’s and filter for if these actions have occurred periodically.
Disallow creating indexes in the production environment outside of an approved deployment process. I.e. Only indexes that you’ve approved (through an internal process) from Dev can be created on Production.
Of course, all the above would depend on your use case and requirements. Would you be able to advise if the indexes are being created manually or via code?