docker部署prometheus+grafana服务器监控(一)

news2024/9/29 17:28:22

docker-compose 部署prometheus+grafana

Prometheus

Prometheus 是有 SoundCloud 开发的开源监控系统和时序数据库,基于 Go 语言开发。通过基于 HTTP 的 pull 方式采集时序数据,通过服务发现或静态配置去获取要采集的目标服务器,支持多节点工作,支持多种可视化图表及仪表盘。

贴一下官方提供的架构图:

在这里插入图片描述

Pormetheus 几个主要模块有,Server,Exporters,Pushgateway,PromQL,Alertmanager,WebUI 等,主要逻辑如下:

Prometheus server 定期从静态配置的 targets 或者服务发现的 targets 拉取数据。

当新拉取的数据大于配置内存缓存区时,Prometheus 会将数据持久化到磁盘(如果使用 remote storage 将持久化到云端)。

Prometheus 配置 rules,然后定时查询数据,当条件触发时,会将 alert 推送到配置的 Alertmanager。

Alertmanager 收到警告时,会根据配置,聚合、去重、降噪等操作,最后发送警告。

可以使用 API,Prometheus Console 或者 Grafana 查询和聚合数据。

Grafana

Grafana 是一个开源的度量分析及可视化套件。通过访问数据库(如 InfluxDB、Prometheus),展示自定义图表。

Exporter
Exporter 是 Prometheus 推出的针对服务器状态监控的 Metrics 工具。目前开发中常见的组件都有对应的 exporter 可以直接使用。常见的有两大类,一种是社区提供的,包含数据库,消息队列,存储,HTTP 服务,日志等,比如 node_exporter,mysqld_exporter 等;还有一种是用户自定义的 exporter,可以基于官方提供的 Client Library 创建自己的 exporter 程序。

每个 exporter 的一个实例被称为 target,Prometheus 通过轮询的方式定期从这些 target 中获取样本数据。

在这里插入图片描述

原理简介

在这里插入图片描述

直接先看docker-compose.yml
version: "3.8"
services:
  node-exporter:
    image: prom/node-exporter:latest
    container_name: "node-exporter0"
    ports:
      - "9100:9100"
    restart: always
  prometheus:
    image: prom/prometheus:latest
    container_name: "prometheus0"
    user: root
    restart: always
    ports:
      - "9090:9090"
    volumes:
      - "./conf/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml"
      - "./prometheus_data:/prometheus"
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--web.console.libraries=/usr/share/prometheus/console_libraries'
      - '--web.console.templates=/usr/share/prometheus/consoles'
  grafana:
    image: grafana/grafana
    container_name: "grafana0"
    user: root
    ports:
      - "3000:3000"
    restart: always
    volumes:
      - "./grafana_data:/var/lib/grafana"
    depends_on:
      -  prometheus

  alertmanager:
    image: prom/alertmanager
    hostname: alertmanager
    container_name: alertmanager
    user: root
    restart: always
    ports:
      - "9093:9093"
    volumes:
      - ./data/prometheus/alertmanager_data:/var/lib/alertmanager

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 defaults to '/metrics'
    # scheme defaults to 'http'.

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

  - job_name: "node-exporter"
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["node-exporter:9100"]
 # 服务器1 根据自己情况调整
  - job_name: "node-dw"
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["192.168.1.5:9100"]
   # 服务器2 根据自己情况调整
  - job_name: "node-bj02-online-01"
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["192.168.1.7:9100"]

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1129852.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Kubernetes 部署 kubeflow1.7.0

KubeFlow 是一个开源的项目&#xff0c;旨在为 Kubernetes 提供可组合、便携式、可扩展的机器学习技术栈。它最初是为了解决在 Kubernetes 上运行分布式机器学习任务所带来的挑战而创建的。Kubernetes 本身是一个容器平台&#xff0c;但在近年来&#xff0c;越来越多的公司开始…

