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

Make priming of pop alerts configurable #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/main/java/net/opentsdb/horizon/alerts/EnvironmentConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ public class EnvironmentConfig {

public static final String DEFAULT_PULSAR_ATHENZ_KEY_ID = "0";

public static final String ENABLE_PRIMING = "enable_pop_priming";

public static final String DEFAULT_ENABLE_PRIMING = "true";

static {
String file = PROPERTIES_FILE;
if(IS_LOCAL) {
Expand Down Expand Up @@ -668,6 +672,15 @@ public boolean isSnoozeTagsEnabled() {
));
}

public boolean enablePOPPriming() {
return Boolean.parseBoolean(
propertiesFile.getProperty(
ENABLE_PRIMING,
DEFAULT_ENABLE_PRIMING
)
);
}

public Optional<List<String>> getList(final String property,
final String defaultValue,
final String delimiter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public final class PeriodOverPeriodProcessor
private final TSDBClient tsdbClient;
private final StatusWriter statusWriter;
private final CollectorWriter collectorWriter;
private final boolean enablePriming;

private String namespace;
private long alertId;
Expand Down Expand Up @@ -111,7 +112,23 @@ public PeriodOverPeriodProcessor(
final TSDBClient tsdbClient,
final StatusWriter statusWriter,
final CollectorWriter collectorWriter) {
this (
alertConfig,
tsdbClient,
statusWriter,
collectorWriter,
new EnvironmentConfig().enablePOPPriming()
);
}

public PeriodOverPeriodProcessor(
final PeriodOverPeriodAlertConfig alertConfig,
final TSDBClient tsdbClient,
final StatusWriter statusWriter,
final CollectorWriter collectorWriter,
final boolean enablePriming) {
super(alertConfig);
this.enablePriming = enablePriming;
Validate.paramNotNull(tsdbClient, "tsdbClient cannot be null");
Validate.paramNotNull(statusWriter, "statusWriter cannot be null");
Validate.paramNotNull(collectorWriter, "collectorWriter cannot be null");
Expand All @@ -122,6 +139,7 @@ public PeriodOverPeriodProcessor(
displayWindowSec = DISPLAY_WINDOW_SEC;
}


/* ------------ Methods ------------ */

@Override
Expand Down Expand Up @@ -180,8 +198,11 @@ public AlertEventBag execute(final long endTime,
final List<AlertEvent> alerts = processResponse(response, stateStore);
LOG.debug("processed response result: alert_id={}, end_time={}, alerts={}",
alertId, endTime, alerts);

tryPrimeNextModel(endTime, timeUnit);
if (enablePriming) {
tryPrimeNextModel(endTime, timeUnit);
} else {
LOG.debug("Priming is disabled for Period over period alerts. Skipping for alert_id={}", alertId);
}

return new AlertEventBag(alerts, getAlertConfig());
}
Expand Down