Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to serve Prometheus metrics #671 #693

Merged
merged 3 commits into from
Oct 24, 2023

Conversation

fflorent
Copy link
Collaborator

Context

At the ANCT, we faced a Ouf Of Memory crash of Grist. The problem was somehow solved but we'd like to monitor Grist a bit more, beyond logs.

That's the reason of this PR: proposing a Prometheus exporter.

Technical aspects

  • We introduce a new environment variable GRIST_PROMCLIENT_PORT
  • When set, it activates the Prometheus exporter server which listens at the specified port
  • Use --require option to load the prometheus-exporter.ts module

Resolves #671

sandbox/run.sh Outdated
NODE_PATH=_build:_build/stubs:_build/ext node _build/stubs/app/server/server.js
if [[ -n "$GRIST_PROMCLIENT_PORT" ]]; then
require_promclient="--require ./_build/stubs/app/server/prometheus-exporter.js"
fi
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the prom-client dependency is embedded no matter what, do you think we keep that --require option as is or may we just import prometheus-exporter.ts as a regular TS module in stubs/app/server/server.ts and conditionally run server.listen or not there?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's keep it simple, include the dependency unconditionally, and use a regular TS module. Thanks @fflorent

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright! That's done here: a7a14e3

sandbox/run.sh Outdated
NODE_PATH=_build:_build/stubs:_build/ext node _build/stubs/app/server/server.js
if [[ -n "$GRIST_PROMCLIENT_PORT" ]]; then
require_promclient="--require ./_build/stubs/app/server/prometheus-exporter.js"
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's keep it simple, include the dependency unconditionally, and use a regular TS module. Thanks @fflorent

sandbox/watch.sh Outdated
require_promclient="--require ./_build/stubs/app/server/prometheus-exporter.js"
fi

ls _build/stubs/app/server
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this ls debugging code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, sorry, I remove that!

@fflorent fflorent force-pushed the issue-671-prom-client branch from a7a14e3 to b30b154 Compare October 24, 2023 10:52
@fflorent fflorent force-pushed the issue-671-prom-client branch from b30b154 to f46ce54 Compare October 24, 2023 10:55
Copy link
Member

@paulfitz paulfitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fflorent !

@paulfitz paulfitz merged commit 38c8476 into gristlabs:main Oct 24, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Monitoring Grist using Prometheus or OpenTelemetry?
2 participants