【Html】交通灯问题

效果 实现方式 计时器&#xff1a;setTimeout或setInterval来计时。setInterval和 setTimeout 在某些情况下可能会出现计时不准确的情况。这通常是由于JavaScript的事件循环机制和其他代码执行所需的时间造成的。 问询&#xff1a;通过getCurrentLight将每个状态的持续时间设置…

解密分布式事务:CAP理论、BASE理论、两阶段提交(2PC)、三阶段提交(3PC)、补偿事务(TCC)、MQ事务消息、最大努力通知

文章目录 &#x1f34a; CAP理论&#x1f34a; BASE理论&#x1f34a; 两阶段提交&#xff08;2PC&#xff09;&#x1f389; XA事务 &#x1f34a; 三阶段提交&#xff08;3PC&#xff09;&#x1f34a; 补偿事务&#xff08;TCC&#xff09;&#x1f34a; MQ事务消息&#x1…

web开发初级工程师学习笔记ing(持续更新)!!!

web开发初级工程师学习笔记 前端开发工具实验1 VS Code 初体验介绍 前端开发工具 实验1 VS Code 初体验 介绍 VS Code 环境提供的是一个可以在浏览器中使用原生 VS Code 编辑代码的程序。在该环境中&#xff0c;你可以使用到与本地安装近乎一致的 VS Code 程序来编辑代码文件…

计算机网络(谢希仁)第八版课后题答案(第二章)

1.物理层要解决哪些问题&#xff1f;物理层的主要特点是什么&#xff1f; (1)物理层要尽可能地屏蔽掉物理设备和传输媒体&#xff0c;通信手段的不同&#xff0c;使数据链路层感觉不到这些差异&#xff0c;只考虑完成本层的协议和服务。 (2)给其服务用户&#xff08;数据链路…

IO多路复用技术

IO多路复用 一、概念 IO多路复用技术 是一种 网络通信 的方式&#xff0c;通过这种方式可以同时检测多个 文件描述符&#xff08;这个过程是阻塞的&#xff09;&#xff0c;一旦检测到某一个文件描述符&#xff08;状态是 可读 或者 可写 的&#xff09;是就绪的&#xff0c;…

苏州健雄职业技术学院人工智能学院学生在“火焰杯”软件测试开发选拔赛总决赛获奖

3月22日&#xff0c;第三届“火焰杯”软件测试开发选拔赛颁奖仪式在人工智能学院D2-102机房举行&#xff0c;软件工程20级学生和软件测试社团全体社团成员参加本次活动。本次活动由测吧&#xff08;北京&#xff09;科技有限公司项目总监王雪冬担任颁奖嘉宾&#xff0c;并为同学…

使用Windows平台的Hyper-V虚拟机安装CentOS7的详细过程

Hyper-V虚拟机安装CentOS7 前言常见Linux系统CentOSUbuntuDebianKaliFedoraArch LinuxMintManjaroopenSUSE Hyper-V开启Hyper-V打开Hyper-V Hyper-V的使用新建虚拟机开始安装分区配置开始安装 修改yum源为阿里源 前言 作为一名开发者&#xff0c;就服务器而言&#xff0c;接触最…

SpringMVC 报文信息转换器(HttpMessageConverter)

文章目录 描述1、RequestBody2、RequestEntity3、ResponseBody4、SpringMVC处理json5、SpringMVC处理ajax6、RestController注解7、ResponseEntity 描述 HttpMessageConverter&#xff0c;报文信息转换器&#xff0c;将请求报文转换为Java对象&#xff0c;或将Java对象转换为响…

Linux:firewalld防火墙-(实验2)-IP伪装与端口转发(4)

实验环境 本章实验环境要建立在上一章之上&#xff0c;ip等都是继承上一章&#xff0c;完全在上一章之下的操作 Linux&#xff1a;firewalld防火墙-小环境实验&#xff08;3&#xff09;-CSDN博客https://blog.csdn.net/w14768855/article/details/133996151?spm1001.2014.3…

