| 知乎專欄 | 多維度架構 | | | 微信號 netkiller-ebook | | | QQ群:128659835 請註明“讀者” |
Springboot 整合 InfluxDB 非常簡單,先引入依賴即可,記得需要同時引入 actuator
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-influx</artifactId> </dependency>
配置檔案 application.yaml 如下
spring:
application:
name: springboot-with-influxdb
server:
port: 8080
management:
metrics:
export:
influx:
enabled: true
db: springboot
uri: http://localhost:8086
user-name:
password:
connect-timeout: 1s
read-timeout: 10s
auto-create-db: true
step: 1m
num-threads: 2
consistency: one
compressed: true
batch-size: 1000
配置好 Springboot 後,啟動應用,稍後Springboot 就會將數據源源不斷地寫入到 InfluxDB 中。
> show measurements name: measurements name ---- 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 tomcat_sessions_active_current tomcat_sessions_active_max tomcat_sessions_alive_max tomcat_sessions_created tomcat_sessions_expired tomcat_sessions_rejected visits
查看數據
select * from process_cpu_usage