-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from d-Rickyy-b/prometheus
Implement prometheus support
- Loading branch information
Showing
10 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
### Added | ||
### Changed | ||
### Fixed | ||
### Docs | ||
|
||
## [1.1.0] - 2022-03-28 | ||
|
||
### Added | ||
- Support for prometheus database | ||
|
||
## [1.0.0] - 2022-02-14 | ||
Initial release! First stable version of GoGeizhalsBot is published as v1.0.0 | ||
|
||
[unreleased]: https://github.com/d-Rickyy-b/GoGeizhalsBot/compare/v1.1.0...HEAD | ||
[1.1.0]: https://github.com/d-Rickyy-b/GoGeizhalsBot/compare/v1.0.0...v1.1.0 | ||
[1.0.0]: https://github.com/d-Rickyy-b/GoGeizhalsBot/tree/v1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package bot | ||
|
||
var version = "1.0.0-dev (compiled manually)" | ||
var version = "1.1.0-dev (compiled manually)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package prometheus | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/VictoriaMetrics/metrics" | ||
) | ||
|
||
var ( | ||
TotalUniqueUsersValue int64 | ||
totalUniqueUsers = metrics.NewGauge("gogeizhalsbot_unique_users_total", func() float64 { | ||
return float64(TotalUniqueUsersValue) | ||
}) | ||
|
||
TotalUniquePriceagentsValue int64 | ||
totalUniquePriceagents = metrics.NewGauge("gogeizhalsbot_unique_priceagents", func() float64 { | ||
return float64(TotalUniquePriceagentsValue) | ||
}) | ||
|
||
TotalUniqueProductPriceagentsValue int64 | ||
totalUniqueProductPriceagents = metrics.NewGauge("gogeizhalsbot_unique_priceagents{type=\"product\"}", func() float64 { | ||
return float64(TotalUniqueProductPriceagentsValue) | ||
}) | ||
|
||
TotalUniqueWishlistPriceagentsValue int64 | ||
totalUniqueWishlistPriceagents = metrics.NewGauge("gogeizhalsbot_unique_priceagents{type=\"wishlist\"}", func() float64 { | ||
return float64(TotalUniqueWishlistPriceagentsValue) | ||
}) | ||
|
||
TotalUserInteractions = metrics.NewCounter("gogeizhalsbot_user_interactions_total") | ||
GeizhalsHTTPRequests = metrics.NewCounter("gogeizhalsbot_geizhals_http_requests_total") | ||
PriceagentNotifications = metrics.NewCounter("gogeizhalsbot_priceagent_notifications_total") | ||
HttpErrors = metrics.NewCounter("gogeizhalsbot_http_errors_total") | ||
GraphsRendered = metrics.NewCounter("gogeizhalsbot_graphs_rendered_total") | ||
) | ||
|
||
// var backgroundUpdateChecks = metrics.NewSummary("gogeizhalsbot_total_requests") | ||
|
||
func StartPrometheusExporter(addr string) { | ||
// Expose the registered metrics at `/metrics` path. | ||
http.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) { | ||
metrics.WritePrometheus(w, true) | ||
}) | ||
http.ListenAndServe(addr, nil) | ||
} |