简介

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. 最强中文NLP预训练模型艾尼ERNIE官方揭秘【附视频】

    “最近刚好在用ERNIE写毕业论文” “感觉还挺厉害的” “为什么叫ERNIE啊,这名字有什么深意吗?” “我想让艾尼帮我写作业” 看了上面火热的讨论,你一定很好奇“艾尼”.“ERNIE”到底是个啥? ...

  2. Openmp多线程编程练习

    环境配置 一般使用Visual Studio2019来作为openmp的编程环境 调试-->属性-->C/C++-->所有选项-->Openmp支持改为 是(可以使用下拉菜单) ...

  3. ArcSDE 10 for SQL Server安装教程(含下载链接)

    亲测:ArcSDE 10.1适用于ArcGIS10.2的版本. 该版本支持SQL Server.Oracle.PostgreSQL等数据库连接 下载链接(含安装包和授权文件): 链接:https:// ...

  4. IDEA 使用lombok

    一.配置maven <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback ...

  5. NOIP模拟 2

    大概就是考试的时候慌的一批,因为一道正解也没想出来,T1,T3只会暴搜,听见天皇在旁边的窃喜声本渣内心是崩溃的 会打暴搜的我先打了暴搜,大多数时间都用在第二题上,妄想自己能拿50多分- 最后半小时万念 ...

  6. linux破解密码

    1.关机2.按e进入grub 3.在linux16行末尾输入 rd.break console=tty1   4.按ctrl+“X”执行.  5.输入 mount -o remount,rw /sys ...

  7. 访问控制列表ACL

    1.ACL Access list ,访问控制列表. 2.作用 限制网络中的地址访问. 3.主要内容 Eg: Router(config)#access-list ? <一>. <1 ...

  8. JS、JQ相关小技巧积攒

    JS.JQ相关小技巧积攒,以备不时之需. 1.js 获取时间差:时间戳相减.new Date().getTime()  获得毫秒数,除以(1000*60*60*24) 获得天数. 2.重定向操作:页面 ...

  9. 南开大学校徽及手写字的Tikz源码

    话不多说,直接上内容. % ---------------------------------- % !TeX enginee = pdfLaTeX/XeLaTeX % !TeX encoding = ...

  10. gitbook的插件配置

    原生的gitbook样式比较单一,美观度和功能欠佳,可通过相关插件进行拓展. 插件地址:https://plugins.gitbook.com/ 主目录下新建book.json: { "au ...