当前位置:网站首页>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
边栏推荐
- Bitbucket installation configuration
- The real situation of programmers
- Index optimization of performance tuning methodology
- 装饰器学习01
- The Blue Bridge Cup web application development simulation competition is open for the first time! Contestants fast forward!
- Win11缺少dll文件怎么办?Win11系统找不到dll文件修复方法
- Efficiency difference between row first and column first traversal of mat data types in opencv
- Reptile practice
- AD637使用笔记
- 从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
猜你喜欢
[Yugong series] go teaching course in July 2022 004 go code Notes
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
How to use tensorflow2 for cat and dog classification and recognition
"Chris Richardson microservices series" uses API gateway to build microservices
QML reported an error expected token ";", expected a qualified name ID
Livelocks and deadlocks of concurrency control
Business learning of mall order module
元宇宙中的三大“派系”
装饰器学习01
Analysis and test of ModbusRTU communication protocol
随机推荐
他们主动布局(autolayout)环境的图像编辑器
微服務鏈路風險分析
Official clarification statement of Jihu company
Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture
Summary of concurrency control
MySQL disconnection reports an error MySQL ldb_ exceptions. OperationalError 4031, The client was disconnected by the server
Did you brush the real title of the blue bridge cup over the years? Come here and teach you to counter attack!
多家呼吸机巨头产品近期被一级召回 呼吸机市场仍在增量竞争
Defect detection - Halcon surface scratch detection
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
1.3 years of work experience, double non naked resignation agency face-to-face experience [already employed]
Evolution of large website architecture and knowledge system
Create a virtual machine on VMware (system not installed)
HYSBZ 2243 染色 (树链拆分)
Blocking protocol for concurrency control
crm创建基于fetch自己的自定义报告
极狐公司官方澄清声明
让开发效率提升的跨端方案
MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
Deeply convinced plan X - network protocol basic DNS