动态链接函数(dlopen/dlsym/dlclose)使用总结

一、简介 动态链接函数操作&#xff08;显式运行时链接&#xff09;主要包含头文件dlfcn.h&#xff08;/usr/include/dlfcn.h&#xff09;&#xff0c;涉及的常用的函数主要有dlopen&#xff0c;dlysm&#xff0c;dlclose。主要作用是从动态库中加载函数到程序中使用&#xff…

shell脚本条件语句(极其粗糙版)

条件测试操作和条件测试语句&#xff1a; $?:条件判断&#xff0c;失败或者成功&#xff0c;真或者假&#xff0c;true false shell脚本中&#xff1a;0为真&#xff0c;true 执行成功&#xff1b;其他所有的非0 都是假&#xff0c; false&#xff0c;执行失败 条件测试的命…

如何禁止员工上班玩游戏

如何禁止员工上班玩游戏 在这个游戏盛行的年代里&#xff0c;不少游戏玩家会玩到忘我的状态&#xff0c;也有不少员工在上班的时候也要玩上两把&#xff0c;但是公司是雇佣员工的时间是来工作的&#xff0c;出现这种情况很显然是对公司不利的&#xff0c;会严重影响工作效率和…

Python print 函数用法总结

Python3 print 函数用法总结 一、print()函数概述 print() 方法用于打印输出&#xff0c;是python中最常见的一个函数。 print([*objects][,seq ][,end\n][,filesys.stdout]) 参数的具体含义如下&#xff1a; objects --表示输出的对象。输出多个对象时&#xff0c;需要用…

MySQL---表的增查改删(CRUD基础)

文章目录 什么是CRUD&#xff1f;新增&#xff08;Create&#xff09;单行数据 全列插入多行数据 指定列插入 查询&#xff08;Retrieve&#xff09;全列查询指定列查询查询字段为表达式起别名查询去重查询排序查询条件查询分页查询 修改&#xff08;Update&#xff09;删除&…

新手如何备考学习PMP?

一、PMP学习7步走攻略 1、熟悉考试大纲&#xff1a; PMP考试大纲是备考的基础&#xff0c;考生需要详细熟悉考试大纲&#xff0c;了解各个知识领域的重点和难点。 2、制定学习计划&#xff1a; 根据考试大纲和个人情况&#xff0c;制定学习计划&#xff0c;合理分配学习时间…

stm32移植u8g2库内存不足解决办法

1.现象 跟着视频教程移植完u8g2库到stm32f103c8t6后&#xff0c;进行编译&#xff0c;报了100多个空间不足的问题&#xff0c;如下图。 ..\Output\Output.axf: Error: L6406E: No space in execution regions with .ANY selector matching u8g2_fonts.o(.constdata). ..\Outp…

蓝天远控2023(VIP会员版)

蓝天远控2023&#xff08;VIP会员版&#xff09;下载地址&#xff1a;https://user.qzone.qq.com/512526231/main

【逆向】导入表注入

练手的exe链接 链接&#xff1a;https://pan.baidu.com/s/1_87QNHaZYlfY_5uwIRePUQ?pwd6gds 提取码&#xff1a;6gds 原理&#xff1a; 在动态链接库一章提到DllMain&#xff0c;这里再回顾一次 当dll被加载进4GB空间时&#xff0c;会调用一次DllMain&#xff08;入口方法&…

在家制作电子相册一定需要的一款工具

​随着科技的发展&#xff0c;越来越多的人开始喜欢在家制作电子相册&#xff0c;记录自己的生活点滴。那么&#xff0c;如何在家制作电子相册呢&#xff1f; 一款好的工具是必不可少的。可以使用这款工具&#xff0c;轻松上手----FLBOOK在线制作电子杂志平台 1.打开FLBOOK在线…