Skip to content

Commit

Permalink
tmp commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lhpqaq committed Dec 16, 2024
1 parent 4be4db8 commit ca05ce0
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,63 @@
~ specific language governing permissions and limitations
~ under the License.
-->

<!--<property>-->
<!-- <name>name</name>-->
<!-- <values>prometheus</values>-->
<!-- <property>-->
<!-- <property>-->
<!-- <name>job_name</name>-->
<!-- <value>job</value>-->
<!-- <description>Job name</description>-->
<!-- </property>-->
<!-- <name>job_targets</name>-->
<!-- <values>-->
<!-- <property>-->
<!-- <name>target1</name>-->
<!-- <value>localhost:9090</value>-->
<!-- </property>-->
<!-- </values>-->
<!-- <description>Job targets</description>-->
<!-- </property>-->
<!-- <property>-->
<!-- <name>job_scrape_interval</name>-->
<!-- <value>5s</value>-->
<!-- <description>scrape targets from this job every scrape_interval.</description>-->
<!-- </property>-->
<configuration>
<property>
<name>scrape_jobs</name>
<values>
<property>
<name>scrape_config1</name>
<values>
<property>
<name>job_name</name>
<value>job</value>
<description>Job name</description>
</property>
<property>
<name>job_targets</name>
<value>['localhost:9090']</value>
<description>Job targets</description>
</property>
<property>
<name>job_scrape_interval</name>
<value>5s</value>
<description>scrape targets from this job every scrape_interval.</description>
</property>
</values>
<description>A scrape configuration containing exactly one endpoint to scrape.</description>
</property>
</values>
<description>A scrape configuration containing exactly one endpoint to scrape.</description>
</property>
<property>
<name>content</name>
<description>This is the freemarker template for prometheus.yml file</description>
<value><![CDATA[
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
scrape_interval: ${scrape_interval} # By default, scrape targets every 15 seconds.
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
Expand All @@ -43,10 +92,10 @@ scrape_configs:
static_configs:
- targets: ['localhost:9090']
<#list scrapeJobs as job>
- job_name: "${job.name}"
<#list scrape_jobs as job>
- job_name: '${job.name}'
scrape_interval: ${job.scrapeInterval}
scrape_interval: ${job.scrape_interval}
static_configs:
- targets: ${job.targets}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
package org.apache.bigtop.manager.stack.infra.v1_0_0.prometheus;

import org.apache.bigtop.manager.common.message.entity.payload.CommandPayload;
import org.apache.bigtop.manager.stack.core.annotations.GlobalParams;
import org.apache.bigtop.manager.stack.core.spi.param.Params;
import org.apache.bigtop.manager.stack.core.utils.LocalSettings;
import org.apache.bigtop.manager.stack.infra.param.InfraParams;

import com.google.auto.service.AutoService;
Expand All @@ -28,6 +30,7 @@
import lombok.extern.slf4j.Slf4j;

import java.text.MessageFormat;
import java.util.Map;

@Getter
@Slf4j
Expand All @@ -47,4 +50,17 @@ public String dataDir() {
public String getServiceName() {
return "prometheus";
}

@GlobalParams
public Map<String, Object> scapeJobs() {
Map<String, Object> configuration = LocalSettings.configurations(getServiceName(), "prometheus");
log.info(configuration.toString());
Map<String, Object> scapeJobs = (Map<String, Object>) configuration.get("scape_jobs");
log.info(scapeJobs.toString());
for (Map.Entry<String, Object> entry : scapeJobs.entrySet()) {
Map<String, Object> scapeJob = (Map<String, Object>) entry.getValue();
log.info(scapeJob.toString());
}
return configuration;
}
}

0 comments on commit ca05ce0

Please sign in to comment.