Coder Social home page Coder Social logo

pm2-cluster-prometheus's People

Contributors

dependabot[bot] avatar fz6m avatar jakeh avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

pm2-cluster-prometheus's Issues

Returning JSON Instead of Prometheus Format

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.

Screenshot from 2020-08-26 18-19-50

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 running more than 1 clustered process

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. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.