xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

promjs & frontend monitor All In One

promjs & frontend monitor All In One

promjs

https://github.com/siimon/prom-client

https://www.npmjs.com/package/promjs

import prom from 'promjs';
 
const registry = prom();
const counter = registry.create('counter', 'my_counter', 'A counter for things');


const counter = registry.create('counter', 'my_counter', 'A counter for things');
//
counter.inc();
console.log(registry.metrics());
// =>
// # HELP my_counter A counter for things \n
// # TYPE my_counter counter
// my_counter 1 \n

demos


const autoReport = (timer = 10000) => {
    window.setInterval(() => {
        const stringData = registry.metrics();
        console.log('重复 bug ???', registry);
        console.log('stringData ???', stringData);
        axios.post(url, stringData).then(() => {
            // 0
            registry.reset();
        });
    }, timer);
};

const manualReport = () => {
    // registry.reset();
    axios.post(url, registry.metrics()).then(() => {
        registry.reset();
    });
};


import prom from 'promjs';
import axios from 'axios';

const registry = prom();
// 打点 API, 新的 1, 旧的 0 ???
const pageRequestsCounter = registry.create('counter', 'page_requests_total');

const pageRetentionTimer = registry.create('histogram', 'page_retention_seconds');

const apiRequestsCounter = registry.create('counter', 'api_requests_total');

const apiRequestsTimer = registry.create('histogram', 'api_requests_duration_seconds');


const url = 'http://metrics.xgqfrms.xyz/metrics/job/app';

const autoReport = (timer = 10000) => {
    window.setInterval(() => {
        console.log('重复 bug ???', registry);
        axios.post(url, registry.metrics()).then(() => {
            // 0
            registry.reset();
        });
    }, timer);
};

const manualReport = () => {
    registry.reset();
    // axios.post(url, registry.metrics()).then(() => {
    //     registry.reset();
    // });
};

refs

Writing client libraries | Prometheus

https://prometheus.io/docs/instrumenting/writing_clientlibs/



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @   xgqfrms  阅读(87)  评论(16编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2020-04-07 taro render html
2020-04-07 TDD & Unit testing
2020-04-07 Taro 版本
2020-04-07 小程序 webview 自动打开新页面
2020-04-07 Taro Next
2020-04-07 taro 渲染 html
2019-04-07 Algorithm Visualizer
点击右上角即可分享
微信分享提示