Prometheus + Grafana安装

Prometheus是一款基于时序数据库的开源监控告警系统,非常适合Kubernetes集群的监控。Prometheus的基本原理是通过HTTP协议周期性抓取被监控组件的状态,任意组件只要提供对应的HTTP接口就可以接入监控。不需要任何SDK或者其他的集成过程。这样做非常适合做虚拟化环境监控系统,比如VM、Docker、Kubernetes等。
Grafana是一款开源的数据可视化工具,使用Grafana可以非常轻松的将数据转成图表(如下图)的展现形式来做到数据监控以及数据统计。 Grafana专注于时序类图表分析,而且支持多种数据源,如Graphite、InfluxDB、Elasticsearch、Mysql、K8s、Zabbix等。

环境准备

安装Docker

powershell 复制代码
wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
powershell 复制代码
yum -y install docker-ce
powershell 复制代码
systemctl enable docker
systemctl start docker

拉取镜像:

shell 复制代码
docker pull bitnami/prometheus
docker pull grafana/grafana

启动prometheus

新建目录 prometheus,编辑配置文件prometheus.yml

shell 复制代码
mkdir /opt/prometheus
cd /opt/prometheus/
vim prometheus.yml

挂载配置文件:

yaml 复制代码
global:
  scrape_interval:     60s
  evaluation_interval: 60s
 
scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ['localhost:9090']
        labels:
          instance: prometheus
 
  - job_name: linux
    static_configs:
      - targets: ['127.0.0.1:9100']
        labels:
          instance: localhost
复制代码
docker run  -d \
  -p 9090:9090 \
  -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml  \
  bitnami/prometheus

访问127.0.0.1:9090/graph

启动grafana

新建空文件夹grafana-storage,用来存储数据

shell 复制代码
mkdir /opt/grafana-storage

设置权限,因为grafana用户会在这个目录写入文件,直接设置777!

shell 复制代码
chmod 777 -R /opt/grafana-storage

启动镜像

yaml 复制代码
docker run -d \
  -p 3000:3000 \
  --name=grafana \
  -v /opt/grafana-storage:/var/lib/grafana \
  grafana/grafana

默认账号密码:admin admin

相关推荐
hweiyu009 小时前
Go、DevOps运维开发实战(视频教程)
开发语言·golang·运维开发
路由侠内网穿透.3 天前
外网访问可视化工具 Grafana (Linux版本)
linux·运维·服务器·grafana·远程工作
麦兜*3 天前
Spring Boot 应用 Docker 监控:Prometheus + Grafana 全方位监控
spring boot·后端·spring cloud·docker·prometheus
罗不俷4 天前
Prometheus 详解:从原理到实战,打造企业级云原生监控体系
云原生·prometheus
Deamon Tree6 天前
Prometheus和Grafana简介
grafana·prometheus
苦逼IT运维6 天前
Kubernetes 双层 Nginx 容器环境下的 CORS 问题及解决方案(极端情况)
运维·nginx·容器·kubernetes·jenkins·运维开发·ci
码界奇点6 天前
Apache IoTDB 架构特性与 PrometheusGrafana 监控体系部署实践
架构·apache·grafana·prometheus·iotdb
Linux-palpitate6 天前
基于Prometheus和Grafana的MySQL监控,服务器监控
服务器·grafana·prometheus
hello_2507 天前
golang程序对接prometheus
开发语言·golang·prometheus
weixin_307779138 天前
C#程序实现将Teradata的存储过程转换为Amazon Redshift的pgsql的存储过程
数据库·c#·云计算·运维开发·aws