简介

prometheus存储的是时序数据,即按相同时序(相同名称和标签),以时间维度存储连续的数据的集合。

时序(time series)是由名字(Metric)以及一组key/value标签定义的,具有相同的名字以及标签属于相同时序。


Metric类型:

  • Counter: 一种累加的metric,如请求的个数,结束的任务数,出现的错误数等

  • Gauge: 常规的metric,如温度,可任意加减。其为瞬时的,与时间没有关系的,可以任意变化的数据。

  • Histogram: 柱状图,用于观察结果采样,分组及统计,如:请求持续时间,响应大小。其主要用于表示一段时间内对数据的采样,并能够对其指定区间及总数进行统计。根据统计区间计算

  • Summary: 类似Histogram,用于表示一段时间内数据采样结果,其直接存储quantile数据,而不是根据统计区间计算出来的。不需要计算,直接存储结果


PromQL:

PromQL (Prometheus Query Language) 是 Prometheus 自己开发的数据查询 DSL 语言。

查询结果类型:

  • 瞬时数据 (Instant vector): 包含一组时序,每个时序只有一个点,例如:http_requests_total
  • 区间数据 (Range vector): 包含一组时序,每个时序有多个点,例如:http_requests_total[5m]
  • 纯量数据 (Scalar): 纯量只有一个数字,没有时序,例如:count(http_requests_total)

架构图

安装部署

环境准备

主机名 角色 IP 系统版本 内核版本
es01.k8s.com node01 10.0.20.11 CentOS 7.5 5.1.4-1.el7.elrepo.x86_64

官网: prometheus.io

prometheus 下载地址: https://github.com/prometheus/prometheus/releases/download/v2.14.0/prometheus-2.14.0.linux-amd64.tar.gz

安装

prometheus 安装使用二进制安装,解压后即可直接启动。

[root@es01 soft]# ls -l prometheus-2.14.0.linux-amd64.tar.gz
-rw-r--r-- 1 root root 58625125 Nov 12 00:21 prometheus-2.14.0.linux-amd64.tar.gz [root@es01 soft]# tar xf prometheus-2.14.0.linux-amd64.tar.gz [root@es01 soft]# ls prometheus-2.14.0.linux-amd64
console_libraries consoles LICENSE NOTICE prometheus prometheus.yml promtool tsdb [root@es01 soft]# mv prometheus-2.14.0.linux-amd64 /opt/prometheus-2.14 [root@es01 soft]# mkdir /opt/prometheus-2.14/{bin,config,data,logs} [root@es01 soft]# cd /opt/prometheus-2.14/
[root@es01 prometheus-2.14]# mv prometheus promtool tsdb bin/
[root@es01 prometheus-2.14]# mv prometheus.yml config/ [root@es01 prometheus-2.14]# ll
total 20
drwxr-xr-x 2 root root 52 Nov 21 16:43 bin
drwxr-xr-x 4 root root 151 Nov 25 09:30 config
drwxr-xr-x 2 3434 3434 38 Nov 12 00:17 console_libraries
drwxr-xr-x 2 3434 3434 173 Nov 12 00:17 consoles
drwxr-xr-x 12 root root 4096 Nov 25 09:00 data
-rw-r--r-- 1 3434 3434 11357 Nov 12 00:17 LICENSE
drwxr-xr-x 2 root root 23 Nov 21 16:49 logs
-rw-r--r-- 1 3434 3434 3184 Nov 12 00:17 NOTICE

配置环境变量

[root@es01 prometheus-2.14]# echo '/opt/prometheus-2.14/bin:$PATH' >> /etc/profile
[root@es01 prometheus-2.14]# source /etc/profile
[root@es01 prometheus-2.14]# prometheus --version
prometheus, version 2.14.0 (branch: HEAD, revision: edeb7a44cbf745f1d8be4ea6f215e79e651bfe19)
build user: root@df2327081015
build date: 20191111-14:27:12
go version: go1.13.4

能输出以上内容,及表示配置完成。

配置

默认的配置文件,既可以直接启动

[root@es01 prometheus-2.14]# egrep -v '^#' prometheus.yml
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). alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093 rule_files:
# - "first_rules.yml"
# - "second_rules.yml" 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']

启动

直接使用 nohub 把进程放到后台运行

[root@es01 config]# nohup /opt/prometheus-2.14/bin/prometheus --config.file=/opt/prometheus-2.14/config/prometheus.yml --web.enable-lifecycle --storage.tsdb.path=/opt/prometheus-2.14/data/ --log.level=info --log.format=json &>> /opt/prometheus-2.14/logs/prometheus.log &
  • --config.file 指定配置文件目录
  • --web.enable-lifecycle 开启通过 http://prometheus:port/-/reload 访问重新加载配置文件
  • --storage.tsdb.path 配置prometheus数据保存目录
  • --log.level 配置输出日志级别
  • --log.format 配置日志输出格式

更多启动参数,请使用 prometheus -h 进行查看。

