首页 > 其他分享 >prometheus 配置文件汇总

prometheus 配置文件汇总

时间:2024-01-30 09:57:01浏览次数:20  
标签:http name 配置文件 汇总 job prometheus configs prober

prometheus

prometheus.yaml

# 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: ['192.168.39.101:9093']
          # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  - /etc/prometheus/rules/*.rules
  # - "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: ["192.168.39.101:9090"]
#-------new edit----------
  # 采集node exporter监控数据
#  - job_name: 'node'
#    static_configs:
#      - targets: ['192.168.39.101:9100']
#      - targets: ['192.168.39.102:9100']
# 使用consul自动发现
  - job_name: 'consul-prometheus'
    consul_sd_configs:
    - server: '192.168.39.102:8500'
      services: []  
    relabel_configs:
    - source_labels: [__meta_consul_tags]
      regex: .*node-exporter.*
      action: keep
    - regex: __meta_consul_service_metadata_(.+)
      action: labelmap
  - job_name: 'consul-cadvisor-exporter'
    consul_sd_configs:
    - server: '192.168.39.102:8500'
      services: []  
    relabel_configs:
    - source_labels: [__meta_consul_tags]
      regex: .*cadvisor-exporter.*
      action: keep
    - regex: __meta_consul_service_metadata_(.+)
      action: labelmap
  # 采集 boost监控
  - job_name: 'boost'
    static_configs:
      - targets: ['10.20.0.169:1288']
# cAdvisor
  - job_name: cadvisor
    static_configs:
    - targets:
      - 192.168.39.101:8080
#mysql
  - job_name: mysql
    static_configs:
    - targets:
      - 10.20.2.117:9105
# blockbox
  - job_name: baidu_http2xx_probe
    params:
      module:
      - http_2xx
      target:
      - baidu.com
    metrics_path: /probe
    static_configs:
    - targets:
      - 192.168.39.102:9115
  - job_name: prometheus_http2xx_probe
    params:
      module:
      - http_2xx
      target:
      - prometheus.io
    metrics_path: /probe
    static_configs:
    - targets:
      - 192.168.39.102:9115
# Relabeling
  - job_name: 'blackbox'
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets:
        - http://prometheus.io    # Target to probe with http.
        - https://prometheus.io   # Target to probe with https.
        - http://mi.com # Target to probe with http on port 8080.
        - http://bing.com # Target to probe with http on port 8080.
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 192.168.39.102:9115

# remote storage
#remote_write:
#  - url: "http://10.20.2.117:8086/api/v1/prom/write?db=prometheus&u=admin&p=admin"

#remote_read:
#  - url: "http://10.20.2.117:8086/api/v1/prom/read?db=prometheus&u=admin&p=admin"
remote_write:
  - url: "http://localhost:9201/write"

remote_read:
  - url: "http://localhost:9201/read"

alert rules

cat /etc/prometheus/rules/hoststats-alert.rules

groups:
- name: hostStatsAlert
  rules:
  - alert: hostCpuUsageAlert
    expr: sum(avg without (cpu_seconds_total)(irate(node_cpu_seconds_total{mode!='idle'}[5m]))) by (instance) > 0.85
    for: 1m
    labels:
      severity: page
    annotations:
      summary: "Instance {{ $labels.instance }} CPU usgae high"
      description: "{{ $labels.instance }} CPU usage above 85% (current value: {{ $value }})"
  - alert: hostMemUsageAlert
    expr: (node_memory_MemTotal - node_memory_MemAvailable)/node_memory_MemTotal > 0.85
    for: 1m
    labels:
      severity: page
    annotations:
      summary: "Instance {{ $labels.instance }} MEM usgae high"
      description: "{{ $labels.instance }} MEM usage above 85% (current value: {{ $value }})"

alertmanager

cat alertmanager-0.26.0.linux-amd64/alertmanager.yml

global:
  slack_api_url: https://hooks.slack.com/services/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
route:
  group_by: ['alertname']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 1h
  receiver: 'slack'
receivers:
  - name: 'web.hook'
    webhook_configs:
      - url: 'http://127.0.0.1:5001/'
  - name: slack
    slack_configs:
    - channel: '#prometheus_alertmananger_hook'
      send_resolved: true
      text: 'https://internal.myorg.net/wiki/alerts/{{ .GroupLabels.app }}/{{ .GroupLabels.alertname }}'
inhibit_rules:
  - source_match:
      severity: 'critical'
    target_match:
      severity: 'warning'
    equal: ['alertname', 'dev', 'instance']****

blackbox

cat blackbox_exporter-0.24.0.linux-amd64/blackbox.yml

