jakeh / pm2-cluster-prometheus Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I've been trying to implement metrics for a cluster program, and this seems to be the tool to go for. Thanks a lot for the same <3
I'm facing an issue, and I would like to know if you can help me with the same. I've used the following statements in my code along with appropriate imports.
const aggregatorRegistry = new AggregatorRegistry();
// register for prometheus
app.get('/metrics', async (_, res) => {
const metrics = await getAggregateMetrics();
res.set('Content-Type', aggregatorRegistry.contentType);
res.send(metrics);
});
The /metrics
endpoint is queried by Prometheus and since it is returning a JSON (attached at bottom), Prometheus is giving the following error.
I've searched the web for a solution, however, my knowledge with clusters and metrics is very less and I would be really delighted if you can guide me on the right path.
{"_metrics":{"graphql_queries_parsed":{"name":"graphql_queries_parsed","labelNames":["operationName","operation"],"hashMap":{},"help":"The amount of GraphQL queries that have been parsed.","aggregator":"sum"},"graphql_queries_validation_started":{"name":"graphql_queries_validation_started","labelNames":["operationName","operation"],"hashMap":{},"help":"The amount of GraphQL queries that have started validation.","aggregator":"sum"},"graphql_queries_resolved":{"name":"graphql_queries_resolved","labelNames":["operationName","operation"],"hashMap":{},"help":"The amount of GraphQL queries that have had their operation resolved.","aggregator":"sum"},"graphql_queries_execution_started":{"name":"graphql_queries_execution_started","labelNames":["operationName","operation"],"hashMap":{},"help":"The amount of GraphQL queries that have started executing.","aggregator":"sum"},"graphql_queries_errored":{"name":"graphql_queries_errored","labelNames":["operationName","operation"],"hashMap":{},"help":"The amount of GraphQL queries that have encountered errors.","aggregator":"sum"},"graphql_queries_responded":{"name":"graphql_queries_responded","labelNames":["operationName","operation"],"hashMap":{},"help":"The amount of GraphQL queries that have been executed and been attempted to send to the client. This includes requests with errors.","aggregator":"sum"},"graphql_resolver_time":{"name":"graphql_resolver_time","help":"The time to resolve a GraphQL field.","aggregator":"sum","upperBounds":[0.005,0.01,0.025,0.05,0.1,0.25,0.5,1,2.5,5,10],"bucketValues":{"1":0,"5":0,"10":0,"0.005":0,"0.01":0,"0.025":0,"0.05":0,"0.1":0,"0.25":0,"0.5":0,"2.5":0},"sum":0,"count":0,"hashMap":{},"labelNames":["parentType","fieldName","returnType"]},"graphql_total_request_time":{"name":"graphql_total_request_time","help":"The time to complete a GraphQL query.","aggregator":"sum","upperBounds":[0.005,0.01,0.025,0.05,0.1,0.25,0.5,1,2.5,5,10],"bucketValues":{"1":0,"5":0,"10":0,"0.005":0,"0.01":0,"0.025":0,"0.05":0,"0.1":0,"0.25":0,"0.5":0,"2.5":0},"sum":0,"count":0,"hashMap":{},"labelNames":["operationName","operation"]},"http_request_duration_seconds":{"name":"http_request_duration_seconds","help":"duration histogram of http responses labeled with: status_code, method, path","aggregator":"sum","upperBounds":[0.003,0.03,0.1,0.3,1.5,10],"bucketValues":{"10":0,"0.003":0,"0.03":0,"0.1":0,"0.3":0,"1.5":0},"sum":0,"count":0,"hashMap":{},"labelNames":["status_code","method","path"]},"up":{"name":"up","labelNames":[],"hashMap":{"":{"value":1,"labels":{}}},"help":"1 = up, 0 = not up","aggregator":"sum"}},"_collectors":[],"_defaultLabels":{}}
pm2-cluster-prometheus/package.json
Line 29 in ecffcc6
I was looking at resolving an issue in one of our projects (specifically GHSA-vh95-rmgr-6w4m). And this pm2 version relies on an outdated version of mkdirp that relies on minimist 0.0.8.
What's the feasibility of bumping this dependency to the latest pm2?
First off, just wanted to say I have been looking for something like this for a while! Nice work!
It looks like as part of your metric gathering process that you send a message to all PM2 controlled process to report their stats and this works great if you only have 1 clustered process running in PM2. If you have multiple, it sends a request to all and waits for a reply. If the other process is not running your module, it does not respond causing a timeout. If it is running your module, it will inadvertently report stats for a process a different process. I was wondering if you could add a filter to only send a message to process with the same process name "process.env.name". I figure a quick filter under getProcList would do the trick. :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.