You've already forked AstralRinth
forked from didirus/AstralRinth
Add /metrics endpoint for Prometheus (#724)
This commit is contained in:
28
Cargo.lock
generated
28
Cargo.lock
generated
@@ -284,6 +284,19 @@ dependencies = [
|
|||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "actix-web-prom"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f23f332a652836b8f3a6876103c70c9ed436d0e69fa779ab5d7f57b1d5c8d488"
|
||||||
|
dependencies = [
|
||||||
|
"actix-web",
|
||||||
|
"futures-core",
|
||||||
|
"pin-project-lite",
|
||||||
|
"prometheus",
|
||||||
|
"regex",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix-ws"
|
name = "actix-ws"
|
||||||
version = "0.2.5"
|
version = "0.2.5"
|
||||||
@@ -2234,6 +2247,7 @@ dependencies = [
|
|||||||
"actix-multipart",
|
"actix-multipart",
|
||||||
"actix-rt",
|
"actix-rt",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
|
"actix-web-prom",
|
||||||
"actix-ws",
|
"actix-ws",
|
||||||
"argon2",
|
"argon2",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -3139,6 +3153,20 @@ dependencies = [
|
|||||||
"rustc_version 0.2.3",
|
"rustc_version 0.2.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "prometheus"
|
||||||
|
version = "0.13.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"fnv",
|
||||||
|
"lazy_static",
|
||||||
|
"memchr",
|
||||||
|
"parking_lot 0.12.1",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ptr_meta"
|
name = "ptr_meta"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
|
|||||||
21
Cargo.toml
21
Cargo.toml
@@ -18,6 +18,7 @@ actix-multipart = "0.6.0"
|
|||||||
actix-cors = "0.6.4"
|
actix-cors = "0.6.4"
|
||||||
actix-ws = "0.2.5"
|
actix-ws = "0.2.5"
|
||||||
actix-files = "0.6.2"
|
actix-files = "0.6.2"
|
||||||
|
actix-web-prom = "0.7.0"
|
||||||
|
|
||||||
tokio = { version = "1.29.1", features = ["sync"] }
|
tokio = { version = "1.29.1", features = ["sync"] }
|
||||||
tokio-stream = "0.1.14"
|
tokio-stream = "0.1.14"
|
||||||
@@ -37,7 +38,7 @@ hyper-tls = "0.5.0"
|
|||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_with = "3.0.0"
|
serde_with = "3.0.0"
|
||||||
chrono = { version = "0.4.26", features = ["serde"]}
|
chrono = { version = "0.4.26", features = ["serde"] }
|
||||||
yaserde = "0.8.0"
|
yaserde = "0.8.0"
|
||||||
yaserde_derive = "0.8.0"
|
yaserde_derive = "0.8.0"
|
||||||
xml-rs = "0.8.15"
|
xml-rs = "0.8.15"
|
||||||
@@ -72,9 +73,21 @@ log = "0.4.19"
|
|||||||
env_logger = "0.10.0"
|
env_logger = "0.10.0"
|
||||||
thiserror = "1.0.41"
|
thiserror = "1.0.41"
|
||||||
|
|
||||||
sqlx = { version = "0.6.3", features = ["offline", "runtime-tokio-rustls", "postgres", "chrono", "macros", "migrate", "decimal", "json"] }
|
sqlx = { version = "0.6.3", features = [
|
||||||
rust_decimal = { version = "1.30.0", features = ["serde-with-float", "serde-with-str"] }
|
"offline",
|
||||||
redis = { version = "0.23.0", features = ["tokio-comp", "ahash", "r2d2"]}
|
"runtime-tokio-rustls",
|
||||||
|
"postgres",
|
||||||
|
"chrono",
|
||||||
|
"macros",
|
||||||
|
"migrate",
|
||||||
|
"decimal",
|
||||||
|
"json",
|
||||||
|
] }
|
||||||
|
rust_decimal = { version = "1.30.0", features = [
|
||||||
|
"serde-with-float",
|
||||||
|
"serde-with-str",
|
||||||
|
] }
|
||||||
|
redis = { version = "0.23.0", features = ["tokio-comp", "ahash", "r2d2"] }
|
||||||
deadpool-redis = "0.12.0"
|
deadpool-redis = "0.12.0"
|
||||||
clickhouse = { version = "0.11.2", features = ["uuid", "time"] }
|
clickhouse = { version = "0.11.2", features = ["uuid", "time"] }
|
||||||
uuid = { version = "1.2.2", features = ["v4", "fast-rng", "serde"] }
|
uuid = { version = "1.2.2", features = ["v4", "fast-rng", "serde"] }
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use actix_web::{App, HttpServer};
|
use actix_web::{App, HttpServer};
|
||||||
|
use actix_web_prom::PrometheusMetricsBuilder;
|
||||||
use env_logger::Env;
|
use env_logger::Env;
|
||||||
use labrinth::database::redis::RedisPool;
|
use labrinth::database::redis::RedisPool;
|
||||||
use labrinth::file_hosting::S3Host;
|
use labrinth::file_hosting::S3Host;
|
||||||
@@ -88,6 +89,11 @@ async fn main() -> std::io::Result<()> {
|
|||||||
|
|
||||||
let store = MemoryStore::new();
|
let store = MemoryStore::new();
|
||||||
|
|
||||||
|
let prometheus = PrometheusMetricsBuilder::new("labrinth")
|
||||||
|
.endpoint("/metrics")
|
||||||
|
.build()
|
||||||
|
.expect("Failed to create prometheus metrics middleware");
|
||||||
|
|
||||||
info!("Starting Actix HTTP server!");
|
info!("Starting Actix HTTP server!");
|
||||||
|
|
||||||
let labrinth_config = labrinth::app_setup(
|
let labrinth_config = labrinth::app_setup(
|
||||||
@@ -101,6 +107,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
// Init App
|
// Init App
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
|
.wrap(prometheus.clone())
|
||||||
.wrap(actix_web::middleware::Compress::default())
|
.wrap(actix_web::middleware::Compress::default())
|
||||||
.wrap(
|
.wrap(
|
||||||
RateLimiter::new(MemoryStoreActor::from(store.clone()).start())
|
RateLimiter::new(MemoryStoreActor::from(store.clone()).start())
|
||||||
|
|||||||
Reference in New Issue
Block a user