Prometheus的介绍及初步使用

2020-04-09  本文已影响0人  睦月MTK

一、Prometheus

二、Prometheus的安装及配置
# 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).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']

  - job_name: 'springboot'
    scrape_interval: 5s
    metrics_path: "/actuator/prometheus"
    static_configs:
    - targets: ['localhost:8080']

scrape_config是用来配置需要进行监控的任务(job),每个任务对应一个或多个待监控的容器,默认配置只有名为“prometheus”的任务,该任务会从目标localhost:9090/metrics处获取发布的性能指标信息,第二个任务是我配置的,用于模拟真实环境中的一个待监控的应用,该应用是一个springboot项目,你可以从项目地址处克隆它,该应用会将相关性能指标信息发布到localhost:8080/actuactor/prometheus


三、Prometheus的简单使用
# 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 tomcat_sessions_active_current_sessions  
# TYPE tomcat_sessions_active_current_sessions gauge
tomcat_sessions_active_current_sessions 0.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",} 1.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 0.0

每一种性能指标信息前面都加上了相关注释,用来告知该性能指标的类型等信息,且都有以下格式指标名{名值对} 指标值

$ prometheus --config.file=prometheus.yml

参考文档:
[1] Prometheus overview
[2] First steps with Prometheus

上一篇 下一篇

猜你喜欢

热点阅读