From ca617068fe7f12021ce5e0e2fd1dc1b6e22e9416 Mon Sep 17 00:00:00 2001 From: lhpqaq <657407891@qq.com> Date: Tue, 24 Dec 2024 17:19:08 +0800 Subject: [PATCH] fix --- .../{prometheus-conf.xml => prometheus.xml} | 0 .../infra/v1_0_0/prometheus/PrometheusParams.java | 13 +++---------- .../v1_0_0/prometheus/PrometheusServerScript.java | 4 ++-- .../infra/v1_0_0/prometheus/PrometheusSetup.java | 1 + 4 files changed, 6 insertions(+), 12 deletions(-) rename bigtop-manager-server/src/main/resources/stacks/infra/1.0.0/services/prometheus/configuration/{prometheus-conf.xml => prometheus.xml} (100%) diff --git a/bigtop-manager-server/src/main/resources/stacks/infra/1.0.0/services/prometheus/configuration/prometheus-conf.xml b/bigtop-manager-server/src/main/resources/stacks/infra/1.0.0/services/prometheus/configuration/prometheus.xml similarity index 100% rename from bigtop-manager-server/src/main/resources/stacks/infra/1.0.0/services/prometheus/configuration/prometheus-conf.xml rename to bigtop-manager-server/src/main/resources/stacks/infra/1.0.0/services/prometheus/configuration/prometheus.xml diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusParams.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusParams.java index 8a78c13d0..4f100b793 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusParams.java +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusParams.java @@ -50,7 +50,6 @@ public class PrometheusParams extends InfraParams { private List> scrapeJobs; private String prometheusPort; private String prometheusContent; - private String prometheusScrapeInterval; private String prometheusRulesFilename; private String prometheusRulesFileContent; @@ -60,7 +59,6 @@ public PrometheusParams(CommandPayload commandPayload) { scrapeJobs.add(prometheusScrapeJob); scrapeJobs.add(agentScrapeJob); globalParamsMap.put("scrape_jobs", scrapeJobs); - globalParamsMap.put("scrape_interval", prometheusScrapeInterval); globalParamsMap.put("rules_file_name", prometheusRulesFilename); } @@ -68,10 +66,6 @@ public String dataDir() { return MessageFormat.format("{0}/data", serviceHome()); } - public String confDir() { - return MessageFormat.format("{0}", serviceHome()); - } - public String targetsConfigFile(String jobName) { return MessageFormat.format("{0}/{1}_targets.json", confDir(), jobName); } @@ -92,7 +86,7 @@ protected List getAllHost() { @GlobalParams public Map prometheusJob() { - Map configuration = LocalSettings.configurations(getServiceName(), "prometheus-conf"); + Map configuration = LocalSettings.configurations(getServiceName(), "prometheus"); prometheusPort = (String) configuration.get("port"); Map job = new HashMap<>(); job.put("name", PROMETHEUS_SELF_JOB_NAME); @@ -109,15 +103,14 @@ public Map agentJob() { job.put("targets_file", targetsConfigFile(BM_AGENT_JOB_NAME)); job.put("targets_list", getAllHost()); agentScrapeJob = job; - return LocalSettings.configurations(getServiceName(), "prometheus-conf"); + return LocalSettings.configurations(getServiceName(), "prometheus"); } @GlobalParams public Map configs() { - Map configuration = LocalSettings.configurations(getServiceName(), "prometheus-conf"); + Map configuration = LocalSettings.configurations(getServiceName(), "prometheus"); prometheusContent = (String) configuration.get("content"); - prometheusScrapeInterval = (String) configuration.get("scrape_interval"); return configuration; } diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusServerScript.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusServerScript.java index 5f1acd005..d98c84be1 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusServerScript.java +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusServerScript.java @@ -51,8 +51,8 @@ public ShellResult start(Params params) { configure(params); PrometheusParams prometheusParams = (PrometheusParams) params; String cmd = MessageFormat.format( - "nohup {0}/prometheus --config.file={0}/prometheus.yml --web.listen-address={1} --storage.tsdb.path={0}/data > {0}/nohup.out 2>&1 &", - prometheusParams.serviceHome(), prometheusParams.listenAddress()); + "nohup {0}/prometheus --config.file={1}/prometheus.yml --web.listen-address={2} --storage.tsdb.path={0}/data > {0}/nohup.out 2>&1 &", + prometheusParams.serviceHome(), prometheusParams.confDir(), prometheusParams.listenAddress()); try { ShellResult shellResult = LinuxOSUtils.sudoExecCmd(cmd, prometheusParams.user()); if (shellResult.getExitCode() != 0) { diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java index c6ec3b2dc..89d015ded 100644 --- a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java @@ -44,6 +44,7 @@ public static ShellResult config(Params params) { String group = prometheusParams.group(); LinuxFileUtils.createDirectories(prometheusParams.dataDir(), user, group, Constants.PERMISSION_755, true); + LinuxFileUtils.createDirectories(prometheusParams.confDir(), user, group, Constants.PERMISSION_755, true); LinuxFileUtils.toFileByTemplate( prometheusParams.getPrometheusContent(),