zoukankan      html  css  js  c++  java
  • prometheus配置

    本文主要记录下测试环境积累的prometheus配置信息,主要是k8s基本节点的配置和cadvisor的配置,方便以后使用做为参考

    global:
      scrape_interval: 30s
      scrape_timeout: 30s
    scrape_configs:
    - job_name: 'prometheus'
      static_configs:
        - targets: ['localhost:9090']
    - job_name: 'kubernetes-cluster'
      scheme: https
      tls_config:
        insecure_skip_verify: true
      kubernetes_sd_configs:
      - api_server: "http://192.168.180.101:8080"
        role: node
    - job_name: 'kubernetes-service-endpoints'
      scheme: https
      tls_config:
        insecure_skip_verify: true
      kubernetes_sd_configs:
      - api_server: "http://192.168.180.101:8080"
        role: endpoints
      relabel_configs:
      - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]
        action: keep
        regex: true
      - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme]
        action: replace
        target_label: __scheme__
        regex: (https?)
      - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_path]
        action: replace
        target_label: __metrics_path__
        regex: (.+)
      - source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]
        action: replace
        target_label: __address__
        regex: (.+)(?::d+);(d+)
        replacement: $1:$2
      - action: labelmap
        regex: __meta_kubernetes_service_label_(.+)
      - source_labels: [__meta_kubernetes_service_namespace]
        action: replace
        target_label: kubernetes_namespace
      - source_labels: [__meta_kubernetes_service_name]
        action: replace
        target_label: kubernetes_name
    - job_name: 'kubernetes-services'
      scheme: https
      tls_config:
        insecure_skip_verify: true
      metrics_path: /probe
      params:
        module: [http_2xx]
      kubernetes_sd_configs:
      - api_server: "http://192.168.180.101:8080"
        role: service
      relabel_configs:
      - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_probe]
        action: keep
        regex: true
      - source_labels: [__address__]
        target_label: __param_target
      - target_label: __address__
        replacement: blackbox
      - source_labels: [__param_target]
        target_label: instance
      - action: labelmap
        regex: __meta_kubernetes_service_label_(.+)
      - source_labels: [__meta_kubernetes_service_namespace]
        target_label: kubernetes_namespace
      - source_labels: [__meta_kubernetes_service_name]
        target_label: kubernetes_name
    - job_name: 'kubernetes-pods'
      scheme: https
      tls_config:
        insecure_skip_verify: true
      kubernetes_sd_configs:
      - api_server: "http://192.168.180.101:8080"
        role: pod
      relabel_configs:
      - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
        action: keep
        regex: true
      - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
        action: replace
        target_label: __metrics_path__
        regex: (.+)
      - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
        action: replace
        regex: (.+):(?:d+);(d+)
        replacement: ${1}:${2}
        target_label: __address__
      - action: labelmap
        regex: __meta_kubernetes_pod_label_(.+)
      - source_labels: [__meta_kubernetes_pod_namespace]
        action: replace
        target_label: kubernetes_namespace
      - source_labels: [__meta_kubernetes_pod_name]
        action: replace
        target_label: kubernetes_pod_name
    # Scrape config for Kubelet cAdvisor.
    #
    # This is required for Kubernetes 1.7.3 and later, where cAdvisor metrics
    # (those whose names begin with 'container_') have been removed from the
    # Kubelet metrics endpoint.  This job scrapes the cAdvisor endpoint to
    # retrieve those metrics.
    #
    # In Kubernetes 1.7.0-1.7.2, these metrics are only exposed on the cAdvisor
    # HTTP endpoint; use "replacement: /api/v1/nodes/${1}:4194/proxy/metrics"
    # in that case (and ensure cAdvisor's HTTP server hasn't been disabled with
    # the --cadvisor-port=0 Kubelet flag).
    #
    # This job is not necessary and should be removed in Kubernetes 1.6 and
    # earlier versions, or it will cause the metrics to be scraped twice.
    # 在k8s 1.6和以前的版本不用增加cadvisor数据采集,之后的版本就需要单独增加cadvisor采集数据
    - job_name: 'kubernetes-nodes-cadvisor'
      # Default to scraping over https. If required, just disable this or change to
      # `http`.
      scheme: http
      tls_config:
        insecure_skip_verify: true
      kubernetes_sd_configs:
      - api_server: "http://192.168.180.101:8080"
    # 这里的role一定要注意是node
        role: node
      relabel_configs:
      - source_labels: [__meta_kubernetes_role]
        action: replace
        target_label: kubernetes_role
        regex: (.+)
    # 将默认10250端口改成10255端口
      - source_labels: [__address__]
        action: replace
        regex: '(.*):10250'
        replacement: '${1}:10520'
        target_label: __address__
      - action: labelmap
        regex: __meta_kubernetes_node_label_(.+)
  • 相关阅读:
    F12
    InnerClass.java
    Java8
    对象下—练习4
    对象下—练习3
    模板方法
    对象下—练习2
    对象下—举例二、三
    【J-Link】J-Link不支持(版本太低)
    【Android】安装插件 + 改变文字大小、颜色 + 隐藏代码区块的直线
  • 原文地址:https://www.cnblogs.com/davygeek/p/7886215.html
Copyright © 2011-2022 走看看