[root@es01 config]# netstat -lntup | grep 9090
tcp6 0 0 :::9090 :::* LISTEN 25469/prometheus

安装完成

Prometheus 安装的更多相关文章

  1. Prometheus安装

    Prometheus安装 下载地址: https://prometheus.io/download/ 现在时间是: 2019.09.07 安装环境: Linux centos7 minimal 虚拟机 ...

  2. Prometheus 安装Alertmanager集成

    Prometheus 安装Alertmanager集成 # 下载地址 地址1:https://prometheus.io/download/ 地址2:https://github.com/promet ...

  3. Prometheus 安装Grafana与Prometheus集成

    Prometheus 安装Grafana与Prometheus集成 Grafana是一个开源的度量分析和可视化系统. 下载地址:https://grafana.com/grafana/download ...

  4. Prometheus 安装部署

    Prometheus 安装部署 安装版本:prometheus-2.6.1 百度云下载:https://pan.baidu.com/s/1w16lQZKw8PCHqlRuSK2i7A 提取码:lw1q ...

  5. Prometheus安装教程

    Prometheus安装教程 欢迎关注H寻梦人公众号 参考目录 docker安装Prometheus 基于docker 搭建Prometheus+Grafana prometheus官方文档 dock ...

  6. Prometheus安装和配置node_exporter监控主机

    Node_exporter是可以在* Nix和Linux系统上运行的计算机度量标准的导出器. Node_exporter 主要用于暴露 metrics 给 Prometheus,其中 metrics ...

  7. prometheus安装、使用

    本文主要参考https://songjiayang.gitbooks.io/prometheus/introduction/what.html 二进制包安装 我们可以到 Prometheus 二进制下 ...

  8. Prometheus安装部署说明

    本文主要介绍了如何二进制安装Prometheus.使用 Node Exporter 采集主机信息并使用Grafana来进行图形化的展示. 1. 安装Prometheus Server Promethe ...

  9. prometheus学习系列二: Prometheus安装

    下载 在prometheus的官网的download页面,可以找到prometheus的下载二进制包. [root@node00 src]# cd /usr/src/ [root@node00 src ...

随机推荐

  1. 使用linq实现回调函数

    通过输入的Id找到parentId是该Id的列表,然后找到parentId是上面那个Id的列表,以此类推,找到第一目录下所有子目录的的列表. 通过传入第一目录的Id,得到该目录下的所有子目录. 通过回 ...

  2. H5 + WebGL 实现的楼宇自控 3D 可视化监控

    前言 智慧楼宇和人们的生活息息相关,楼宇智能化程度的提高,会极大程度的改善人们的生活品质,在当前工业互联网大背景下受到很大关注.目前智慧楼宇可视化监控的主要优点包括: 智慧化 -- 智慧楼宇是一个生态 ...

  3. 转:NFS原理详解

    原文:http://atong.blog.51cto.com/2393905/1343950 一.NFS介绍 1)什么是NFS 它的主要功能是通过网络让不同的机器系统之间可以彼此共享文件和目录.NFS ...

  4. Go netpoll I/O 多路复用构建原生网络模型之源码深度解析

    导言 Go 基于 I/O multiplexing 和 goroutine 构建了一个简洁而高性能的原生网络模型(基于 Go 的I/O 多路复用 netpoll),提供了 goroutine-per- ...

  5. CSPS模拟 81

    Z哥的题,真是见题如见人啊.. T1 实际状态数没有那么多,不要被数字吓倒就是了. 另外为什么吧轮廓线给忘了啊 T3 觉得自己是正解但是被hack了? 考试的时候想到了复杂度对的的解法,但是 spfa ...

  6. docker安装制定版本-centos7

    # 安装依赖包 yum install -y yum-utils device-mapper-persistent-data lvm2 # 添加Docker软件包源 yum-config-manage ...

  7. Linux修改主机名!(图文)

    本篇作为之前的补充篇,如果想修改自己的主机名,方便老师检查作业是否是自己做的,可以用修改主机名的方法,那么怎么修改呢? 一. 使用hostname命令 比如我现在的主机名是haozhikuan-hbz ...

  8. php ffmpeg截取视频第一帧保存为图片的方法

    php ffmpeg截取视频第一帧保存为图片的方法 <pre> $xiangmupath = $this->getxiangmupath(); $filename = 'chengs ...

  9. kubernetes 控制器详解【持续完善中】

    目录 资源创建详解 一:Pod及常用参数 1.简介 2.模板 3.删除pod 4.设置Pod主机名 5.镜像拉取策略(ImagePullPolicy) 二:RC 1.简介 2.模板 三:Deploym ...

  10. 【Elasticsearch 7 探索之路】(三)倒排索引

    上一篇,我们介绍了 ES 文档的基本 CURE 和批量操作.我们都知道倒排索引是搜索引擎非常重要的一种数据结构,什么是倒排索引,倒排索引的原理是什么. 1 索引过程 在讲解倒排索引前,我们先了解索引创 ...