mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 14:54:27 +01:00
feat(prometheus): add build_info metric
Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
This commit is contained in:
parent
9a756cf2c5
commit
7bfcd76628
@ -5,6 +5,13 @@ use prometheus::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
pub static ref MEILISEARCH_BUILD_INFO: IntGaugeVec = register_int_gauge_vec!(
|
||||||
|
opts!(
|
||||||
|
"meilisearch_build_info",
|
||||||
|
"A metric with a constant '1' value labelled by version from which meilisearch was built"),
|
||||||
|
& ["revision", "version"]
|
||||||
|
)
|
||||||
|
.expect("Can't create a metric");
|
||||||
pub static ref MEILISEARCH_HTTP_REQUESTS_TOTAL: IntCounterVec = register_int_counter_vec!(
|
pub static ref MEILISEARCH_HTTP_REQUESTS_TOTAL: IntCounterVec = register_int_counter_vec!(
|
||||||
opts!("meilisearch_http_requests_total", "Meilisearch HTTP requests total"),
|
opts!("meilisearch_http_requests_total", "Meilisearch HTTP requests total"),
|
||||||
&["method", "path", "status"]
|
&["method", "path", "status"]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use actix_web::http::header;
|
use actix_web::http::header;
|
||||||
use actix_web::web::{self, Data};
|
use actix_web::web::{self, Data};
|
||||||
use actix_web::HttpResponse;
|
use actix_web::HttpResponse;
|
||||||
|
use build_info;
|
||||||
use index_scheduler::IndexScheduler;
|
use index_scheduler::IndexScheduler;
|
||||||
use meilisearch_auth::AuthController;
|
use meilisearch_auth::AuthController;
|
||||||
use meilisearch_types::error::ResponseError;
|
use meilisearch_types::error::ResponseError;
|
||||||
@ -54,6 +55,11 @@ pub async fn get_metrics(
|
|||||||
}
|
}
|
||||||
crate::metrics::MEILISEARCH_IS_INDEXING.set(index_scheduler.is_task_processing()? as i64);
|
crate::metrics::MEILISEARCH_IS_INDEXING.set(index_scheduler.is_task_processing()? as i64);
|
||||||
|
|
||||||
|
let build_info = build_info::BuildInfo::from_build();
|
||||||
|
let commit_sha = build_info.commit_sha1.unwrap_or("unknown").to_string();
|
||||||
|
let pkg_version = env!("CARGO_PKG_VERSION").to_string();
|
||||||
|
crate::metrics::MEILISEARCH_BUILD_INFO.with_label_values(&[&commit_sha, &pkg_version]).set(1);
|
||||||
|
|
||||||
let encoder = TextEncoder::new();
|
let encoder = TextEncoder::new();
|
||||||
let mut buffer = vec![];
|
let mut buffer = vec![];
|
||||||
encoder.encode(&prometheus::gather(), &mut buffer).expect("Failed to encode metrics");
|
encoder.encode(&prometheus::gather(), &mut buffer).expect("Failed to encode metrics");
|
||||||
|
Loading…
Reference in New Issue
Block a user