2692: Slight changes for prometheus metrics r=Kerollmops a=gmourier

# Pull Request

## What does this PR do?

- Replace "MeiliSearch" with "Meilisearch"
- Brings some consistency between rust identifier and exposed metrics names
- Add suffix describing unit, in plural form. e.g `MEILISEARCH_DB_SIZE_BYTES` (https://prometheus.io/docs/practices/naming/#metric-names)
- Update dashboard.json

Co-authored-by: Guillaume Mourier <guillaume@meilisearch.com>
This commit is contained in:
bors[bot] 2022-08-24 10:12:24 +00:00 committed by GitHub
commit f87ebfe477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 16 deletions

View File

@ -112,7 +112,7 @@
}, },
"editorMode": "builder", "editorMode": "builder",
"exemplar": true, "exemplar": true,
"expr": "meilisearch_database_size{job=\"meilisearch\", instance=\"$instance\"}", "expr": "meilisearch_db_size_bytes{job=\"meilisearch\", instance=\"$instance\"}",
"interval": "", "interval": "",
"legendFormat": "", "legendFormat": "",
"range": true, "range": true,
@ -178,7 +178,7 @@
}, },
"editorMode": "builder", "editorMode": "builder",
"exemplar": true, "exemplar": true,
"expr": "meilisearch_total_index{job=\"meilisearch\", instance=\"$instance\"}", "expr": "meilisearch_index_count{job=\"meilisearch\", instance=\"$instance\"}",
"interval": "", "interval": "",
"legendFormat": "", "legendFormat": "",
"range": true, "range": true,
@ -239,7 +239,7 @@
"uid": "1MRsknzVz" "uid": "1MRsknzVz"
}, },
"editorMode": "builder", "editorMode": "builder",
"expr": "meilisearch_docs_count{job=\"meilisearch\", index=\"$Index\", instance=\"$instance\"}", "expr": "meilisearch_index_docs_count{job=\"meilisearch\", index=\"$Index\", instance=\"$instance\"}",
"hide": false, "hide": false,
"range": true, "range": true,
"refId": "A" "refId": "A"
@ -1000,7 +1000,7 @@
] ]
}, },
"timezone": "", "timezone": "",
"title": "MeiliSearch", "title": "Meilisearch",
"uid": "7wcZ94dnz", "uid": "7wcZ94dnz",
"version": 47, "version": 47,
"weekStart": "" "weekStart": ""

View File

@ -16,18 +16,19 @@ lazy_static! {
&["method", "path"] &["method", "path"]
) )
.expect("Can't create a metric"); .expect("Can't create a metric");
pub static ref MEILISEARCH_DB_SIZE: IntGauge = register_int_gauge!(opts!( pub static ref MEILISEARCH_DB_SIZE_BYTES: IntGauge = register_int_gauge!(opts!(
"meilisearch_database_size", "meilisearch_db_size_bytes",
"MeiliSearch Stats DbSize" "Meilisearch Db Size In Bytes"
)) ))
.expect("Can't create a metric"); .expect("Can't create a metric");
pub static ref MEILISEARCH_INDEX_COUNT: IntGauge = register_int_gauge!(opts!( pub static ref MEILISEARCH_INDEX_COUNT: IntGauge =
"meilisearch_total_index", register_int_gauge!(opts!("meilisearch_index_count", "Meilisearch Index Count"))
"MeiliSearch Stats Index Count"
))
.expect("Can't create a metric"); .expect("Can't create a metric");
pub static ref MEILISEARCH_DOCS_COUNT: IntGaugeVec = register_int_gauge_vec!( pub static ref MEILISEARCH_INDEX_DOCS_COUNT: IntGaugeVec = register_int_gauge_vec!(
opts!("meilisearch_docs_count", "MeiliSearch Stats Docs Count"), opts!(
"meilisearch_index_docs_count",
"Meilisearch Index Docs Count"
),
&["index"] &["index"]
) )
.expect("Can't create a metric"); .expect("Can't create a metric");

View File

@ -287,11 +287,11 @@ pub async fn get_metrics(
let search_rules = &meilisearch.filters().search_rules; let search_rules = &meilisearch.filters().search_rules;
let response = meilisearch.get_all_stats(search_rules).await?; let response = meilisearch.get_all_stats(search_rules).await?;
crate::metrics::MEILISEARCH_DB_SIZE.set(response.database_size as i64); crate::metrics::MEILISEARCH_DB_SIZE_BYTES.set(response.database_size as i64);
crate::metrics::MEILISEARCH_INDEX_COUNT.set(response.indexes.len() as i64); crate::metrics::MEILISEARCH_INDEX_COUNT.set(response.indexes.len() as i64);
for (index, value) in response.indexes.iter() { for (index, value) in response.indexes.iter() {
crate::metrics::MEILISEARCH_DOCS_COUNT crate::metrics::MEILISEARCH_INDEX_DOCS_COUNT
.with_label_values(&[index]) .with_label_values(&[index])
.set(value.number_of_documents as i64); .set(value.number_of_documents as i64);
} }