micrometer
自从我们添加了基本应用程序以来,是时候启动InfluxDB实例了。
我们将按照之前的教程进行操作,并添加一个docker实例。
docker run –rm -p 8086:8086 –name influxdb-本地influxdb
是时候在我们的pom上添加微米InfluxDB依赖项了
< dependencies > ...
< dependency >
< groupId >org.springframework.boot</ groupId >
< artifactId >spring-boot-starter-actuator</ artifactId >
</ dependency >
< dependency >
< groupId >io.micrometer</ groupId >
< artifactId >micrometer-core</ artifactId >
< version >1.3.2</ version >
</ dependency >
< dependency >
< groupId >io.micrometer</ groupId >
< artifactId >micrometer-registry-influx</ artifactId >
< version >1.3.2</ version >
</ dependency > ... </ dependencies >
是时候通过application.yaml添加配置了
management:
metrics:
export:
influx:
enabled: true
db: devjobsapi
uri: http: / / 127.0 . 0.1 : 8086
endpoints:
web:
expose: "*"
让我们启动应用程序并执行一些请求。
一段时间后,我们可以检查数据库和其中包含的数据。
docker exec -it influxdb- local influx > SHOW DATABASES; name: databases name ---- _internal devjobsapi > use devjobsapi Using database devjobsapi > SHOW MEASUREMENTS name: measurements name ---- http_server_requests jvm_buffer_count jvm_buffer_memory_used jvm_buffer_total_capacity jvm_classes_loaded jvm_classes_unloaded jvm_gc_live_data_size jvm_gc_max_data_size jvm_gc_memory_allocated jvm_gc_memory_promoted jvm_gc_pause jvm_memory_committed jvm_memory_max jvm_memory_used jvm_threads_daemon jvm_threads_live jvm_threads_peak jvm_threads_states logback_events process_cpu_usage process_files_max process_files_open process_start_time process_uptime system_cpu_count system_cpu_usage system_load_average_1m
太棒了 让我们检查访问的端点。
> SELECT*FROM http_server_requests; name: http_server_requests time count exception mean method metric_type outcome status sum upper uri ---- ----- --------- ---- ------ ----------- ------- ------ --- ----- --- 1582586157093000000 1 None 252.309331 GET histogram SUCCESS 200 252.309331 252.309331 /actuator 1582586157096000000 0 None 0 GET histogram SUCCESS 200 0 2866.531375 /jobs/github/{page}
太棒了! 下一步将是可视化那些指标。
micrometer