Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
lhpqaq committed Dec 15, 2024
1 parent c2ca814 commit 4670517
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,21 @@ public class PrometheusParams extends InfraParams {

private final String PROMETHEUS_SELF_JOB_NAME = "prometheus";
private final String BM_AGENT_JOB_NAME = "bm-agent";
private final Integer BM_AGENT_PORT = 8081;
private final String BM_AGENT_PORT = "8081";

private final List<Map<String, Object>> prometheusScrapeJobs = new ArrayList<>();
private Integer prometheusPort;
private Map<String, Object> prometheusScrapeJob;
private Map<String, Object> agentScrapeJob;
private List<Map<String, Object>> scrapeJobs;
private String prometheusPort;
private String prometheusContent;
private String prometheusScrapeInterval;

public PrometheusParams(CommandPayload commandPayload) {
super(commandPayload);
globalParamsMap.put("scrape_jobs", prometheusScrapeJobs);
scrapeJobs = new ArrayList<>();
scrapeJobs.add(prometheusScrapeJob);
scrapeJobs.add(agentScrapeJob);
globalParamsMap.put("scrape_jobs", scrapeJobs);
globalParamsMap.put("scrape_interval", prometheusScrapeInterval);
}

Expand Down Expand Up @@ -85,12 +90,12 @@ private List<String> getAllHost() {
@GlobalParams
public Map<String, Object> prometheusJob() {
Map<String, Object> configuration = LocalSettings.configurations(getServiceName(), "prometheus");
prometheusPort = (Integer) configuration.get("port");
prometheusPort = (String) configuration.get("port");
Map<String, Object> job = new HashMap<>();
job.put("name", PROMETHEUS_SELF_JOB_NAME);
job.put("targets_file", targetsConfigFile(PROMETHEUS_SELF_JOB_NAME));
job.put("targets_list", List.of(MessageFormat.format("localhost:{0}", prometheusPort)));
prometheusScrapeJobs.add(job);
prometheusScrapeJob = job;
return configuration;
}

Expand All @@ -100,7 +105,7 @@ public Map<String, Object> agentJob() {
job.put("name", BM_AGENT_JOB_NAME);
job.put("targets_file", targetsConfigFile(BM_AGENT_JOB_NAME));
job.put("targets_list", getAllHost());
prometheusScrapeJobs.add(job);
agentScrapeJob = job;
return LocalSettings.configurations(getServiceName(), "prometheus");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public static ShellResult config(Params params) {
Constants.PERMISSION_644,
prometheusParams.getGlobalParamsMap());

for (int i = 0; i < prometheusParams.getPrometheusScrapeJobs().size(); i++) {
Map<String, Object> job = prometheusParams.getPrometheusScrapeJobs().get(i);
for (int i = 0; i < prometheusParams.getScrapeJobs().size(); i++) {
Map<String, Object> job = prometheusParams.getScrapeJobs().get(i);
Map<String, List<String>> targets = new HashMap<>();
targets.put("targets", (List<String>) job.get("targets_list"));
LinuxFileUtils.toFile(
Expand Down

0 comments on commit 4670517

Please sign in to comment.