mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-29 16:24:26 +01:00
aae099e330
3851: Expose lastUpdate and isIndexing in /stats endpoint r=dureuill a=gentcys # Pull Request ## Related issue Fixes #3843 ## What does this PR do? - expose lastUpdate in `/stats` endpoint - expose isIndex in `stats` endpoint - add a method `is_task_processing` in index-scheduler/src/lib.rs. ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: Cong Chen <cong.chen@ocrlabs.com> Co-authored-by: ManyTheFish <many@meilisearch.com> Co-authored-by: Louis Dureuil <louis@meilisearch.com>
60 lines
2.6 KiB
Rust
60 lines
2.6 KiB
Rust
use lazy_static::lazy_static;
|
|
use prometheus::{
|
|
opts, register_histogram_vec, register_int_counter_vec, register_int_gauge,
|
|
register_int_gauge_vec, HistogramVec, IntCounterVec, IntGauge, IntGaugeVec,
|
|
};
|
|
|
|
/// Create evenly distributed buckets
|
|
fn create_buckets() -> [f64; 29] {
|
|
(0..10)
|
|
.chain((10..100).step_by(10))
|
|
.chain((100..=1000).step_by(100))
|
|
.map(|i| i as f64 / 1000.)
|
|
.collect::<Vec<_>>()
|
|
.try_into()
|
|
.unwrap()
|
|
}
|
|
|
|
lazy_static! {
|
|
pub static ref MEILISEARCH_HTTP_RESPONSE_TIME_CUSTOM_BUCKETS: [f64; 29] = create_buckets();
|
|
pub static ref MEILISEARCH_HTTP_REQUESTS_TOTAL: IntCounterVec = register_int_counter_vec!(
|
|
opts!("meilisearch_http_requests_total", "Meilisearch HTTP requests total"),
|
|
&["method", "path"]
|
|
)
|
|
.expect("Can't create a metric");
|
|
pub static ref MEILISEARCH_DB_SIZE_BYTES: IntGauge =
|
|
register_int_gauge!(opts!("meilisearch_db_size_bytes", "Meilisearch DB Size In Bytes"))
|
|
.expect("Can't create a metric");
|
|
pub static ref MEILISEARCH_USED_DB_SIZE_BYTES: IntGauge = register_int_gauge!(opts!(
|
|
"meilisearch_used_db_size_bytes",
|
|
"Meilisearch Used DB Size In Bytes"
|
|
))
|
|
.expect("Can't create a metric");
|
|
pub static ref MEILISEARCH_INDEX_COUNT: IntGauge =
|
|
register_int_gauge!(opts!("meilisearch_index_count", "Meilisearch Index Count"))
|
|
.expect("Can't create a metric");
|
|
pub static ref MEILISEARCH_INDEX_DOCS_COUNT: IntGaugeVec = register_int_gauge_vec!(
|
|
opts!("meilisearch_index_docs_count", "Meilisearch Index Docs Count"),
|
|
&["index"]
|
|
)
|
|
.expect("Can't create a metric");
|
|
pub static ref MEILISEARCH_HTTP_RESPONSE_TIME_SECONDS: HistogramVec = register_histogram_vec!(
|
|
"meilisearch_http_response_time_seconds",
|
|
"Meilisearch HTTP response times",
|
|
&["method", "path"],
|
|
MEILISEARCH_HTTP_RESPONSE_TIME_CUSTOM_BUCKETS.to_vec()
|
|
)
|
|
.expect("Can't create a metric");
|
|
pub static ref MEILISEARCH_NB_TASKS: IntGaugeVec = register_int_gauge_vec!(
|
|
opts!("meilisearch_nb_tasks", "Meilisearch Number of tasks"),
|
|
&["kind", "value"]
|
|
)
|
|
.expect("Can't create a metric");
|
|
pub static ref MEILISEARCH_LAST_UPDATE: IntGauge =
|
|
register_int_gauge!(opts!("meilisearch_last_update", "Meilisearch Last Update"))
|
|
.expect("Can't create a metric");
|
|
pub static ref MEILISEARCH_IS_INDEXING: IntGauge =
|
|
register_int_gauge!(opts!("meilisearch_is_indexing", "Meilisearch Is Indexing"))
|
|
.expect("Can't create a metric");
|
|
}
|