allow --docker-prom-retention-days with default of 183d

This commit is contained in:
Jonathan Shook 2020-12-15 12:37:43 -06:00
parent 4a06f226c9
commit 0a6bb1fa5f
3 changed files with 16 additions and 4 deletions

View File

@ -135,7 +135,8 @@ public class NBCLI {
DockerMetricsManager dmh = new DockerMetricsManager();
Map<String, String> dashboardOptions = Map.of(
DockerMetricsManager.GRAFANA_TAG, globalOptions.getDockerGrafanaTag(),
DockerMetricsManager.PROM_TAG, globalOptions.getDockerPromTag()
DockerMetricsManager.PROM_TAG, globalOptions.getDockerPromTag(),
DockerMetricsManager.TSDB_RETENTION, String.valueOf(globalOptions.getDockerPromRetentionDays())
);
dmh.startMetrics(dashboardOptions);
String warn = "Docker Containers are started, for grafana and prometheus, hit" +

View File

@ -87,6 +87,7 @@ public class NBCLIOptions {
private final static String DOCKER_METRICS_AT = "--docker-metrics-at";
private static final String DOCKER_GRAFANA_TAG = "--docker-grafana-tag";
private static final String DOCKER_PROM_TAG = "--docker-prom-tag";
private static final String DOCKER_PROM_RETENTION_DAYS = "--docker-prom-retention-days";
private static final String GRAALJS_ENGINE = "--graaljs";
private static final String NASHORN_ENGINE = "--nashorn";
@ -147,6 +148,7 @@ public class NBCLIOptions {
private Path statepath;
private final List<String> statePathAccesses = new ArrayList<>();
private final String hdrForChartFileName = DEFAULT_CHART_HDR_LOG_NAME;
private String dockerPromRetentionDays = "183d";
public String getAnnotatorsConfig() {
return annotatorsConfig;
@ -157,6 +159,10 @@ public class NBCLIOptions {
return hdrForChartFileName;
}
public String getDockerPromRetentionDays() {
return this.dockerPromRetentionDays;
}
public enum Mode {
ParseGlobalsOnly,
ParseAllOptions
@ -288,6 +294,10 @@ public class NBCLIOptions {
arglist.removeFirst();
docker_prom_tag = readWordOrThrow(arglist, "prometheus docker tag");
break;
case DOCKER_PROM_RETENTION_DAYS:
arglist.removeFirst();
dockerPromRetentionDays = Integer.parseInt(readWordOrThrow(arglist, "prometheus retention days"));
break;
case DOCKER_GRAFANA_TAG:
arglist.removeFirst();
docker_grafana_tag = readWordOrThrow(arglist, "grafana docker tag");

View File

@ -30,6 +30,7 @@ public class DockerMetricsManager {
public static final String GRAFANA_TAG = "grafana_tag";
public static final String PROM_TAG = "prom_tag";
public static final String TSDB_RETENTION = "tsdb_days";
private final DockerHelper dh;
@ -45,7 +46,7 @@ public class DockerMetricsManager {
String ip = startGraphite();
startPrometheus(ip, options.get(PROM_TAG));
startPrometheus(ip, options.get(PROM_TAG), options.get(TSDB_RETENTION));
startGrafana(ip, options.get(GRAFANA_TAG));
@ -94,7 +95,7 @@ public class DockerMetricsManager {
}
}
private void startPrometheus(String ip, String tag) {
private void startPrometheus(String ip, String tag, String retention) {
logger.info("preparing to start docker metrics");
String PROMETHEUS_IMG = "prom/prometheus";
@ -117,7 +118,7 @@ public class DockerMetricsManager {
List<String> cmdList = Arrays.asList(
"--config.file=/etc/prometheus/prometheus.yml",
"--storage.tsdb.path=/prometheus",
"--storage.tsdb.retention=183d",
"--storage.tsdb.retention=" + retention,
"--web.enable-lifecycle"
);