• spring boot监控之prometheus配置


    1,spring boot工程引入jar包

    compile 'org.springframework.boot:spring-boot-starter-actuator'
    compile 'io.micrometer:micrometer-core:1.3.5'
    compile 'io.micrometer:micrometer-registry-prometheus:1.3.5'

    2,修改spring boot工程配置

    management:
      server:
        port: 10091
      endpoints:
        web:
          exposure:
            include: '*'

    3,监控代码示例

     Counter counter = Metrics.counter("counter", "tag-1", "tag-2");
     counter.increment();

    4, 启动Spring boot工程

      启动后访问http://localhost:10091/actuator,应该能看到返回很多链接,如能看到http://localhost:10091/actuator/prometheus, 说明正确。

    5,安装配置prometheus

        下载安装后后,修改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).
    
    # 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: /actuator/prometheus
        # scheme defaults to 'http'.
    
        static_configs:
        - targets: ['localhost:10091']

    6, 启动prometheus,查看运行效果

  • 相关阅读:
    Codeforces Round #239(Div. 2) 做后扯淡玩
    hdu 3507 Print Article
    prufer序列
    POJ 2778 DNA Sequence
    Codeforces Round #237 (Div. 2)
    poj3352
    图论知识
    POJ 2186
    Codeforces Round #236 (Div. 2)
    POJ 2823 Sliding Window
  • 原文地址:https://www.cnblogs.com/season2009/p/12424882.html
Copyright © 2020-2023  润新知