Grafana集成prometheus(1.Prometheus安装)

下载docker镜像

shell 复制代码
docker pull prom/prometheus
docker pull prom/node-exporter

启动

node-exporter

该程序用以采集机器内存等数据

启动脚本

shell 复制代码
docker run -d -p 9100:9100  prom/node-exporter
ss -anptl | grep 9100

启动截图

prometheus

启动脚本

shell 复制代码
# 3b907f5313b7 为镜像id
docker run -d --name prometheus -p 9090:9090 3b907f5313b7 

启动截图

映射配置文件及自定义配置

复制配置文件

配置存放路径此处以/opt/start/prometheus/conf/prometheus为例

shell 复制代码
cd /opt/start/prometheus/conf/prometheus
# 进入容器
docker exec -it prometheus /bin/sh
# 到目的文件夹下执行命令进行复制
docker cp grafana:/usr/share/grafana/conf/defaults.ini ./

停止任务并删除容器

shell 复制代码
docker stop prometheus
docker rm prometheus

修改配置prometheus.yml

  • 查看node-exporter网络地址
shell 复制代码
docker inspect node-exporter |grep Address
  • 修改配置
shell 复制代码
vim /opt/start/prometheus/conf/prometheus/prometheus.yml

修改配置(job_nametargets),其中targets为为上面安装的node-exporter对应的网络地址

shell 复制代码
# 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: ["172.17.0.4:9100"]

创建容器(带文件映射,方便后续修改配置)

shell 复制代码
# 最后面为镜像id,也可以通过REPOSITORY:TAG来替换
docker run -d --name prometheus -v /opt/start/prometheus/conf/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -p 9090:9090 3b907f5313b7

# 查看运行状态
docker ps

检查状态

  • 登录prometheus界面(ip:9090)
  • 点击status -> targets, 查看Status, Up表示正常
相关推荐
逻辑与&&1 天前
[Prometheus学习笔记]从架构到案例,一站式教程
笔记·学习·prometheus
Walden-20201 天前
构建基于 DCGM-Exporter, Node exporter,PROMETHEUS 和 GRAFANA 构建算力监控系统
docker·容器·grafana·prometheus
牛角上的男孩2 天前
部署Prometheus、Grafana、Zipkin、Kiali监控度量Istio
grafana·prometheus·istio
福大大架构师每日一题3 天前
文心一言 VS 讯飞星火 VS chatgpt (383)-- 算法导论24.5 3题
prometheus
小安运维日记6 天前
Linux云计算 |【第五阶段】CLOUD-DAY10
linux·运维·云计算·k8s·grafana·prometheus
福大大架构师每日一题6 天前
29.2 golang实战项目log2metrics架构说明
架构·prometheus
花开了¥7 天前
prometheus 快速入门
prometheus
陈小肚9 天前
k8s 1.28.2 集群部署 Thanos 对接 MinIO 实现 Prometheus 数据长期存储
kubernetes·prometheus·thanos
福大大架构师每日一题9 天前
27.9 调用go-ansible执行playbook拷贝json文件重载采集器
golang·json·ansible·prometheus
迷茫运维路10 天前
Prometheus+Telegraf实现自定义监控项配置
运维·prometheus·telegraf·自定义监控