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表示正常
相关推荐
AC赳赳老秦16 小时前
外文文献精读:DeepSeek翻译并解析顶会论文核心技术要点
前端·flutter·zookeeper·自动化·rabbitmq·prometheus·deepseek
牛奶咖啡132 天前
Prometheus+Grafana构建云原生分布式监控系统(十二)_基于DNS的服务发现
云原生·prometheus·dns·搭建自己的dns服务器·使用bind搭建dns服务器·配置正向解析·基于dns的服务发现
A-刘晨阳3 天前
Prometheus + Grafana + Alertmanager 实现邮件监控告警及配置告警信息
运维·云计算·grafana·prometheus·监控·邮件
饺子大魔王的男人3 天前
告别服务器失联!Prometheus+Alertmanager+cpolar 让监控告警不局限于内网
运维·服务器·prometheus
牛奶咖啡134 天前
Prometheus+Grafana构建云原生分布式监控系统(十一)_基于consul的服务发现
云原生·prometheus·consul的安装部署·consul服务自动发现·consul服务的注册删除·consul服务的更新·实现自动去consul注册服务
Otto_10275 天前
在 OpenStack Rocky 中部署 Prometheus + Grafana
openstack·grafana·prometheus
牛奶咖啡135 天前
Prometheus+Grafana构建云原生分布式监控系统(十)_prometheus的服务发现机制(一)
云原生·prometheus·prometheus服务发现·静态服务发现·动态服务发现·基于文件的服务发现配置实践·prometheus标签重写
玄德公笔记5 天前
Prometheus监控k8s的metric详解(第二版)-01-scrape 指标抓取
kubernetes·k8s·prometheus·监控·metric·scrape·k8s监控
小北方城市网5 天前
Spring Boot Actuator+Prometheus+Grafana 生产级监控体系搭建
java·spring boot·python·rabbitmq·java-rabbitmq·grafana·prometheus
牛奶咖啡136 天前
Prometheus+Grafana构建云原生分布式监控系统(九)_pushgateway的使用
云原生·grafana·prometheus·pushgateway·pushgateway使用场景·推数据到pushgateway·pushgateway的使用