-
-
Notifications
You must be signed in to change notification settings - Fork 462
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 support for custom labels in Prometheus metrics #979
base: master
Are you sure you want to change the base?
Conversation
Hey @appleboy, thanks again for your contributions to Gatus! What use does the global In other words, if the environment label is defined in the endpoint, well, its only use is for metrics, so if the user defined it in the endpoint config, it's because they explicitly want it and therefore it should be published with the metrics, which would then make the global/top-level Let me know if the comment above doesn't make sense, I'm running on very little sleep today 😅 |
Thank you for your response. I was also thinking about the issue you mentioned yesterday. I will further modify it so that if the endpoint is configured, it will be automatically added to the metrics. |
- Add `toBoolPtr` function to convert a bool to a bool pointer - Add `contains` function to check if a key exists in a slice - Add `GetMetricLabels` method to `Config` struct to return unique metric labels from enabled endpoints - Change file permission notation from `0644` to `0o644` in `config_test.go` - Add `Labels` field to `Endpoint` struct for key-value pairs - Initialize Prometheus metrics with dynamic labels from configuration - Modify `PublishMetricsForEndpoint` to include dynamic labels - Add test for `GetMetricLabels` method in `config_test.go` - Update `watchdog` to pass labels to monitoring and execution functions Signed-off-by: appleboy <[email protected]>
@TwiN Updated. Please review it again. I also add config file unit testing. |
- Rename `toBoolPtr` function to a generic `toPtr` function - Update tests to use the new `toPtr` function instead of `toBoolPtr` Signed-off-by: appleboy <[email protected]>
- Move `toPtr` and `contains` utility functions to a new file `util.go` Signed-off-by: appleboy <[email protected]>
@TwiN Any feedbacks? |
- Reorder parameters in `PublishMetricsForEndpoint` function - Update test cases to match the new parameter order in `PublishMetricsForEndpoint` - Reorder parameters in `monitor` function - Adjust `monitor` function calls to match the new parameter order - Reorder parameters in `execute` function call to `PublishMetricsForEndpoint` Signed-off-by: Bo-Yi Wu <[email protected]>
toPtr
function to convert a bool to a bool pointercontains
function to check if a key exists in a sliceGetMetricLabels
method toConfig
struct to return unique metric labels from enabled endpoints0644
to0o644
inconfig_test.go
Labels
field toEndpoint
struct for key-value pairsPublishMetricsForEndpoint
to include dynamic labelsGetMetricLabels
method inconfig_test.go
watchdog
to pass labels to monitoring and execution functionsSummary
The changes for
config.yaml
This pull request introduces several enhancements to the Gatus project, including the addition of a Labels field to the Config and Endpoint structs to support key-value pairs for metrics. It also updates the Prometheus metrics initialization to include dynamic labels from the configuration, modifies the PublishMetricsForEndpoint function to handle and include these labels, and adds corresponding tests and updates to the codebase to ensure the functionality works as intended.
New metrics preview
Checklist
README.md
, if applicable.