首页 > 其他分享 >62、Prometheus-远端存储-Influxdb部署

62、Prometheus-远端存储-Influxdb部署

时间:2023-04-12 12:13:25浏览次数:35  
标签:http 62 prometheus Influxdb server Prometheus requests data localhost

1、基础知识

1.1、官方文档

https://docs.influxdata.com/influxdb/v1.8/supported_protocols/prometh

1.2、需求

需把要prometheus数据存到其他远程服务器上

2、Influxdb部署

2.1、配置yum源

cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL \$releasever
baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 0
EOF

2.2、安装Influxdb

yum install influxdb -y

2.3、启动Influxdb服务

2.3.1、启动

systemctl start influxdb
systemctl enable influxdb

2.3.2、查询运行状态

]# netstat  -tunlp | grep influxd
tcp        0      0 127.0.0.1:8088          0.0.0.0:*               LISTEN      29082/influxd       
tcp6       0      0 :::8086                 :::*                    LISTEN      29082/influxd 

 

2.4、创建 prometheus 数据库

]# influx
Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> create database prometheus;
> show databases;
name: databases
name
----
_internal
prometheus

2.5、修改prometheus启动脚本

2.5.1、创建存放的数据的目录

mkdir -p /usr/local/prometheus/data

2.5.2、修改prometheus.service

]# cat /usr/lib/systemd/system/prometheus.service
[Unit]
Description=prometheus server project
After=network.target
[Service]
Type=simple
ExecStart=/data/server/prometheus/bin/prometheus \
--config.file=/data/server/prometheus/etc/prometheus.yml \
--storage.tsdb.path=/usr/local/prometheus/data # 修改这里的数据目录
Restart=on-failure
[Install]
WantedBy=multi-user.target

# 修改服务脚本,需要重新加载一下
systemctl daemon-reload

2.6、配置 prometheus.yaml【添加远程读写】

2.6.1、配置

]# vi /data/server/prometheus/etc/prometheus.yml
scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]

remote_write:
  - url: "http://192.168.10.34:8086/api/v1/prom/write?db=prometheus"
remote_read:
  - url: "http://192.168.10.34:8086/api/v1/prom/read?db=prometheus"

2.6.2、检查语法

]# promtool check config /data/server/prometheus/etc/prometheus.yml 
Checking /data/server/prometheus/etc/prometheus.yml
  SUCCESS: 1 rule files found
 SUCCESS: /data/server/prometheus/etc/prometheus.yml is valid prometheus config file syntax

Checking /data/server/prometheus/rules/metrics_request_rules.yaml
  SUCCESS: 2 rules found

2.6.3、重启prometheus服务

systemctl restart prometheus

2.7、登陆Influxdb查询

2.7.1、登陆数据库

]# influx
Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> use prometheus
Using database prometheus

2.7.2、查询监控项

> show measurements
...
promhttp_metric_handler_requests_total
scrape_duration_seconds
scrape_samples_post_metric_relabeling
scrape_samples_scraped
scrape_series_added
up

2.7.3、查询监控的数据

> select * from prometheus_http_requests_total limit 5;
name: prometheus_http_requests_total
time                __name__                       code handler  instance       job        value
----                --------                       ---- -------  --------       ---        -----
1681271646440000000 prometheus_http_requests_total 200  /metrics localhost:9090 prometheus 1
1681271661440000000 prometheus_http_requests_total 200  /metrics localhost:9090 prometheus 2
1681271676440000000 prometheus_http_requests_total 200  /metrics localhost:9090 prometheus 3
1681271691440000000 prometheus_http_requests_total 200  /metrics localhost:9090 prometheus 4
1681271706440000000 prometheus_http_requests_total 200  /metrics localhost:9090 prometheus 5

2.8、数据库已经变更成功

]# ll /usr/local/prometheus/data/
总用量 20
drwxr-xr-x 2 root root     6 4月  12 11:53 chunks_head
-rw-r--r-- 1 root root     0 4月  12 11:53 lock
-rw-r--r-- 1 root root 20001 4月  12 11:57 queries.active
drwxr-xr-x 2 root root    22 4月  12 11:53 wal

 

标签:http,62,prometheus,Influxdb,server,Prometheus,requests,data,localhost
From: https://www.cnblogs.com/ygbh/p/17309296.html

相关文章

  • Codeforces Round 862 (Div. 2)
    CodeforcesRound862(Div.2)Date:04/07/2023Link:Dashboard-CodeforcesRound862(Div.2)-CodeforcesA|WeNeedtheZeroBrief:给定非负整数序列,求一个\(x\),使得序列每个元素异或\(x\)后再全部异或起来的结果为\(0\).没有输出\(-1\).Data:\(T\leq1e3,......
  • 60、Prometheus-alertmanager、邮件告警配置
    1、规则解析1.1、规则简介Prometheus支持两种类型的规则:记录规则和警报规则,它们可以进行配置,然后定期进行评估。要将规则包含在Prometheus中,需要先创建一个包含必要规则语句的文件,并让Prometheus通过Prometheus配置中的rule_fies字段加载该文件。默认情况下,prometheus的规则......
  • 从 1 秒到 10 毫秒!在 APISIX 中减少 Prometheus 请求阻塞
    本文介绍了Prometheus插件造成长尾请求现象的原因,以及如何解决这个问题。作者屠正松,ApacheAPISIXPMCMember。原文链接现象在APISIX社区中,曾有部分用户陆续反馈一种神秘现象:部分请求延迟较长。具体表现为:当流量请求进入一个正常部署的APISIX集群时,偶尔会出现部分请......
  • 58、K8S-监控机制-Prometheus-自定义metrics
    Kubernetes学习目录1、安装python环境1.1、下载python软件wgethttps://www.python.org/ftp/python/3.9.16/Python-3.9.16.tgz1.2、安装依赖包yuminstallgccgcc-c++glibc-develglibczlib-develzlibopenssl-developensslsqlite-develreadline-develbzip2-devel......
  • Perfect P-th Powers UVA - 10622
     给出n,写成n=x^p的形式,求p最大值#include<iostream>#include<vector>#include<cmath>#include<algorithm>usingnamespacestd;#defineintlonglongintflg=0;intgcd(intx,inty){ returny==0?x:gcd(y,x%y);}voidsov(in......
  • 57、K8S-监控机制-Prometheus-PromQL基础-运算符、聚合、功能函数
    Kubernetes学习目录1、数据基础1.1、时间序列1.1.1、介绍时间序列数据:按照时间顺序记录系统、设备状态变化的数据,每个数据称为一个样本;数据采集以特定的时间周期进行,因而,随着时间流逝,将这些样本数据记录下来,将生成一个离散的样本数据序列;该序列也称为向量(Vector);而将多个序......
  • P6216 回文匹配
    回文匹配/*这里sum表示一维前缀和sum(r-m+1)-sum(l-1)sum(r-m+1-i)-sum(l-1+i)所以应该是使用二位前缀和来进行处理len/2也就是我半径需要的最小长度有些难模拟,但是就是二维前缀和最后统计答案的地方是真的绕*/#include<bits/stdc++.h>usingnamespacestd;con......
  • 56、K8S-监控机制-Prometheus-配置解析、标签管理
    Kubernetes学习目录1、配置文件1.1、配置简介1.1.1、简介Prometheus可以通过命令行或者配置文件的方式对服务进行配置。一般情况下,命令行方式一般用于不可变的系统参数配置,例如存储位置、要保留在磁盘和内存中的数据量等;配置文件用于定义与数据动态获取相关的配置选项和文件......
  • 54、K8S-监控机制-Prometheus-node_exporter部署
    Kubernetes学习目录1、node_exporter部署1.1、安装主机说明这里分别安装到node1和node2节点上。1.2、软件安装1.2.1、解压软件mkdir/data/{softs,server}-ptarxvfnode_exporter-1.5.0.linux-amd64.tar.gz-C/data/server/1.2.2、程序位置重新调整ln-s/data/s......
  • 1626. 无矛盾的最佳球队
    题目链接:1626.无矛盾的最佳球队方法一:子集型回溯+记忆化解题思路先对\(scores\)和\(ages\)数组进行预处理得到\(pair<int,int>a[n]\)数组,\(a[i].first=score[i],a[i].second=ages[i]\),然后进行\(sort\)排序;枚举计算\([i,n-1]\)区间的最大分数\(score_i\)\(=df......