当前位置:网站首页>Promql demo service
Promql demo service
2022-07-05 22:04:00 【Zhang quandan, Foxconn quality inspector】
Demo service
In order to show you in as much detail as possible PromQL Index query , Here we will Fork An open source Prometheus Demo service to query , This allows us to control the indicator data more flexibly , Project warehouse address :https://github.com/cnych/prometheus_demo_service, This is a Go Language development services , We can build our own applications .
First of all to prepare golang Environmental Science :
* wget https://golang.org/dl/go1.16.3.linux-amd64.tar.gz
* rm -rf /usr/local/go && tar -C /usr/local -xzf go1.16.3.linux-amd64.tar.gz
# Configure environment variables , You can add the following command to /etc/profile in
* export PATH=$PATH:/usr/local/go/bin
# perform go Command to verify
* go version
go version go1.16.3 linux/amd64
then clone The code to build : Start preparing to build the project
# First clone Code ( It is recommended to use ssh Pattern , You'll see ~)
* git clone https://github.com/cnych/prometheus_demo_service
* cd prometheus_demo_service
# To configure GOPROXY agent
* export GOPROXY=https://goproxy.cn
# structure
* env GOOS=linux GOARCH=amd64 go build -o prometheus_demo_service // Compile
[[email protected] prometheus_demo_service]# ls
api.go client.go crossbuild.sh Dockerfile go.sum intermittent_metric.go memory.go
batch.go cpu.go disk.go go.mod holiday.go main.go prometheus_demo_service
This is a binary program compiled and packaged , It can be started directly
The listening port is 8080
[[email protected] prometheus_demo_service]# ./prometheus_demo_service
[[email protected] ~]# netstat -tpln | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 20916/./prometheus_
# HELP demo_api_http_requests_in_progress The current number of API HTTP requests in progress.
# TYPE demo_api_http_requests_in_progress gauge
demo_api_http_requests_in_progress 1
# HELP demo_api_request_duration_seconds A histogram of the API HTTP request durations in seconds.
# TYPE demo_api_request_duration_seconds histogram
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.0001"} 0
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.00015000000000000001"} 0
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.00022500000000000002"} 0
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.0003375"} 0
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.00050625"} 0
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.000759375"} 0
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.0011390624999999999"} 0
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.0017085937499999998"} 0
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.0025628906249999996"} 0
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.0038443359374999994"} 0
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.00576650390625"} 0
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.008649755859375"} 0
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.0129746337890625"} 22
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.01946195068359375"} 600
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.029192926025390625"} 612
demo_api_request_duration_seconds_bucket{method="GET",path="/api/bar",status="200",le="0.043789389038085935"} 660
Start after the build 3 A service , Monitor separately 10000、10001、10002 port :
[[email protected] ~]# netstat -tpln | grep 1000
tcp6 0 0 :::10000 :::* LISTEN 26720/./prometheus_
tcp6 0 0 :::10001 :::* LISTEN 27270/./prometheus_
tcp6 0 0 :::10002 :::* LISTEN 27326/./prometheus_
[[email protected] prometheus_demo_service]# nohup ./prometheus_demo_service --listen-address=:10000 &
[1] 26720
[[email protected] prometheus_demo_service]# nohup: ignoring input and appending output to ?.ohup.out?
[[email protected] prometheus_demo_service]# nohup ./prometheus_demo_service --listen-address=:10001 &
[2] 27270
[[email protected] prometheus_demo_service]# nohup: ignoring input and appending output to ?.ohup.out?
[[email protected] prometheus_demo_service]#
[[email protected] prometheus_demo_service]# nohup ./prometheus_demo_service --listen-address=:10002 &
[3] 27326
above 3 All services are /metrics
The endpoint exposes some indicator data , We can put this 3 Services are configured to Prometheus Crawling task , In this way, these services can be used later PromQL Query description .
complete prometheus.yml
The configuration file is shown below :
global:
scrape_interval: 5s # Grab frequency
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
# To configure demo Grab task
- job_name: demo
scrape_interval: 15s // Will be covered global Global configuration for
scrape_timeout: 10s
static_configs:
- targets:
- demo-service-0:10000
- demo-service-1:10001
- demo-service-2:10002
边栏推荐
- Tips for using SecureCRT
- Business learning of mall commodity module
- Yolov5 training custom data set (pycharm ultra detailed version)
- Evolution of large website architecture and knowledge system
- Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer
- Daily question brushing record (XIV)
- 从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
- Leetcode simple question ring and rod
- MMAP学习
- 华为联机对战如何提升玩家匹配成功几率
猜你喜欢
Shell script, awk condition judgment and logic comparison &||
【愚公系列】2022年7月 Go教学课程 004-Go代码注释
科技云报道荣膺全球云计算大会“云鼎奖”2013-2022十周年特别贡献奖
Learning of mall permission module
多家呼吸机巨头产品近期被一级召回 呼吸机市场仍在增量竞争
Serializability of concurrent scheduling
A number of ventilator giants' products have been recalled recently, and the ventilator market is still in incremental competition
华为联机对战如何提升玩家匹配成功几率
MMAP学习
Sentinel production environment practice (I)
随机推荐
等到产业互联网时代真正发展成熟,我们将会看待一系列的新产业巨头的出现
Create a virtual machine on VMware (system not installed)
华为联机对战如何提升玩家匹配成功几率
资深电感厂家告诉你电感什么情况会有噪音电感噪音是比较常见的一种电感故障情况,如果使用的电感出现了噪音大家也不用着急,只需要准确查找分析出什么何原因,其实还是有具体的方法来解决的。作为一家拥有18年品牌
Cross end solutions to improve development efficiency
Database tuning solution
Installation of VMware Workstation
华为快游戏调用登录接口失败,返回错误码 -1
NET中小型企业项目开发框架系列(一个)
2022-07-05:给定一个数组,想随时查询任何范围上的最大值。 如果只是根据初始数组建立、并且以后没有修改, 那么RMQ方法比线段树方法好实现,时间复杂度O(N*logN),额外空间复杂度O(N*
Performance monitoring of database tuning solutions
Tips for using SecureCRT
装饰器学习01
华为游戏多媒体调用切换房间方法出现异常Internal system error. Reason:90000017
Basic grammar of interview (Part 1)
Implementation technology of recovery
matlab绘制hsv色轮图
Common interview questions of redis factory
Bitbucket installation configuration
Web3为互联网带来了哪些改变?