fix: return metric name instead of query in Prometheus /series API (#3864)

* fix: return metric name instead of query in Prometheus /series API

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* omit non-tag columns from result

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* fix clippy

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2024-05-07 17:07:16 +08:00
committed by GitHub
parent 1b5862223c
commit 71c1c7ca24
3 changed files with 125 additions and 16 deletions

View File

@@ -492,7 +492,7 @@ pub async fn test_prom_http_api(store_type: StorageType) {
// series
let res = client
.get("/v1/prometheus/api/v1/series?match[]=demo&start=0&end=0")
.get("/v1/prometheus/api/v1/series?match[]=demo{}&start=0&end=0")
.send()
.await;
assert_eq!(res.status(), StatusCode::OK);
@@ -508,10 +508,7 @@ pub async fn test_prom_http_api(store_type: StorageType) {
.collect::<BTreeMap<String, String>>();
let expected = BTreeMap::from([
("__name__".to_string(), "demo".to_string()),
("ts".to_string(), "1970-01-01 00:00:00+0000".to_string()),
("cpu".to_string(), "1.1".to_string()),
("host".to_string(), "host1".to_string()),
("memory".to_string(), "2.2".to_string()),
]);
assert_eq!(actual, expected);