Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alerting Enhancements: Alerting Comments (Experimental) #663

Merged
merged 11 commits into from
Jun 7, 2024

Conversation

toepkerd
Copy link
Contributor

@toepkerd toepkerd commented May 29, 2024

Description

Common utils additions for the Alerting Comments experimental feature

Issues Resolved

opensearch-project/alerting#1500: direct request for adding Alert notes when acknowledging an Alert and showing who acknowledged an Alert.

This feature intends to be a superset of this ask, though adding comments or notes specifically when acknowledging an Alert will be a later extension.

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
@toepkerd toepkerd changed the title Alerting enhancements Alerting enhancements: Alerting Notes May 30, 2024
@toepkerd toepkerd marked this pull request as ready for review May 30, 2024 21:17
@toepkerd toepkerd changed the title Alerting enhancements: Alerting Notes Alerting enhancements: Alerting Notes (Experimental) May 30, 2024
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
@toepkerd toepkerd changed the title Alerting enhancements: Alerting Notes (Experimental) Alerting enhancements: Alerting Comments (Experimental) Jun 5, 2024
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
@@ -21,6 +21,9 @@ object AlertingActions {
const val SUBSCRIBE_FINDINGS_ACTION_NAME = "cluster:admin/opensearch/alerting/findings/subscribe"
const val GET_MONITOR_ACTION_NAME = "cluster:admin/opendistro/alerting/monitor/get"
const val SEARCH_MONITORS_ACTION_NAME = "cluster:admin/opendistro/alerting/monitor/search"
const val INDEX_COMMENT_ACTION_NAME = "cluster:admin/opendistro/alerting/alerts/comments/write"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for opendistro

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check latest actions for naming convention

content = sin.readString(),
createdTime = sin.readInstant(),
lastUpdatedTime = sin.readOptionalInstant(),
user = if (sin.readBoolean()) {
Copy link
Collaborator

@riysaxen-amzn riysaxen-amzn Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ternary op for better readability

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kotlin does not seem to have a ternary operator (https://discuss.kotlinlang.org/t/ternary-operator/2116), and favors directly using if else as it is more idiomatic. I can make it one line to resemble a ternary operator structure more.

val content: String,
val createdTime: Instant,
val lastUpdatedTime: Instant?,
val user: User?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this be optional field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastUpdatedTime will be an optional field because upon a Comment's creation, it will not have a last updated time, only a created time. lastUpdatedTime is only assigned when a User makes a subsequent call to the same Comment to edit/update it. user will also be an optional field because there's no guarantee that the Security Plugin will be installed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullable because of security and without security

@riysaxen-amzn
Copy link
Collaborator

if you've have a github issue for this feature, add it in PR description for ref

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
@AWSHurneyt
Copy link
Collaborator

Looks good to me as long as other folks' comments are addressed. I've resolved the comments I left.

Copy link
Collaborator

@AWSHurneyt AWSHurneyt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@toepkerd Oh actually, could you confirm whether this should be merged to main or a feature branch?

AWSHurneyt
AWSHurneyt previously approved these changes Jun 6, 2024
riysaxen-amzn
riysaxen-amzn previously approved these changes Jun 6, 2024
val content: String,
val createdTime: Instant,
val lastUpdatedTime: Instant?,
val user: User?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullable because of security and without security

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
@toepkerd toepkerd dismissed stale reviews from riysaxen-amzn and AWSHurneyt via a5d8a47 June 7, 2024 18:39
@toepkerd toepkerd changed the title Alerting enhancements: Alerting Comments (Experimental) Alerting Enhancements: Alerting Comments (Experimental) Jun 7, 2024
@AWSHurneyt AWSHurneyt merged commit acaa844 into opensearch-project:main Jun 7, 2024
9 checks passed
@toepkerd toepkerd mentioned this pull request Jun 10, 2024
5 tasks
@@ -31,6 +31,12 @@ data class DataSources(
/** Configures a custom index pattern for alertHistoryIndex alias.*/
val alertsHistoryIndexPattern: String? = "<.opendistro-alerting-alert-history-{now/d}-1>", // AlertIndices.ALERT_HISTORY_INDEX_PATTERN

/** Configures a custom index alias to store comments associated with alerts.*/
val commentsIndex: String = ".opensearch-alerting-comments-history-write", // AlertIndices.COMMENTS_HISTORY_WRITE_INDEX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be optional??
existing usage of dataSources like SEcurity analytics will not be setting this field.

opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 10, 2024
* initial commit, functional but needs refactoring

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>

* added lastUpdatedTime to Note object

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>

* changed name from alert id to entity id

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>

* import cleanup

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>

* changing name from Alerting Notes to Alerting Comments

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>

* misc fixes and cleanup

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>

* adding unit test coverage

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>

* misc cleanup

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>

* misc review-based cleanup

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>

* added validation exception messages

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>

---------

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Co-authored-by: Dennis Toepker <toepkerd@amazon.com>
(cherry picked from commit acaa844)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
eirsep pushed a commit that referenced this pull request Jun 10, 2024
* initial commit, functional but needs refactoring



* added lastUpdatedTime to Note object



* changed name from alert id to entity id



* import cleanup



* changing name from Alerting Notes to Alerting Comments



* misc fixes and cleanup



* adding unit test coverage



* misc cleanup



* misc review-based cleanup



* added validation exception messages



---------



(cherry picked from commit acaa844)

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dennis Toepker <toepkerd@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants