Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 8, 2025

  • Install prom-client library
  • Create metrics module to initialize and export Prometheus metrics
  • Set up default Node.js metrics (CPU, RAM, event loop, etc.)
  • Create HTTP middleware to track request duration and count by route, method, and status code
  • Create separate Express app for metrics endpoint
  • Add METRICS_PORT environment variable to configuration
  • Start metrics server on separate port in HawkAPI class
  • Test the implementation by checking /metrics endpoint
  • Add integration tests for metrics endpoint
  • Add documentation for Prometheus metrics integration
  • Remove package-lock.json (use yarn instead)
  • Fix yarn.lock to preserve git dependency commit hash
  • Update Dockerfile.dev and CI workflows to use Node 16
Original prompt

This section details on the original issue you should resolve

<issue_title>chore(devops): set up basic prometheus metrics</issue_title>
<issue_description>We need to integrate prometheus metrics to the application.

  • Must serve prometheus-compatible /metrics endpoint on a different port (not the one API uses to serve user requests)
  • Must include default nodejs metrics (for CPU, RAM, etc)
  • Must include http-level metrics: count and duration of requests by route, http code and http method
  • Use prom-client library</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #539

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Set up basic Prometheus metrics integration chore(devops): set up basic prometheus metrics Oct 8, 2025
Copilot AI requested a review from neSpecc October 8, 2025 20:53
Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fastdl.mongodb.org
    • Triggering command: node ./postinstall.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from neSpecc October 8, 2025 21:11
@neSpecc
Copy link
Member

neSpecc commented Oct 8, 2025

@copilot there is an error during yarn build:

3.908 error An unexpected error occurred: "Commit hash required".

Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot there is an error during yarn build:

3.908 error An unexpected error occurred: "Commit hash required".

Fixed. The issue was that yarn.lock had lost the commit hash for the git dependency (codex-accounting-sdk). Restored the original yarn.lock and properly added prom-client using yarn add to preserve the git commit hash. Now yarn install and yarn build work correctly.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fastdl.mongodb.org
    • Triggering command: /usr/local/bin/node ./postinstall.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@neSpecc
Copy link
Member

neSpecc commented Oct 8, 2025

@copilot some of ci failed: https://github.com/codex-team/hawk.api.nodejs/actions/runs/18358440930/job/52296525978?pr=541

The failing job is caused by using Node.js version 14.17.0, which is incompatible with the [email protected] package. prom-client requires Node.js "^16 || ^18 || >=20".

Consider using node 16 in Dockerfile.dev

And check other CI as well

Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot some of ci failed: https://github.com/codex-team/hawk.api.nodejs/actions/runs/18358440930/job/52296525978?pr=541

The failing job is caused by using Node.js version 14.17.0, which is inco...

Updated to Node 16 for prom-client compatibility:

  • Dockerfile.dev: Node 14.17.0 → Node 16 (also updated python → python3)
  • tests.yml: Added Node.js setup using .nvmrc
  • integration-tests.yml: Added Node.js setup using .nvmrc

All CI workflows now use Node 16.16.0 (from .nvmrc), which satisfies prom-client's requirement of "^16 || ^18 || >=20".

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fastdl.mongodb.org
    • Triggering command: /usr/local/bin/node ./postinstall.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@neSpecc neSpecc marked this pull request as ready for review October 8, 2025 21:59
@neSpecc neSpecc merged commit d4b8f82 into master Oct 8, 2025
9 checks passed
@neSpecc neSpecc deleted the copilot/set-up-prometheus-metrics branch October 8, 2025 22:00
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.

chore(devops): set up basic prometheus metrics

2 participants