generated from amazon-archives/__template_Custom
    
        
        - 
                Notifications
    
You must be signed in to change notification settings  - Fork 119
 
PPL Alerting: Get Alerts and Alert Lifecycle #1972
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
          
     Open
      
      
            toepkerd
  wants to merge
  7
  commits into
  opensearch-project:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
toepkerd:ppl-review
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            7 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      b2f7cb8
              
                PPL Alerting: Get Alerts and Alert Lifecycle
              
              
                toepkerd-zz f4bffa1
              
                updating scheduled jobs schema version in alert indices IT
              
              
                toepkerd-zz acc68f7
              
                enabling alerting v2 by default
              
              
                toepkerd-zz d12bf64
              
                making get alerts response fields snake cased
              
              
                toepkerd-zz 42dcb2e
              
                removing unused get alerts params and adding serde tests for alertsv2…
              
              
                toepkerd-zz cbf4f12
              
                removing misleading comments
              
              
                toepkerd-zz f67ebdb
              
                minor changes
              
              
                toepkerd-zz File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
  
    
      
          
            15 changes: 15 additions & 0 deletions
          
          15 
        
  alerting/src/main/kotlin/org/opensearch/alerting/actionv2/GetAlertsV2Action.kt
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| 
     | 
||
| package org.opensearch.alerting.actionv2 | ||
| 
     | 
||
| import org.opensearch.action.ActionType | ||
| 
     | 
||
| class GetAlertsV2Action private constructor() : ActionType<GetAlertsV2Response>(NAME, ::GetAlertsV2Response) { | ||
| companion object { | ||
| val INSTANCE = GetAlertsV2Action() | ||
| const val NAME = "cluster:admin/opensearch/alerting/v2/alerts/get" | ||
| } | ||
| } | 
        
          
  
    
      
          
            47 changes: 47 additions & 0 deletions
          
          47 
        
  alerting/src/main/kotlin/org/opensearch/alerting/actionv2/GetAlertsV2Request.kt
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| 
     | 
||
| package org.opensearch.alerting.actionv2 | ||
| 
     | 
||
| import org.opensearch.action.ActionRequest | ||
| import org.opensearch.action.ActionRequestValidationException | ||
| import org.opensearch.commons.alerting.model.Table | ||
| import org.opensearch.core.common.io.stream.StreamInput | ||
| import org.opensearch.core.common.io.stream.StreamOutput | ||
| import java.io.IOException | ||
| 
     | 
||
| class GetAlertsV2Request : ActionRequest { | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. serde unit tests There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adding  | 
||
| val table: Table | ||
| val severityLevel: String | ||
| val monitorV2Ids: List<String>? | ||
| 
     | 
||
| constructor( | ||
| table: Table, | ||
| severityLevel: String, | ||
| monitorV2Ids: List<String>? = null, | ||
| ) : super() { | ||
| this.table = table | ||
| this.severityLevel = severityLevel | ||
| this.monitorV2Ids = monitorV2Ids | ||
| } | ||
| 
     | 
||
| @Throws(IOException::class) | ||
| constructor(sin: StreamInput) : this( | ||
| table = Table.readFrom(sin), | ||
| severityLevel = sin.readString(), | ||
| monitorV2Ids = sin.readOptionalStringList(), | ||
| ) | ||
| 
     | 
||
| override fun validate(): ActionRequestValidationException? { | ||
| return null | ||
| } | ||
| 
     | 
||
| @Throws(IOException::class) | ||
| override fun writeTo(out: StreamOutput) { | ||
| table.writeTo(out) | ||
| out.writeString(severityLevel) | ||
| out.writeOptionalStringCollection(monitorV2Ids) | ||
| } | ||
| } | ||
        
          
  
    
      
          
            52 changes: 52 additions & 0 deletions
          
          52 
        
  alerting/src/main/kotlin/org/opensearch/alerting/actionv2/GetAlertsV2Response.kt
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| 
     | 
||
| package org.opensearch.alerting.actionv2 | ||
| 
     | 
||
| import org.opensearch.alerting.modelv2.AlertV2 | ||
| import org.opensearch.commons.notifications.action.BaseResponse | ||
| import org.opensearch.core.common.io.stream.StreamInput | ||
| import org.opensearch.core.common.io.stream.StreamOutput | ||
| import org.opensearch.core.xcontent.ToXContent | ||
| import org.opensearch.core.xcontent.XContentBuilder | ||
| import java.io.IOException | ||
| import java.util.Collections | ||
| 
     | 
||
| class GetAlertsV2Response : BaseResponse { | ||
| val alertV2s: List<AlertV2> | ||
| 
     | 
||
| // totalAlertV2s is not the same as the size of alertV2s because there can be 30 alerts from the request, but | ||
| // the request only asked for 5 alerts, so totalAlertV2s will be 30, but alertV2s will only contain 5 alerts | ||
| val totalAlertV2s: Int? | ||
| 
     | 
||
| constructor( | ||
| alertV2s: List<AlertV2>, | ||
| totalAlertV2s: Int? | ||
| ) : super() { | ||
| this.alertV2s = alertV2s | ||
| this.totalAlertV2s = totalAlertV2s | ||
| } | ||
| 
     | 
||
| @Throws(IOException::class) | ||
| constructor(sin: StreamInput) : this( | ||
| alertV2s = Collections.unmodifiableList(sin.readList(::AlertV2)), | ||
| totalAlertV2s = sin.readOptionalInt() | ||
| ) | ||
| 
     | 
||
| @Throws(IOException::class) | ||
| override fun writeTo(out: StreamOutput) { | ||
| out.writeCollection(alertV2s) | ||
| out.writeOptionalInt(totalAlertV2s) | ||
| } | ||
| 
     | 
||
| @Throws(IOException::class) | ||
| override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { | ||
| builder.startObject() | ||
| .field("alerts_v2", alertV2s) | ||
| .field("total_alerts_v2", totalAlertV2s) | ||
| 
     | 
||
| return builder.endObject() | ||
| } | ||
| } | 
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.