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

Feat: Add a Metric to Track the Total of Probes Running #1222

Merged

Conversation

haricnugraha
Copy link
Contributor

Monika Pull Request (PR)

What feature/issue does this PR add

  • Add a metric to track total probe running.
  • Implement an abort controller to prevent unnecessary requests and free up resources.

How did you implement / how did you fix it

Added

  • Added monika_probe_running_total metric to track the running total of Monika probes.
  • Added events for probe start and finish to monitor probe activity.
  • Added Prometheus configuration and instructions for local monitoring with Docker compose.

Changed

  • Updated @types/node to version 18 for better type support.
  • Implemented an abort controller for probe processing to prevent unnecessary requests and free up resources.
  • Refactored code to use an abstract class and method to ensure implementation in child classes.

How to test

  1. Use the following configuration.
probes:
  - id: "1"
    requests:
      - url: http://example.com
  - id: "2"
    requests:
      - url: https://example.com
  - id: "3"
    requests:
      - url: https://example.com
  - id: "4"
    requests:
      - url: https://example.com
  - id: "5"
    requests:
      - url: https://example.com
  - id: "6"
    requests:
      - url: https://example.com
  - id: "7"
    requests:
      - url: https://example.com
  - id: "8"
    requests:
      - url: https://example.com
  - id: "9"
    requests:
      - url: https://example.com
  - id: "10"
    requests:
      - url: https://example.com
  1. Run Prometheus. Run docker compose -f ./dev/prometheus/docker-compose.yaml up.
  2. Run Monika with the Prometheus flag. Run npm start -- --prometheus 3001.
  3. Open Prometheus Expression Browser. Visit http://localhost:9090/graph.
  4. Input sum(monika_probe_running_total) and click the Execute button.
  5. Click the Graph tab.
  6. Change the configuration to test the abort controller.

Demo

Graph

image

Abort Controller

Before

before.mp4

After

after.mp4

@haricnugraha haricnugraha changed the title Refactor/abort irrelevant probe Feat: Add a Metric to Track the Running Total of Monika Probes Dec 27, 2023
Copy link

codecov bot commented Dec 27, 2023

Codecov Report

Attention: 15 lines in your changes are missing coverage. Please review.

Comparison is base (e6a6be2) 63.86% compared to head (763bc5c) 63.71%.

Files Patch % Lines
src/plugins/metrics/prometheus/collector.ts 20.00% 7 Missing and 1 partial ⚠️
src/components/probe/index.ts 57.14% 1 Missing and 2 partials ⚠️
src/utils/ip.ts 33.33% 1 Missing and 1 partial ⚠️
src/components/probe/prober/factory.ts 0.00% 1 Missing ⚠️
src/looper/index.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1222      +/-   ##
==========================================
- Coverage   63.86%   63.71%   -0.16%     
==========================================
  Files         111      111              
  Lines        3277     3296      +19     
  Branches      561      566       +5     
==========================================
+ Hits         2093     2100       +7     
- Misses        998     1006       +8     
- Partials      186      190       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@haricnugraha haricnugraha marked this pull request as ready for review December 27, 2023 10:49
@haricnugraha haricnugraha changed the title Feat: Add a Metric to Track the Running Total of Monika Probes Feature: Add a Metric to Track the Total of Probes Running Dec 28, 2023
@haricnugraha haricnugraha changed the title Feature: Add a Metric to Track the Total of Probes Running Feat: Add a Metric to Track the Total of Probes Running Dec 28, 2023
Copy link
Contributor

@sapiderman sapiderman left a comment

Choose a reason for hiding this comment

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

good pr 👍🏽

worked for me
image

Copy link
Contributor

@dennypradipta dennypradipta left a comment

Choose a reason for hiding this comment

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

Nicely done.
image

@haricnugraha haricnugraha merged commit af4a1fd into hyperjumptech:main Jan 8, 2024
6 checks passed
@haricnugraha haricnugraha deleted the refactor/abort-irrelevant-probe branch January 8, 2024 08:02
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.

3 participants