Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions nexus/src/external_api/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6386,7 +6386,7 @@ async fn timeseries_schema_list(
async fn timeseries_query(
rqctx: RequestContext<ApiContext>,
body: TypedBody<params::TimeseriesQuery>,
) -> Result<HttpResponseOk<Vec<oxql_types::Table>>, HttpError> {
) -> Result<HttpResponseOk<views::OxqlQueryResult>, HttpError> {
let apictx = rqctx.context();
let handler = async {
let nexus = &apictx.context.nexus;
Expand All @@ -6395,7 +6395,7 @@ async fn timeseries_query(
nexus
.timeseries_query(&opctx, &query)
.await
.map(HttpResponseOk)
.map(|tables| HttpResponseOk(views::OxqlQueryResult { tables }))
.map_err(HttpError::from)
};
apictx
Expand Down
13 changes: 8 additions & 5 deletions nexus/tests/integration_tests/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use nexus_test_utils::resource_helpers::{
};
use nexus_test_utils::ControlPlaneTestContext;
use nexus_test_utils_macros::nexus_test;
use nexus_types::external_api::views::OxqlQueryResult;
use omicron_test_utils::dev::poll::{wait_for_condition, CondCheckError};
use omicron_uuid_kinds::{GenericUuid, InstanceUuid};
use oximeter::types::Datum;
Expand Down Expand Up @@ -307,12 +308,14 @@ pub async fn timeseries_query(
.unwrap_or_else(|e| {
panic!("timeseries query failed: {e:?}\nquery: {query}")
});
rsp.parsed_body().unwrap_or_else(|e| {
panic!(
"could not parse timeseries query response: {e:?}\n\
rsp.parsed_body::<OxqlQueryResult>()
.unwrap_or_else(|e| {
panic!(
"could not parse timeseries query response: {e:?}\n\
query: {query}\nresponse: {rsp:#?}"
);
})
);
})
.tables
}

#[nexus_test]
Expand Down
1 change: 1 addition & 0 deletions nexus/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ humantime.workspace = true
ipnetwork.workspace = true
omicron-uuid-kinds.workspace = true
openssl.workspace = true
oxql-types.workspace = true
oxnet.workspace = true
parse-display.workspace = true
schemars = { workspace = true, features = ["chrono", "uuid1"] }
Expand Down
9 changes: 9 additions & 0 deletions nexus/types/src/external_api/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,3 +971,12 @@ pub struct AllowList {
/// The allowlist of IPs or subnets.
pub allowed_ips: ExternalAllowedSourceIps,
}

// OxQL QUERIES

/// The result of a successful OxQL query.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)]
pub struct OxqlQueryResult {
/// Tables resulting from the query, each containing timeseries.
pub tables: Vec<oxql_types::Table>,
}
22 changes: 17 additions & 5 deletions openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -8026,11 +8026,7 @@
"content": {
"application/json": {
"schema": {
"title": "Array_of_Table",
"type": "array",
"items": {
"$ref": "#/components/schemas/Table"
}
"$ref": "#/components/schemas/OxqlQueryResult"
}
}
}
Expand Down Expand Up @@ -16501,6 +16497,22 @@
}
]
},
"OxqlQueryResult": {
"description": "The result of a successful OxQL query.",
"type": "object",
"properties": {
"tables": {
"description": "Tables resulting from the query, each containing timeseries.",
"type": "array",
"items": {
"$ref": "#/components/schemas/Table"
}
}
},
"required": [
"tables"
]
},
"Password": {
"title": "A password used to authenticate a user",
"description": "Passwords may be subject to additional constraints.",
Expand Down