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

Extend Prometheus Labels to include tags (requires restart for NEW labels on the monitor to be visible) #4704

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

spali
Copy link
Contributor

@spali spali commented Apr 22, 2024

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

adds dynamic prometheus labels
fixes #680
replaces #898

Type of change

Please delete any options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas (including JSDoc for methods)
  • My changes generates no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.

@spali
Copy link
Contributor Author

spali commented Apr 22, 2024

I didn't had time to retest after fixing the merge conflicts...
wrote and tested the code over a year ago...
I would appreciate if someone could test a bit my PR.

Edit(CommanderStorm):
If somebody is curious how to test this, we have this docker image:

docker run --rm -it -p 3000:3000 -p 3001:3001 --pull always -e 'UPTIME_KUMA_GH_REPO=spali:dynamic_prometheus_labels' louislam/uptime-kuma:pr-test2

server/server.js Outdated Show resolved Hide resolved
@CommanderStorm CommanderStorm added area:metrics related to monitoring metrics help wanted May need your help to test or answer labels Apr 22, 2024
@spali spali force-pushed the dynamic_prometheus_labels branch from ec822e6 to 78fddc7 Compare April 30, 2024 08:58
@spali
Copy link
Contributor Author

spali commented Apr 30, 2024

did some basic tests and works for me as expected. After saving, the tags are immediately visible on the /metrics endpoint.

@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Apr 30, 2024

I also just did, but I cannot reproduce this working. I am missing some part.
Could you share your testing mechanism?

Mine is:

  • docker run --rm -it -p 3000:3000 -p 3001:3001 --pull always -e 'UPTIME_KUMA_GH_REPO=spali:dynamic_prometheus_labels' louislam/uptime-kuma:pr-test2
    setup mariadb, log in
  • create a monitor
  • request /metrics => see monitor without tag
  • edit monitor and add a tag
  • request /metrics => see monitor without tag

@CommanderStorm CommanderStorm added the question Further information is requested label Apr 30, 2024
@spali
Copy link
Contributor Author

spali commented Apr 30, 2024

Did the same, but didn't use docker. In the repo and my PR branch npm install and npm run start.
I noticed you used pr-test2... is master based on V2?

@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Apr 30, 2024

Yes, master and all further feature development is v2.0 only.
Given that this PR adds a feature, this is the correct branch imo.
See #4500 for the status of said release and the 1.23.0-release notes:

🐻 It should be the last minor version of Uptime Kuma v1. I will focus on the development of v2. Stay tuned!
Update: The last minor version (1.23.x) means that there won't be any new features introduced in v1. However, bug fixes will still be provided. You can expect to see 1.23.1, 1.23.2 and so on.

@spali
Copy link
Contributor Author

spali commented Apr 30, 2024

Then I can't explain the difference between our both test setup's. 🤔

@spali
Copy link
Contributor Author

spali commented May 15, 2024

Could reproduce it after fresh config and no data.

It's a feature 😉 Needs a server restart for new tag's.
See explanation in #898 (comment) which I also forgot about after this long time 😉
Question is, if solution 3.5 is fine to start with or if we need to put more work into it from start.
As it's a new feature, existing users won't miss anything. And it could be optimized for the user experience later. I think some here wait for it and don't mind a restart after introducing new tags.
Never got an answer from @louislam or any other Collaborator here.

Edit:
I suggest to stay with this solution (3.5) as it is the most less invasive one. And later optimizing is always possible if someone finds the time.

@CommanderStorm
Copy link
Collaborator

3.5 sounds fine by me..

@spali
Copy link
Contributor Author

spali commented May 15, 2024

Tested it again with the premise of restarting to see the monitor tags:

  • create ./data directory with 777 permission
  •  docker run --rm -it -p 3000:3000 -p 3001:3001 --pull always -v ./data:/app/data -e 'UPTIME_KUMA_GH_REPO=spali:dynamic_prometheus_labels' louislam/uptime-kuma:pr-test2
    
  • setup sqlite db
  • login
  • disable auth
  • create monitor with tag test
  • kill container and restart with same docker command as above
  • check /metrics for tag to be visible
  • edit monitor and remove existing tag test and re-add tag test with new value
  • check /metrics for tag with new value to be visible immediately
  • edit monitor and remove tag test
  • check /metrics for tag to be removed immediately

Looks good to me and works as intended.

@spali spali changed the title dynamic prometheus labels dynamic prometheus labels (requires restart for **new** labels on the monitor to be visible) May 15, 2024
@spali
Copy link
Contributor Author

spali commented May 15, 2024

renamed PR in case title finds it's way into the changelogs, so the behaviour is noted there:

  • dynamic prometheus labels (requires restart for new labels on the monitor to be visible)

@spali spali force-pushed the dynamic_prometheus_labels branch from 78fddc7 to 6c21c04 Compare May 17, 2024 19:22
@CommanderStorm CommanderStorm changed the title dynamic prometheus labels (requires restart for **new** labels on the monitor to be visible) Extend Prometheus Labels to include tags (requires restart for NEW labels on the monitor to be visible) May 17, 2024
@CommanderStorm CommanderStorm added the needs:review this PR needs a review by maintainers or other community members label May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metrics related to monitoring metrics help wanted May need your help to test or answer needs:review this PR needs a review by maintainers or other community members question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend existing Prometheus labels to include tags
2 participants