- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我不确定这是一个错误,但我试图在过去的一天中实现这个库,但没有任何结果。我认为这可能与依赖项版本冲突,但我尝试了一切。
所以我有一个非常简单的 spring boot 项目,它服务于 /test
端点和我配置
/actuator/prometheus
下有普罗米修斯指标.
requests_test_total
requests_latency_seconds
/test
端点,但这些指标未显示在 prometheus 指标中。
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('io.micrometer:micrometer-registry-prometheus')
compile "io.prometheus:simpleclient:0.8.1"
compile "io.prometheus:simpleclient_hotspot:0.8.1"
compile "io.prometheus:simpleclient_httpserver:0.8.1"
compile "io.prometheus:simpleclient_pushgateway:0.8.1"
compile group: 'io.prometheus', name: 'simpleclient_spring_boot', version: '0.8.1'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compile group: 'ch.qos.logback.contrib', name: 'logback-json-classic', version: '0.1.5'
compile group: 'ch.qos.logback.contrib', name: 'logback-jackson', version: '0.1.5'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.3'
compile group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '6.3'
}
package prometheus.prometheusclientexample;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.prometheus.client.Counter;
import io.prometheus.client.Histogram;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SimpleEndpoint {
private static final Logger logger = LoggerFactory.getLogger("MainLogger");
static final Counter test_requests = Counter.build().name("requests_test_total").help("Total /test requests.").register();
static final Histogram requestLatency = Histogram.build()
.name("requests_latency_seconds").help("Request latency in seconds.").register();
@RequestMapping("/test")
public String test2() throws InterruptedException {
Histogram.Timer requestTimer = requestLatency.startTimer();
try {
logger.info("Before");
test_requests.inc();
logger.info("This is a simple endpint");
}
finally {
requestTimer.observeDuration();
}
return "OK NEW";
}
}
/actuator/prometheus
回复 :
# HELP jvm_gc_memory_allocated_bytes_total Incremented for an increase in the size of the young generation memory pool after one GC to before the next
# TYPE jvm_gc_memory_allocated_bytes_total counter
jvm_gc_memory_allocated_bytes_total 0.0
# HELP jvm_gc_max_data_size_bytes Max size of old generation memory pool
# TYPE jvm_gc_max_data_size_bytes gauge
jvm_gc_max_data_size_bytes 4.294967296E9
# HELP logback_events_total Number of error level events that made it to the logs
# TYPE logback_events_total counter
logback_events_total{level="warn",} 0.0
logback_events_total{level="debug",} 368.0
logback_events_total{level="error",} 0.0
logback_events_total{level="trace",} 0.0
logback_events_total{level="info",} 12.0
# HELP jvm_memory_max_bytes The maximum amount of memory in bytes that can be used for memory management
# TYPE jvm_memory_max_bytes gauge
jvm_memory_max_bytes{area="heap",id="G1 Survivor Space",} -1.0
jvm_memory_max_bytes{area="heap",id="G1 Old Gen",} 4.294967296E9
jvm_memory_max_bytes{area="nonheap",id="Metaspace",} -1.0
jvm_memory_max_bytes{area="nonheap",id="CodeHeap 'non-nmethods'",} 6975488.0
jvm_memory_max_bytes{area="heap",id="G1 Eden Space",} -1.0
jvm_memory_max_bytes{area="nonheap",id="Compressed Class Space",} 1.073741824E9
jvm_memory_max_bytes{area="nonheap",id="CodeHeap 'non-profiled nmethods'",} 2.44682752E8
# HELP tomcat_sessions_alive_max_seconds
# TYPE tomcat_sessions_alive_max_seconds gauge
tomcat_sessions_alive_max_seconds 0.0
# HELP jvm_gc_live_data_size_bytes Size of old generation memory pool after a full GC
# TYPE jvm_gc_live_data_size_bytes gauge
jvm_gc_live_data_size_bytes 0.0
# HELP process_start_time_seconds Start time of the process since unix epoch.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.588860975956E9
# HELP tomcat_sessions_active_max_sessions
# TYPE tomcat_sessions_active_max_sessions gauge
tomcat_sessions_active_max_sessions 0.0
# HELP tomcat_sessions_created_sessions_total
# TYPE tomcat_sessions_created_sessions_total counter
tomcat_sessions_created_sessions_total 0.0
# HELP jvm_classes_unloaded_classes_total The total number of classes unloaded since the Java virtual machine has started execution
# TYPE jvm_classes_unloaded_classes_total counter
jvm_classes_unloaded_classes_total 0.0
# HELP jvm_threads_live_threads The current number of live threads including both daemon and non-daemon threads
# TYPE jvm_threads_live_threads gauge
jvm_threads_live_threads 24.0
# HELP process_files_max_files The maximum file descriptor count
# TYPE process_files_max_files gauge
process_files_max_files 10240.0
# HELP http_server_requests_seconds
# TYPE http_server_requests_seconds summary
http_server_requests_seconds_count{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/actuator/prometheus",} 1.0
http_server_requests_seconds_sum{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/actuator/prometheus",} 0.144024648
http_server_requests_seconds_count{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/test",} 2.0
http_server_requests_seconds_sum{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/test",} 0.029707973
# HELP http_server_requests_seconds_max
# TYPE http_server_requests_seconds_max gauge
http_server_requests_seconds_max{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/actuator/prometheus",} 0.144024648
http_server_requests_seconds_max{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/test",} 0.022717086
# HELP jvm_memory_used_bytes The amount of used memory
# TYPE jvm_memory_used_bytes gauge
jvm_memory_used_bytes{area="heap",id="G1 Survivor Space",} 7340032.0
jvm_memory_used_bytes{area="heap",id="G1 Old Gen",} 4369520.0
jvm_memory_used_bytes{area="nonheap",id="Metaspace",} 4.1996312E7
jvm_memory_used_bytes{area="nonheap",id="CodeHeap 'non-nmethods'",} 1204864.0
jvm_memory_used_bytes{area="heap",id="G1 Eden Space",} 7.9691776E7
jvm_memory_used_bytes{area="nonheap",id="Compressed Class Space",} 5303144.0
jvm_memory_used_bytes{area="nonheap",id="CodeHeap 'non-profiled nmethods'",} 6563328.0
# HELP process_uptime_seconds The uptime of the Java virtual machine
# TYPE process_uptime_seconds gauge
process_uptime_seconds 15.703
# HELP jvm_threads_peak_threads The peak live thread count since the Java virtual machine started or peak was reset
# TYPE jvm_threads_peak_threads gauge
jvm_threads_peak_threads 24.0
# HELP process_files_open_files The open file descriptor count
# TYPE process_files_open_files gauge
process_files_open_files 83.0
# HELP tomcat_sessions_expired_sessions_total
# TYPE tomcat_sessions_expired_sessions_total counter
tomcat_sessions_expired_sessions_total 0.0
# HELP process_cpu_usage The "recent cpu usage" for the Java Virtual Machine process
# TYPE process_cpu_usage gauge
process_cpu_usage 0.002284847603487466
# HELP system_load_average_1m The sum of the number of runnable entities queued to available processors and the number of runnable entities running on the available processors averaged over a period of time
# TYPE system_load_average_1m gauge
system_load_average_1m 11.57421875
# HELP jvm_buffer_memory_used_bytes An estimate of the memory that the Java virtual machine is using for this buffer pool
# TYPE jvm_buffer_memory_used_bytes gauge
jvm_buffer_memory_used_bytes{id="mapped",} 0.0
jvm_buffer_memory_used_bytes{id="direct",} 32768.0
# HELP jvm_buffer_total_capacity_bytes An estimate of the total capacity of the buffers in this pool
# TYPE jvm_buffer_total_capacity_bytes gauge
jvm_buffer_total_capacity_bytes{id="mapped",} 0.0
jvm_buffer_total_capacity_bytes{id="direct",} 32768.0
# HELP jvm_gc_memory_promoted_bytes_total Count of positive increases in the size of the old generation memory pool before GC to after GC
# TYPE jvm_gc_memory_promoted_bytes_total counter
jvm_gc_memory_promoted_bytes_total 0.0
# HELP jvm_memory_committed_bytes The amount of memory in bytes that is committed for the Java virtual machine to use
# TYPE jvm_memory_committed_bytes gauge
jvm_memory_committed_bytes{area="heap",id="G1 Survivor Space",} 7340032.0
jvm_memory_committed_bytes{area="heap",id="G1 Old Gen",} 1.90840832E8
jvm_memory_committed_bytes{area="nonheap",id="Metaspace",} 4.3646976E7
jvm_memory_committed_bytes{area="nonheap",id="CodeHeap 'non-nmethods'",} 2555904.0
jvm_memory_committed_bytes{area="heap",id="G1 Eden Space",} 1.24780544E8
jvm_memory_committed_bytes{area="nonheap",id="Compressed Class Space",} 5898240.0
jvm_memory_committed_bytes{area="nonheap",id="CodeHeap 'non-profiled nmethods'",} 6619136.0
# HELP jvm_threads_daemon_threads The current number of live daemon threads
# TYPE jvm_threads_daemon_threads gauge
jvm_threads_daemon_threads 20.0
# HELP jvm_buffer_count_buffers An estimate of the number of buffers in the pool
# TYPE jvm_buffer_count_buffers gauge
jvm_buffer_count_buffers{id="mapped",} 0.0
jvm_buffer_count_buffers{id="direct",} 4.0
# HELP jvm_threads_states_threads The current number of threads having NEW state
# TYPE jvm_threads_states_threads gauge
jvm_threads_states_threads{state="runnable",} 10.0
jvm_threads_states_threads{state="blocked",} 0.0
jvm_threads_states_threads{state="waiting",} 11.0
jvm_threads_states_threads{state="timed-waiting",} 3.0
jvm_threads_states_threads{state="new",} 0.0
jvm_threads_states_threads{state="terminated",} 0.0
# HELP tomcat_sessions_active_current_sessions
# TYPE tomcat_sessions_active_current_sessions gauge
tomcat_sessions_active_current_sessions 0.0
# HELP system_cpu_count The number of processors available to the Java virtual machine
# TYPE system_cpu_count gauge
system_cpu_count 4.0
# HELP jvm_classes_loaded_classes The number of classes that are currently loaded in the Java virtual machine
# TYPE jvm_classes_loaded_classes gauge
jvm_classes_loaded_classes 7680.0
# HELP system_cpu_usage The "recent cpu usage" for the whole system
# TYPE system_cpu_usage gauge
system_cpu_usage 0.5317742755465176
# HELP tomcat_sessions_rejected_sessions_total
# TYPE tomcat_sessions_rejected_sessions_total counter
tomcat_sessions_rejected_sessions_total 0.0
最佳答案
如果您使用 SpringBoot Micrometer Prometheus 插件我建议使用内置的 MeterRegistry
它以 Prometheus 格式收集和导出指标。
您避免了创建计数器/直方图的需要(如果直接使用 io.prometheus Simpleclient 库,则必须这样做)
@Autowired
private MeterRegistry meterRegistry;
@GetMapping(value = "/main/test", produces = "text/plain")
public String test() {
meterRegistry.counter("requests_test_total").increment();
return "ok";
}
management.endpoints.web.exposure.include=health,info,loggers,prometheus
关于spring-boot - 在 Spring Boot 中使用 prometheus 自定义指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61660765/
我在 Azure 中找不到几个 SQL 指标。任何人都可以帮助如何设置以下主题的指标。 1)产能利用率不足 2)池外的数据库数量 3)扩大规模 4)连接超时 提前致谢。 最佳答案 实际上,这些并不是
我要监控的应用程序提供了一个用于健康检查的 api 端点,它以 json 格式响应指标。例如: $ curl https://example.com/api/stats {"status":"suc
我正在考虑用于分析软件开发工作的软件指标。当我考虑在面向对象的软件中使用类似功能点的指标时,我遇到了一个有趣的挑战/问题。 考虑一个业务规则引擎。它是一种应用程序,由运行业务规则所需的组件组成,然后将
我要监控的应用程序提供了一个用于健康检查的 api 端点,它以 json 格式响应指标。例如: $ curl https://example.com/api/stats {"status":"suc
因此,我正在将旧的数据可视化转换为新平台,但我对他们的社区排序功能有点困惑。在原始代码中,作者似乎使用了带有余弦相似度计算器的凝聚聚类。我认为在 Javascript 中解决这个问题的最佳方法是使用
我不是专业程序员,但我正在尝试改变一些技术指标在名为 TradeStation 的金融图表包中的显示方式(与特定图表供应商无关)。 这就是问题所在:大多数指标都是围绕零点绘制的,有时它们会靠近零点摆动
我们存储了大量来 self 们服务的指标(大约 8000 万个事件)。我们必须根据数据生成报告。 我的问题比较笼统,哪些工具可以满足您的指标/报告需求?有什么推荐的吗? 我们使用 Apache 编写日
我们网站上的页面的 CLS 一直接近于零。这是有道理的,因为它们是服务器呈现的 HTML 页面,具有简单的静态布局。 最近我们添加了 content-visibility: auto 的使用,如下所示
我能想到几种方法来转这种类型的矩阵(数据框): dat = data.frame( x1 = rep(c('a', 'b'), 100), x2 = rep(c('x', 'y
我正在使用 codahale 指标(现在是 dropwizard 指标)来监控我系统中发生的一些“事件”。我正在使用 counters跟踪“事件”发生次数的指标。 我检查了记者为我的计数器指标打印的值
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 11 个月前关闭。 Improve this que
在不使用 Heapster 的情况下,有没有办法收集有关 Kubernetes 集群中节点的 CPU 或磁盘指标? Heapster 最初是如何收集这些指标的? 最佳答案 Kubernetes 监控在
对于二元分类问题,我有一个略微不平衡的数据集,正负比为 0.6。 我最近从这个答案中了解到了 auc 指标:https://stats.stackexchange.com/a/132832/12822
为了做一些参数调整,我喜欢用 Keras 循环一些训练函数。但是,我意识到在使用 tensorflow.keras.metrics.AUC() 时作为度量,对于每个训练循环,都会将一个整数添加到 au
我使用 Azure,现在我想在特定情况下添加短信通知。 当我使用基于日志的指标时,它效果很好,但我想针对特定异常创建通知。 下一个流程:抛出异常 => Azure 知道识别它 => Azure 发送有
我正在尝试访问给定cloudService的指标 我有以下代码: var metricsClient = new MetricsClient(new CertificateCloudCredentia
我正在尝试使用 R 和 xgboost 来研究我的模型。训练模型总体上效果很好,但对于插入符来说,度量存在一些问题。 我尝试为类列设置一个因子,但仍然没有结果。 我的数据 ID var1var2TA
我对编程还很陌生,有时它会用非常基本的概念来困扰我。我在我的 tableviewcontroller 中定义了一个 Activity 指示器作为 Outlet。 @IBOutlet weak var
我正在训练一个进行序列预测的模型。例如,给定某人之前写过的 10 个单词,我正在训练 LSTM 来预测他们将写的下一个单词。我有一个有时可以工作的模型,因此我想创建一个指标来跟踪模型通过词性标签预测下
我正在尝试使用 hystrix 来监控某个网络调用。但我尝试监控的所有指标始终为空。我做错了什么? 我通过实现一个(某种程度上)RESTful 接口(interface)来模拟网络调用,该接口(int
我是一名优秀的程序员,十分优秀!