当前位置:网站首页>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
边栏推荐
- A long's perception
- 微服務鏈路風險分析
- Installation of VMware Workstation
- Interprocess communication in the "Chris Richardson microservice series" microservice architecture
- 数据泄露怎么办?'华生·K'7招消灭安全威胁
- C language knowledge points link
- Shell script, awk condition judgment and logic comparison &||
- Reptile practice
- How to organize an actual attack and defense drill
- Granularity of blocking of concurrency control
猜你喜欢
2022-07-05:给定一个数组,想随时查询任何范围上的最大值。 如果只是根据初始数组建立、并且以后没有修改, 那么RMQ方法比线段树方法好实现,时间复杂度O(N*logN),额外空间复杂度O(N*
科技云报道:算力网络,还需跨越几道坎?
boundary IoU 的计算方式
华为游戏多媒体服务调用屏蔽指定玩家语音方法,返回错误码3010
Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer
Pl/sql basic syntax
Overview of concurrency control
Storage optimization of performance tuning methodology
Getting started with microservices (resttemplate, Eureka, Nacos, feign, gateway)
K210 learning notes (IV) k210 runs multiple models at the same time
随机推荐
Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer
poj 3237 Tree(樹鏈拆分)
SecureCRT使用提示
Bitbucket installation configuration
Create a virtual machine on VMware (system not installed)
Pointer parameter passing vs reference parameter passing vs value parameter passing
How to use tensorflow2 for cat and dog classification and recognition
Performance monitoring of database tuning solutions
如何開發引入小程序插件
Win11缺少dll文件怎么办?Win11系统找不到dll文件修复方法
Huawei game multimedia service calls the method of shielding the voice of the specified player, and the error code 3010 is returned
Blocking of concurrency control
华为快游戏调用登录接口失败,返回错误码 -1
Oracle advanced query
Implementation technology of recovery
How to view Apache log4j 2 remote code execution vulnerability?
Overview of database recovery
Interprocess communication in the "Chris Richardson microservice series" microservice architecture
极狐公司官方澄清声明
EL与JSTL注意事项汇总