├── README.md ├── docker-compose.yml ├── grafana.ini └── prometheus.yml /README.md: -------------------------------------------------------------------------------- 1 | # Grafana 中文教程 2 | 3 | 文本教程原文发布在:https://kalacloud.com/blog/grafana-with-prometheus-tutorial/ 4 | 5 | 6 | ## 什么是 Grafana 7 | Grafana 是由 Grafana Labs 开发的开源监控监控系统,你可以用它来监控线上系统,极大地简化运维和开发工作。 8 | 9 | 它不对数据源作假设,因此你可以用包括 Prometheus, MySQL 在内的任何(时序)数据库搭配使用。 10 | 11 | ## 如何使用本教程 12 | 13 | 请阅读原文:https://kalacloud.com/blog/grafana-with-prometheus-tutorial/ 14 | 15 | 原文中会用到本目录的代码 16 | 17 | ## 如何启动 Grafana 18 | 19 | 请 clone 本教程代码,然后确认本地已经安装 docker-compose 后,在本目录运行 20 | 21 | `docker-compose up` 22 | 23 | 这条命令会启动三个 docker 容器,包括 24 | 25 | `prometheus`, `service` 和 `grafana` 26 | 27 | 其中 `prometheus` 是普罗米修斯时序数据库 28 | 29 | `service` 是普罗米修斯自带的数据生成器(监控本机 CPU 内存等信息) 30 | 31 | `grafana` 就是 Grafana 服务本身 32 | 33 | ## 访问 localhost:3000 34 | 35 | 在你的浏览器中访问 `localhost:3000` 即可看到运行的 Grafana,再根据教程中的步骤设置好源即可 36 | 37 | ## 下一步 38 | 39 | 请继续关注卡拉云博客,在之后的文章中我们将继续介绍如何用 Prometheus 实现监控具体的服务,如何用 PromQL 等 40 | 41 | 42 | 其它教程: 43 | 44 | [REST API 设计指南](https://kalasearch.cn/blog/rest-api-best-practices/) 45 | 46 | [ElasticSearch 终极教程 - 第一章](https://kalasearch.cn/blog/elasticsearch-tutorial/) 47 | 48 | [ElasticSearch 终极教程 - 第二章](https://kalasearch.cn/blog/chapter2-run-elastic-search-locally/) 49 | 50 | [ElasticSearch 终极教程 - 第三章](https://kalasearch.cn/blog/chapter3-elastic-search-and-lucene/) 51 | 52 | [NoSQL 数据库管理系统和模型比较](https://kalasearch.cn/community/tutorials/comparison-of-nosql-databases/) 53 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | services: 3 | prometheus: 4 | image: prom/prometheus 5 | container_name: prometheus 6 | hostname: prometheus 7 | ports: 8 | - 9090:9090 9 | volumes: 10 | - ./prometheus.yml:/etc/prometheus/prometheus.yml 11 | prometheus-exporter: 12 | image: prom/node-exporter 13 | container_name: service 14 | hostname: service 15 | ports: 16 | - 9100:9100 17 | grafana: 18 | image: grafana/grafana 19 | container_name: grafana 20 | hostname: grafana 21 | ports: 22 | - 3000:3000 23 | volumes: 24 | - ./grafana.ini:/etc/grafana/grafana.ini 25 | 26 | -------------------------------------------------------------------------------- /grafana.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kalasearch/grafana-tutorial/eab0890fcfc494582c42c71e9a43ef9d35cc18a2/grafana.ini -------------------------------------------------------------------------------- /prometheus.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 10s 3 | 4 | scrape_configs: 5 | - job_name: node 6 | static_configs: 7 | - targets: ['service:9100'] # NOT localhost since we named the host of service in docker-compose file 8 | 9 | --------------------------------------------------------------------------------