in bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java [38:75]
public static ShellResult config(Params params) {
PrometheusParams prometheusParams = (PrometheusParams) params;
String user = prometheusParams.user();
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(),
MessageFormat.format("{0}/prometheus.yml", prometheusParams.confDir()),
user,
group,
Constants.PERMISSION_644,
prometheusParams.getGlobalParamsMap());
LinuxFileUtils.toFileByTemplate(
prometheusParams.getPrometheusRulesFileContent(),
MessageFormat.format(
"{0}/{1}", prometheusParams.confDir(), prometheusParams.getPrometheusRulesFilename()),
user,
group,
Constants.PERMISSION_644,
prometheusParams.getGlobalParamsMap());
for (int i = 0; i < prometheusParams.getScrapeJobs().size(); i++) {
Map<String, Object> job = prometheusParams.getScrapeJobs().get(i);
LinuxFileUtils.toFile(
ConfigType.JSON,
(String) job.get("targets_file"),
user,
group,
Constants.PERMISSION_644,
job.get("targets_list"));
}
return ShellResult.success("Prometheus Configure success!");
}