当前位置:网站首页>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/amd64then 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"} 660Start 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 
边栏推荐
- 总结出现2xx、3xx、4xx、5xx状态码的原因
- Poj 3237 Tree (Tree Chain Split)
- EBS Oracle 11g cloning steps (single node)
- Drawing HSV color wheel with MATLAB
- HDU 4391 paint the wall segment tree (water
- Regular expressions and re Libraries
- Cross end solutions to improve development efficiency
- How to organize an actual attack and defense drill
- 华为联机对战如何提升玩家匹配成功几率
- ICMP introduction
猜你喜欢

A number of ventilator giants' products have been recalled recently, and the ventilator market is still in incremental competition

K210学习笔记(四) K210同时运行多个模型

The simple problem of leetcode is to split a string into several groups of length K

database mirroring

Sentinel production environment practice (I)
![[Yugong series] go teaching course in July 2022 004 go code Notes](/img/56/d596e7c7bec9abd888e8f18f9769f8.png)
[Yugong series] go teaching course in July 2022 004 go code Notes

AD637使用笔记

装饰器学习01

Analysis and test of ModbusRTU communication protocol

Create a virtual machine on VMware (system not installed)
随机推荐
Shell script, awk condition judgment and logic comparison &||
Oracle checkpoint queue - Analysis of the principle of instance crash recovery
NET中小型企业项目开发框架系列(一个)
Dbeaver executes multiple insert into error processing at the same time
Concurrency control of performance tuning methodology
A trip to Suzhou during the Dragon Boat Festival holiday
Pointer parameter passing vs reference parameter passing vs value parameter passing
MMAP learning
U盘的文件无法删除文件怎么办?Win11无法删除U盘文件解决教程
Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer
Reptile practice
Implementation technology of recovery
等到产业互联网时代真正发展成熟,我们将会看待一系列的新产业巨头的出现
Robot operation mechanism
Shell script, awk uses if, for process control
Did you brush the real title of the blue bridge cup over the years? Come here and teach you to counter attack!
Huawei fast game failed to call the login interface, and returned error code -1
Database recovery strategy
Decorator learning 01
Livelocks and deadlocks of concurrency control