当前位置: 首页 > wzjs >正文

网站页面设计尺寸地推任务网

网站页面设计尺寸,地推任务网,企业营销运营,宝塔wordpress经常502监控指标设置 使用 prometheus-cpp 进行监控指标设置,这里以 mqtt-server 的活跃连接数为例,统计四种协议类型的活跃连接数,在接收到连接进行连接数加一,连接断开时进行连接数减一,使用 gauge 类型 #pragma once#inc…

监控指标设置

使用 prometheus-cpp 进行监控指标设置,这里以 mqtt-server 的活跃连接数为例,统计四种协议类型的活跃连接数,在接收到连接进行连接数加一,连接断开时进行连接数减一,使用 gauge 类型

#pragma once#include <unordered_map>#include "metrics/IMetrics.h"class MqttConnMetrics : public IMetrics {
public:void register_metrics(prometheus::Registry& registry) override {auto& family = prometheus::BuildGauge().Name("mqtt_active_connections").Help("Number of active MQTT connections").Register(registry);protocol_gauges_ = {{MQTT_PROTOCOL::MQTT, &family.Add({{"protocol", "mqtt"}})},{MQTT_PROTOCOL::MQTTS, &family.Add({{"protocol", "mqtts"}})},{MQTT_PROTOCOL::WS, &family.Add({{"protocol", "ws"}})},{MQTT_PROTOCOL::WSS, &family.Add({{"protocol", "wss"}})}};is_registered_ = true;}void increment(MQTT_PROTOCOL protocol) {if (!is_registered_) return;protocol_gauges_[protocol]->Increment();}void decrement(MQTT_PROTOCOL protocol) {if (!is_registered_) return;protocol_gauges_[protocol]->Decrement();}private:bool is_registered_ = false;std::unordered_map<MQTT_PROTOCOL, prometheus::Gauge*> protocol_gauges_;
};

开发完成后,可以通过 http://<address>:<port>/metrics 路径访问到所有的监控指标

prometheus 采集监控指标

安装好 prometheus 之后修改一下 prometheus.yml 配置中 采集的目的地址

# my global config
global:scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.# scrape_timeout is set to the global default (10s).# Alertmanager configuration
alerting:alertmanagers:- static_configs:- targets:# - alertmanager:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:# - "first_rules.yml"# - "second_rules.yml"# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.- job_name: "mqtt-server"scrape_interval: 1s# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ["localhost:8085"]

启动后访问 prometheus 界面,检查是否成功采集到,默认地址 http://localhost:9090

grafana 展示监控数据

安装完 grafana 之后,进入界面添加 prometheus 数据源,然后新增仪表盘,配置监控指标等

http://www.dtcms.com/wzjs/183743.html

相关文章:

  • 网页在线客服系统源码百度搜索关键词排名优化推广
  • 12306的网站是哪个公司做的企业网站建设优化
  • 旅游类网站模板最好最全的搜索引擎
  • 做网站模板广州营销推广
  • 防水网站的外链如何找企业网络营销的模式有哪些
  • 龙华区网站建设网站seo在线优化
  • 建论坛型网站360推广客服电话是多少
  • 贵州省城乡与建设厅网站关键字排名优化工具
  • 中国建筑网官网二测时间微信小程序排名关键词优化
  • 有什么网站可以做logo赚钱网络推广方式有哪几种
  • 网站开发需要什么软件新手怎么做销售
  • 公司网站后台打不开什么是网络营销?
  • 网站开发有前途吗关键词林俊杰mp3在线听
  • 福州网站建设多少钱关键词爱站网关键词挖掘工具
  • 用php做的网站实例网站之家
  • 消防设备网站建设班级优化大师使用心得
  • javamysql做网站网站怎么做的
  • 青海论坛网站建设玉溪seo
  • 建设网站几种方法做网络推广有前途吗
  • 专业网站建设哪家便宜宁波seo教程推广平台
  • 哪里可以免费发广告网站推广优化排名教程
  • 上传wordpress后无法安装seo推广代运营
  • 柳州做网站百度关键词推广一年多少钱
  • 我国网站开发成都网站关键词排名
  • 深圳网络推广建站零基础学什么技术好
  • 如何做 网站的seonba最新排名东西部
  • 恐怖小说网站怎么做互联网平台推广
  • 社交网站开发教程google优化师
  • 新公司建网站网络营销推广公司
  • 泉山微网站开发域名查询ip爱站网