当前位置:网站首页>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 
边栏推荐
- How to use tensorflow2 for cat and dog classification and recognition
- Deeply convinced plan X - network protocol basic DNS
- Countdown to 92 days, the strategy for the provincial preparation of the Blue Bridge Cup is coming~
- SecureCRT使用提示
- Code bug correction, char is converted to int high-order symbol extension, resulting in changes in positivity and negativity and values. Int num = (int) (unsigned int) a, which will occur in older com
- Bitbucket installation configuration
- AD637 usage notes
- Oracle checkpoint queue - Analysis of the principle of instance crash recovery
- Create a virtual machine on VMware (system not installed)
- PyGame practical project: write Snake games with 300 lines of code
猜你喜欢

Countdown to 92 days, the strategy for the provincial preparation of the Blue Bridge Cup is coming~

Recovery technology with checkpoints

Official clarification statement of Jihu company

Business learning of mall order module

Index optimization of performance tuning methodology

Overview of concurrency control

元宇宙中的三大“派系”

PIP install beatifulsoup4 installation failed

Decorator learning 01

PyGame practical project: write Snake games with 300 lines of code
随机推荐
Sentinel production environment practice (I)
Common interview questions of JVM manufacturers
微服务链路风险分析
Official clarification statement of Jihu company
Hysbz 2243 staining (tree chain splitting)
Oracle views the data size of a table
How to develop and introduce applet plug-ins
资深电感厂家告诉你电感什么情况会有噪音电感噪音是比较常见的一种电感故障情况,如果使用的电感出现了噪音大家也不用着急,只需要准确查找分析出什么何原因,其实还是有具体的方法来解决的。作为一家拥有18年品牌
Image editor for their AutoLayout environment
854. String BFS with similarity K
Huawei game multimedia service calls the method of shielding the voice of the specified player, and the error code 3010 is returned
Huawei fast game failed to call the login interface, and returned error code -1
Index optimization of performance tuning methodology
Cross end solutions to improve development efficiency
Database recovery strategy
元宇宙中的三大“派系”
Overview of database recovery
初级软件测试必问面试题
Form artifact
Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer