golang实现枚举类型
viper监控文件变化出现两次事件

gin支持prometheus

妙音 posted @ 2022年8月03日 15:25 in golang with tags go prometheus , 833 阅读
 

起因

 
gin使用了微服务架构, 如何将自己的服务都监控起来?
 

疑问列表

 
 
1. grafana是什么, 能做什么?
 
grafana是一个监控平台,支持不同数据源的可视化。也就是说支持从prometheuse,influxdb等数据源, 并将他们的数据形式可视化的图表.
 
2. prometheus能做什么?
prometheuse是一个监控系统,通过定时http pull采集数据. 并且支持http push.
 
3. prometheus和grafana是什么关系?
prometheuse是监控系统, 界面展示比较粗糙, grafana主要是可视化, 并且支持多种类型数据源。
 
4. gin如何与prometheuse结合?
见后面
 
5. gin如何与grafana?
grafana不支持直接接入gin服务。需要gin先接入prometheuse,再将prometheus接入grafana。
 
6. gin服务的metrics数据格式如何解析?
暂时未找到
 
7. gin自定义监控项
略. 不是本文主题
 
 

下载安装

 
grafana
https://github.com/grafana/grafana

prometheus
https://github.com/prometheus/prometheus
 

gin支持prometheuse

 
1. 修改gin服务代码
 
import (
    ...
"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus/promhttp"
    ...
)


//metrics, promhttp默认可以查看cpu,mem,线程等信息
router.GET("/metrics", gin.WrapH(promhttp.Handler()))
 
2.修改prometheuse配置(prometheuse.yml)
 
scrape_configs:
  - job_name: "prometheus-demo"
    static_configs:
      - targets: ["192.168.28.26:8011"]
 
3. 启动服务
 
a. 启动gin和prometheuse服务后, 访问localhost:9090
 
b. 在"Expression"输入框选择"go_goroutines", 点击"Execute"
 
c. 刚开始数据比较少,可以过一段时间后再刷新页面
 
净土大经科注2014-doc
此生必看的科学实验-水知道答案
印光大师十念法(胡小林主讲第1集)
 
Avatar_small
SEO 说:
2023年7月19日 17:25

I'm glad I found this web site, I couldn't find any knowledge on this matter prior to. Also operate a site and if you are ever interested in doing some visitor writing for me if possible feel free to let me know, im always look for people to check out my web site. 천안출장마사지

Avatar_small
six components of he 说:
2023年8月09日 16:33

The author's passion for the subject shines through. It's infectious and inspiring.

Avatar_small
Johny 说:
2023年8月31日 12:55

Very interesting blog. Alot of blogs I see these days don't really provide anything that I'm interested in, but I'm most definitely interested in this one. Just thought that I would post and let you know. familie vakantie naar regio stockholm

Avatar_small
Johny 说:
2023年9月09日 10:49

Admiring the time and effort you put into your blog and detailed information you offer!.. daftar pentaslot

Avatar_small
otaquani 说:
2023年9月27日 19:10

If you are an internet user on daily basis then must checkout this site. It has been an amazing experience. Believe me it’s totally worth of your time. Suggested to everyone! Gta 5 mod menu download

Avatar_small
Harper Bennett 说:
2023年10月26日 06:10

Impeccable <a href="https://www.intelliscapenj.com/category/commercialsnowremoval">snow and ice management Freehold NJ</a>! The team here excels in providing swift and efficient solutions, ensuring our property is always safe and clear during winter. Highly satisfied with their top-notch snow and ice management expertise!

Avatar_small
asadullah 说:
2023年11月10日 17:20

"Your passion for cooking truly shines through your recipes. Thanks for sharing your love of food!"

Avatar_small
Teri Meri Doriyaann 说:
2023年11月29日 16:43

Desi Serial Teri Meri Doriyaann Full Episode in HD, Watch Hindi Drama Teri Meri Doriyaann Full Episode Latest Video By Star Plus &amp; Hotstar. Bollyfuntv, Desi serials, Desitvbox, Apnetv.

Avatar_small
jnanabhumiap.in 说:
2024年1月10日 13:30

JNANABHUMI AP provides all latest educational updates and many more. The main concept or our aim behind this website has been the will to provide resources full information on each topic which can be accessed through Internet. To ensure that every readers get’s what important and worthy about the topic they search and link to hear from us. jnanabhumiap.in Jnanabhumi AP is a startup by passionate webmasters and bloggers who have passion to provide engaging content which is accurate, interesting and worthy to read. We are mope like a web community where you can find different information’s, resources, topics on day to day incidents or news. We provide you the finest of web content on each and every topics possible with help of editorial and content team.

Avatar_small
meidir 说:
2024年1月28日 02:12

You have a gift for words I will give you that. If only I had the same gift 엉클슬롯먹튀


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter