fix: Add ingest_fields_total
ingest_lines_total count lines (which apparently are the same as points, quite confusingly) No yaks harmed in the making of this PR. (NOTE: the code around metric, especially dealing with happy and error paths is very painful; to be done in another PR)pull/24376/head
parent
8ab71be5eb
commit
35c2ca17fc
|
@ -256,8 +256,11 @@ pub struct ServerMetrics {
|
|||
/// This metric tracks all requests to the Server
|
||||
pub http_requests: metrics::RedMetric,
|
||||
|
||||
/// The number of LP points ingested
|
||||
pub ingest_points_total: metrics::Counter,
|
||||
/// The number of LP lines ingested
|
||||
pub ingest_lines_total: metrics::Counter,
|
||||
|
||||
/// The number of LP fields ingested
|
||||
pub ingest_fields_total: metrics::Counter,
|
||||
|
||||
/// The number of LP bytes ingested
|
||||
pub ingest_points_bytes_total: metrics::Counter,
|
||||
|
@ -306,11 +309,16 @@ impl ServerMetrics {
|
|||
|
||||
Self {
|
||||
http_requests: http_domain.register_red_metric(None),
|
||||
ingest_points_total: ingest_domain.register_counter_metric(
|
||||
ingest_lines_total: ingest_domain.register_counter_metric(
|
||||
"points",
|
||||
None,
|
||||
"total LP points ingested",
|
||||
),
|
||||
ingest_fields_total: ingest_domain.register_counter_metric(
|
||||
"fields",
|
||||
None,
|
||||
"total LP field values ingested",
|
||||
),
|
||||
ingest_points_bytes_total: ingest_domain.register_counter_metric(
|
||||
"points",
|
||||
Some("bytes"),
|
||||
|
@ -560,13 +568,17 @@ impl<M: ConnectionManager> Server<M> {
|
|||
)
|
||||
.await?;
|
||||
|
||||
self.metrics.ingest_points_total.add_with_labels(
|
||||
lines.len() as u64,
|
||||
&[
|
||||
metrics::KeyValue::new("status", "ok"),
|
||||
metrics::KeyValue::new("db_name", db_name.to_string()),
|
||||
],
|
||||
);
|
||||
let num_fields: usize = lines.iter().map(|line| line.field_set.len()).sum();
|
||||
let labels = &[
|
||||
metrics::KeyValue::new("status", "ok"),
|
||||
metrics::KeyValue::new("db_name", db_name.to_string()),
|
||||
];
|
||||
self.metrics
|
||||
.ingest_lines_total
|
||||
.add_with_labels(lines.len() as u64, labels);
|
||||
self.metrics
|
||||
.ingest_fields_total
|
||||
.add_with_labels(num_fields as u64, labels);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -471,13 +471,19 @@ where
|
|||
];
|
||||
|
||||
server.write_lines(&db_name, &lines).await.map_err(|e| {
|
||||
server.metrics.ingest_points_total.add_with_labels(
|
||||
lines.len() as u64,
|
||||
&[
|
||||
metrics::KeyValue::new("status", "error"),
|
||||
metrics::KeyValue::new("db_name", db_name.to_string()),
|
||||
],
|
||||
);
|
||||
let num_fields: usize = lines.iter().map(|line| line.field_set.len()).sum();
|
||||
let labels = &[
|
||||
metrics::KeyValue::new("status", "error"),
|
||||
metrics::KeyValue::new("db_name", db_name.to_string()),
|
||||
];
|
||||
server
|
||||
.metrics
|
||||
.ingest_lines_total
|
||||
.add_with_labels(lines.len() as u64, labels);
|
||||
server
|
||||
.metrics
|
||||
.ingest_fields_total
|
||||
.add_with_labels(num_fields as u64, labels);
|
||||
server.metrics.ingest_points_bytes_total.add_with_labels(
|
||||
body.len() as u64,
|
||||
&[
|
||||
|
@ -917,6 +923,14 @@ mod tests {
|
|||
.eq(1.0)
|
||||
.unwrap();
|
||||
|
||||
// Which consists of two fields
|
||||
metrics_registry
|
||||
.has_metric_family("ingest_fields_total")
|
||||
.with_labels(&[("db_name", "MetricsOrg_MetricsBucket"), ("status", "ok")])
|
||||
.counter()
|
||||
.eq(2.0)
|
||||
.unwrap();
|
||||
|
||||
// Bytes of data were written
|
||||
metrics_registry
|
||||
.has_metric_family("ingest_points_bytes_total")
|
||||
|
|
Loading…
Reference in New Issue