modules:
  http_2xx:
    prober: http
    http:
      preferred_ip_protocol: "ip4"
  http_post_2xx:
    prober: http
    http:
      method: POST
  tcp_connect:
    prober: tcp
  pop3s_banner:
    prober: tcp
    tcp:
      query_response:
      - expect: "^+OK"
      tls: true
      tls_config:
        insecure_skip_verify: false
  grpc:
    prober: grpc
    grpc:
      tls: true
      preferred_ip_protocol: "ip4"
  grpc_plain:
    prober: grpc
    grpc:
      tls: false
      service: "service1"
  ssh_banner:
    prober: tcp
    tcp:
      query_response:
      - expect: "^SSH-2.0-"
      - send: "SSH-2.0-blackbox-ssh-check"
  irc_banner:
    prober: tcp
    tcp:
      query_response:
      - send: "NICK prober"
      - send: "USER prober prober prober :prober"
      - expect: "PING :([^ ]+)"
        send: "PONG ${1}"
      - expect: "^:[^ ]+ 001"
  icmp:
    prober: icmp
  icmp_ttl5:
    prober: icmp
    timeout: 5s
    icmp:
      ttl: 5****

标签:http,name,配置文件,汇总,job,prometheus,configs,prober
From: https://www.cnblogs.com/jasmine456/p/17995830

相关文章

  • 微信开发者工具快捷键汇总
     打开快捷键面板F1打开/关闭工具栏Ctrl+Shift+T打开/关闭模拟器Ctrl+Shift+D打开/关闭调试器Ctrl+Shift+M格式化文件Shift+Alt+F编译Ctrl+B刷新Ctrl+R删除行Ctrl+Shift+K向上复制行Shift+Alt+↑向上移动行Alt+↑向下复制行Shift+Alt+↓向下移动行Alt+↓更改所有匹......
  • 差异性分析汇总
    在做科研写论文的时候,我们总会听说要对数据进行差异性分析,那么何为差异性分析?差异性分析常用的方法有哪些?这些方法应该如何进行分类?如何选择?差异性分析的数据格式是怎么样的?软件如何操作、分析结果如何解读呢?今天我们通过这篇文章,对这些问题一一进行解答。一、什么是差异性分析?1......
  • 12种相关系数汇总!
    所谓相关关系是指2个或2个以上变量取值之间在某种意义下所存在的规律,其目的在于探索数据集所存在隐藏的关系网,在19世纪80年代,Galton通过研究人类身高遗传问题首次提出了相关的概念,文中指出相关关系可以定义为:一个变量变化时,另一个变量或多或少的相应的变量。这种相关关系的统计量......
  • 某国际物流港项目变更问题汇总
    合同约定按照合同专用条款约定24.工程变更25.工程变更价款约定工程变更类型含盖约定支付比例为90%按照合同补充条款约定7.工程变更价款的确定8.变更价款约定了详细的变更流程,以及最后形成文件变更申请1.1工程联系单or工程变更洽商记录1.2设计单位出具的......
  • Prometheus 主机监控管理模板
    systemd管理node_exporterhttps://prometheus.io/download/#node_exporterwgethttps://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz~]#tar-xfnode_exporter-1.7.0.linux-amd64.tar.gznode_exporter-1.7.......
  • 跟着思兼学习Klipper(26): 大卸八块 Klipper 远程控制实验汇总
    又名《给创想三维K1找个"强力外援"》前言原创文章,转载引用请务必注明链接,水平有限,如有疏漏,欢迎交流指正。文章如有更新请访问DFRobot社区及cnblogs博客园,前者内容较全,后者排版及阅读体验更佳。我们约定:主板指MCU部分,上位机指运行Klippy的MPULinux部分。玩了好......
  • es集群配置文件参考
    #集群的名称,同一个集群该值必须设置成相同的cluster.name:clusterName#该节点的名字node.name:node-2#该节点有机会成为master节点node.master:true#该节点可以存储数据node.data:true#shard的数目#设置绑定的IP地址,可以是IPV4或者IPV6network.host:0.0.0.0#节点......
  • logback.xml配置文件模板
    1<?xmlversion="1.0"encoding="UTF-8"?>2<configuration>3<!--4CONSOLE:表示当前的日志信息是可以输出到控制台的。5-->6<appendername="CONSOLE"class="ch.qos.logback.core.ConsoleAppender......
  • prometheus服务发现
    基于文件的自动发现JSON或者yaml的文件都可以,[{"targets":["localhost:8080"],"labels":{"env":"localhost","job":"cadvisor"}},{"targets":["l......
  • shell括号用法汇总
    总结:${}:作用是获取变量的结果,一般情况下,$var与${var}是没有区别的,但是用${}会比较精确的界定变量名称的边界范围。$[]:进行数学运算$():命令替换操作,同反应引号``,即命令的嵌套使用,将$()中包括的命令执行结果向外传递。举例:echotodayis$(date"+%Y-%m-%d")${}与$:$与${}都......