Add additional configuration options for PromPush

This commit is contained in:
Dave Fisher
2023-08-29 15:22:18 -07:00
parent f15a410ea9
commit e69224afb6
3 changed files with 15 additions and 3 deletions

View File

@@ -218,6 +218,7 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
final String dockerMetricsAt = globalOptions.wantsDockerMetricsAt();
String reportGraphiteTo = globalOptions.wantsReportGraphiteTo();
String annotatorsConfig = globalOptions.getAnnotatorsConfig();
String promPushConfig = globalOptions.getPromPushConfig();
final String reportPromPushTo = globalOptions.wantsReportPromPushTo();
@@ -416,7 +417,7 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
final MetricReporters reporters = MetricReporters.getInstance();
reporters.addRegistry("workloads", ActivityMetrics.getMetricRegistry());
if (null != reportPromPushTo) reporters.addPromPush(reportPromPushTo, options.wantsMetricsPrefix());
if (null != reportPromPushTo) reporters.addPromPush(reportPromPushTo, options.wantsMetricsPrefix(), promPushConfig);
if (null != reportGraphiteTo) reporters.addGraphite(reportGraphiteTo, options.wantsMetricsPrefix());
if (null != options.wantsReportCsvTo())
reporters.addCSVReporter(options.wantsReportCsvTo(), options.wantsMetricsPrefix());

View File

@@ -53,6 +53,7 @@ public class NBCLIOptions {
private static final String METRICS_PREFIX = "--metrics-prefix";
private static final String ANNOTATE_EVENTS = "--annotate";
private static final String ANNOTATORS_CONFIG = "--annotators";
private static final String PROMPUSH_CONFIG = "--prompush";
// Enabled if the TERM env var is provided
private static final String ANSI = "--ansi";
@@ -184,6 +185,7 @@ public class NBCLIOptions {
private String[] annotateEvents = {"ALL"};
private String dockerMetricsHost;
private String annotatorsConfig = "";
private String promPushConfig = "";
private String statedirs = NBStatePath.NB_STATEDIR_PATHS;
private Path statepath;
private final String hdrForChartFileName = NBCLIOptions.DEFAULT_CHART_HDR_LOG_NAME;
@@ -208,6 +210,10 @@ public class NBCLIOptions {
return this.annotatorsConfig;
}
public String getPromPushConfig() {
return this.promPushConfig;
}
public NBLabels getLabelMap() {
return this.labels;
}
@@ -376,6 +382,10 @@ public class NBCLIOptions {
arglist.removeFirst();
this.reportPromPushTo = arglist.removeFirst();
break;
case NBCLIOptions.PROMPUSH_CONFIG:
arglist.removeFirst();
promPushConfig = this.readWordOrThrow(arglist, "prompush config");
break;
case NBCLIOptions.GRAPHITE_LOG_LEVEL:
arglist.removeFirst();
this.graphitelogLevel = arglist.removeFirst();

View File

@@ -115,7 +115,7 @@ public class MetricReporters implements Shutdownable {
return this;
}
public MetricReporters addPromPush(final String reportPromPushTo, final String prefix) {
public MetricReporters addPromPush(final String reportPromPushTo, final String prefix, final String config) {
logger.debug(() -> "Adding prompush reporter to " + reportPromPushTo + " with prefix label to " + prefix);
@@ -131,7 +131,8 @@ public class MetricReporters implements Shutdownable {
"prompush",
MetricFilter.ALL,
TimeUnit.SECONDS,
TimeUnit.NANOSECONDS
TimeUnit.NANOSECONDS,
config
);
scheduledReporters.add(promPushReporter);
}