-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Add action to decommission legacy monitoring cluster alerts #64373
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
Merged
jbaiera
merged 21 commits into
elastic:master
from
jbaiera:monitoring-decommission-watch-action
Dec 14, 2020
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
6d15cb2
Basic action definitions made
jbaiera fd7bc4a
Add ability to specify a consumer for when setup is completed by asyn…
jbaiera 76e4303
Refactor HttpResource to return more information on its success or fa…
jbaiera 9060cfb
Transport action to remove existing cluster alerts from configured ex…
jbaiera b0c5638
satisfy precommit
jbaiera 63704e5
Fix duplicate setting
jbaiera a9e7413
Add preliminary rest handler
jbaiera dfa0877
Some serious test cleanup, including a fix for a testing bug
jbaiera d9c6f00
The infinite struggle of forgetting to run precommit
jbaiera 6c3355b
The struggle continues
jbaiera 7881f15
Use a semaphore to lock the exporters out of running their setup unti…
jbaiera 25633f1
Merge branch 'master' into monitoring-decommission-watch-action
elasticmachine 0996f6e
PR feedback
jbaiera 8b52a5b
precommit
jbaiera 16065ed
Merge branch 'master' into monitoring-decommission-watch-action
elasticmachine 1642f52
Wrap mocked listeners to fix calls to ActionListener.map
jbaiera e911d7a
overzealous with one of my reverts
jbaiera 9942a25
Merge branch 'master' into monitoring-decommission-watch-action
elasticmachine 6a3e472
Add alert migration API to non operator actions
jbaiera 0622599
Merge branch 'master' into monitoring-decommission-watch-action
elasticmachine ae5be4c
PR comments
jbaiera 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
18 changes: 18 additions & 0 deletions
18
...in/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringMigrateAlertsAction.java
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,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.xpack.core.monitoring.action; | ||
|
||
import org.elasticsearch.action.ActionType; | ||
|
||
public class MonitoringMigrateAlertsAction extends ActionType<MonitoringMigrateAlertsResponse> { | ||
|
||
public static final MonitoringMigrateAlertsAction INSTANCE = new MonitoringMigrateAlertsAction(); | ||
public static final String NAME = "cluster:admin/xpack/monitoring/migrate/alerts"; | ||
|
||
public MonitoringMigrateAlertsAction() { | ||
super(NAME, MonitoringMigrateAlertsResponse::new); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...n/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringMigrateAlertsRequest.java
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,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.monitoring.action; | ||
|
||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.support.master.MasterNodeRequest; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
|
||
import java.io.IOException; | ||
|
||
public class MonitoringMigrateAlertsRequest extends MasterNodeRequest<MonitoringMigrateAlertsRequest> { | ||
|
||
public MonitoringMigrateAlertsRequest() {} | ||
|
||
public MonitoringMigrateAlertsRequest(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
} |
159 changes: 159 additions & 0 deletions
159
.../java/org/elasticsearch/xpack/core/monitoring/action/MonitoringMigrateAlertsResponse.java
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,159 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.monitoring.action; | ||
|
||
import org.elasticsearch.ElasticsearchException; | ||
import org.elasticsearch.action.ActionResponse; | ||
import org.elasticsearch.common.Nullable; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.io.stream.Writeable; | ||
import org.elasticsearch.common.xcontent.ToXContent; | ||
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class MonitoringMigrateAlertsResponse extends ActionResponse implements ToXContentObject { | ||
|
||
private final List<ExporterMigrationResult> exporters; | ||
|
||
public MonitoringMigrateAlertsResponse(List<ExporterMigrationResult> exporters) { | ||
this.exporters = exporters; | ||
} | ||
|
||
public MonitoringMigrateAlertsResponse(StreamInput in) throws IOException { | ||
super(in); | ||
this.exporters = in.readList(ExporterMigrationResult::new); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeList(exporters); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { | ||
return builder.startObject() | ||
.array("exporters", exporters) | ||
.endObject(); | ||
} | ||
|
||
public List<ExporterMigrationResult> getExporters() { | ||
return exporters; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
MonitoringMigrateAlertsResponse response = (MonitoringMigrateAlertsResponse) o; | ||
return Objects.equals(exporters, response.exporters); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(exporters); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MonitoringMigrateAlertsResponse{" + | ||
"exporters=" + exporters + | ||
'}'; | ||
} | ||
|
||
public static class ExporterMigrationResult implements Writeable, ToXContentObject { | ||
|
||
private final String name; | ||
private final String type; | ||
private final boolean migrationComplete; | ||
private final Exception reason; | ||
|
||
public ExporterMigrationResult(String name, String type, boolean migrationComplete, Exception reason) { | ||
this.name = name; | ||
this.type = type; | ||
this.migrationComplete = migrationComplete; | ||
this.reason = reason; | ||
} | ||
|
||
public ExporterMigrationResult(StreamInput in) throws IOException { | ||
this.name = in.readString(); | ||
this.type = in.readString(); | ||
this.migrationComplete = in.readBoolean(); | ||
this.reason = in.readException(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(name); | ||
out.writeString(type); | ||
out.writeBoolean(migrationComplete); | ||
out.writeException(reason); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
{ | ||
builder.field("name", name); | ||
builder.field("type", type); | ||
builder.field("migration_complete", migrationComplete); | ||
if (reason != null) { | ||
builder.startObject("reason"); | ||
ElasticsearchException.generateThrowableXContent(builder, params, reason); | ||
builder.endObject(); | ||
} | ||
} | ||
return builder.endObject(); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public boolean isMigrationComplete() { | ||
return migrationComplete; | ||
} | ||
|
||
@Nullable | ||
public Exception getReason() { | ||
return reason; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ExporterMigrationResult that = (ExporterMigrationResult) o; | ||
return migrationComplete == that.migrationComplete && | ||
Objects.equals(name, that.name) && | ||
Objects.equals(type, that.type); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name, type, migrationComplete); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ExporterMigrationResult{" + | ||
"name='" + name + '\'' + | ||
", type='" + type + '\'' + | ||
", migrationComplete=" + migrationComplete + | ||
", reason=" + reason + | ||
'}'; | ||
} | ||
} | ||
} |
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
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.