2
我配置prometheus.yml文件普罗米修斯不能拉配置指标
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds.
Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is
every 1 minute.
# scrape_timeout is set to the global default (10s).
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
- job_name: 'example-random'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['localhost:8090']
labels:
group: 'dummy'
和注册度量与普罗米修斯
public class PrometheusMetricsServlet extends MetricsServlet {
private static final Gauge emailCount = Gauge.build().name("email_count")
.help("Number of emails sent by the user")
.register();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setStatus(200);
emailCount.set(54);
}
}
则配置在web.xml一个servlet
<servlet>
<servlet-name>PrometheusServlet</servlet-name>
<servlet-class>prometheusSpike.PrometheusMetricsServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>PrometheusServlet</servlet-name>
<url-pattern>/metrics</url-pattern>
</servlet-mapping>
目标的状态显示为UP,最后一次刮擦发生在几秒之前,但该度量不是开始克反映在普罗米修斯。
该怎么做prometheus从目标中提取配置的指标?
谢谢,这解决了我的问题 – poojabh