Skip to content

[nexus] Move existing OxQL endpoints under /v1/system/* #7047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 13, 2024
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
4 changes: 2 additions & 2 deletions nexus/external-api/output/nexus_tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ login_saml POST /login/{silo_name}/saml/{provi
API operations found with tag "metrics"
OPERATION ID METHOD URL PATH
silo_metric GET /v1/metrics/{metric_name}
timeseries_query POST /v1/timeseries/query
timeseries_schema_list GET /v1/timeseries/schema

API operations found with tag "policy"
OPERATION ID METHOD URL PATH
Expand Down Expand Up @@ -170,6 +168,8 @@ ip_pool_view GET /v1/system/ip-pools/{pool}
API operations found with tag "system/metrics"
OPERATION ID METHOD URL PATH
system_metric GET /v1/system/metrics/{metric_name}
system_timeseries_query POST /v1/system/timeseries/query
system_timeseries_schema_list GET /v1/system/timeseries/schemas

API operations found with tag "system/networking"
OPERATION ID METHOD URL PATH
Expand Down
12 changes: 6 additions & 6 deletions nexus/external-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2541,10 +2541,10 @@ pub trait NexusExternalApi {
/// List timeseries schemas
#[endpoint {
method = GET,
path = "/v1/timeseries/schema",
tags = ["metrics"],
path = "/v1/system/timeseries/schemas",
tags = ["system/metrics"],
}]
async fn timeseries_schema_list(
async fn system_timeseries_schema_list(
rqctx: RequestContext<Self::Context>,
pag_params: Query<TimeseriesSchemaPaginationParams>,
) -> Result<
Expand All @@ -2559,10 +2559,10 @@ pub trait NexusExternalApi {
/// Queries are written in OxQL.
#[endpoint {
method = POST,
path = "/v1/timeseries/query",
tags = ["metrics"],
path = "/v1/system/timeseries/query",
tags = ["system/metrics"],
}]
async fn timeseries_query(
async fn system_timeseries_query(
rqctx: RequestContext<Self::Context>,
body: TypedBody<params::TimeseriesQuery>,
) -> Result<HttpResponseOk<views::OxqlQueryResult>, HttpError>;
Expand Down
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 @@ -5494,7 +5494,7 @@ impl NexusExternalApi for NexusExternalApiImpl {
.await
}

async fn timeseries_schema_list(
async fn system_timeseries_schema_list(
rqctx: RequestContext<ApiContext>,
pag_params: Query<TimeseriesSchemaPaginationParams>,
) -> Result<
Expand All @@ -5521,7 +5521,7 @@ impl NexusExternalApi for NexusExternalApiImpl {
.await
}

async fn timeseries_query(
async fn system_timeseries_query(
rqctx: RequestContext<ApiContext>,
body: TypedBody<params::TimeseriesQuery>,
) -> Result<HttpResponseOk<views::OxqlQueryResult>, HttpError> {
Expand Down
4 changes: 2 additions & 2 deletions nexus/tests/integration_tests/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,10 +947,10 @@ pub static DEMO_SILO_METRICS_URL: Lazy<String> = Lazy::new(|| {
});

pub static TIMESERIES_LIST_URL: Lazy<String> =
Lazy::new(|| String::from("/v1/timeseries/schema"));
Lazy::new(|| String::from("/v1/system/timeseries/schemas"));

pub static TIMESERIES_QUERY_URL: Lazy<String> =
Lazy::new(|| String::from("/v1/timeseries/query"));
Lazy::new(|| String::from("/v1/system/timeseries/query"));

pub static DEMO_TIMESERIES_QUERY: Lazy<params::TimeseriesQuery> =
Lazy::new(|| params::TimeseriesQuery {
Expand Down
4 changes: 2 additions & 2 deletions nexus/tests/integration_tests/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ async fn test_timeseries_schema_list(
// producing data. Force a collection to ensure that happens.
cptestctx.oximeter.force_collect().await;
let client = &cptestctx.external_client;
let url = "/v1/timeseries/schema";
let url = "/v1/system/timeseries/schemas";
let schema =
objects_list_page_authz::<TimeseriesSchema>(client, &url).await;
schema
Expand Down Expand Up @@ -300,7 +300,7 @@ pub async fn timeseries_query(
nexus_test_utils::http_testing::RequestBuilder::new(
&cptestctx.external_client,
http::Method::POST,
"/v1/timeseries/query",
"/v1/system/timeseries/query",
)
.body(Some(&body)),
)
Expand Down
180 changes: 90 additions & 90 deletions openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -8490,6 +8490,96 @@
}
}
},
"/v1/system/timeseries/query": {
"post": {
"tags": [
"system/metrics"
],
"summary": "Run timeseries query",
"description": "Queries are written in OxQL.",
Comment on lines +8498 to +8499
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the summary or description to reflect that this is for fleet-scoped timeseries? Not sure if it's relevant or important yet, given that's the only scope we have today.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, currently it is technically for all timeseries in the system. I'm honestly not sure whether we want to change that in the future. Generally we try not to make it too easy for operators to peek inside silos, with a few exceptions like being able to list instances on a given sled.

"operationId": "system_timeseries_query",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TimeseriesQuery"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OxqlQueryResult"
}
}
}
},
"4XX": {
"$ref": "#/components/responses/Error"
},
"5XX": {
"$ref": "#/components/responses/Error"
}
}
}
},
"/v1/system/timeseries/schemas": {
"get": {
"tags": [
"system/metrics"
],
"summary": "List timeseries schemas",
"operationId": "system_timeseries_schema_list",
"parameters": [
{
"in": "query",
"name": "limit",
"description": "Maximum number of items returned by a single call",
"schema": {
"nullable": true,
"type": "integer",
"format": "uint32",
"minimum": 1
}
},
{
"in": "query",
"name": "page_token",
"description": "Token returned by previous call to retrieve the subsequent page",
"schema": {
"nullable": true,
"type": "string"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TimeseriesSchemaResultsPage"
}
}
}
},
"4XX": {
"$ref": "#/components/responses/Error"
},
"5XX": {
"$ref": "#/components/responses/Error"
}
},
"x-dropshot-pagination": {
"required": []
}
}
},
"/v1/system/users": {
"get": {
"tags": [
Expand Down Expand Up @@ -8800,96 +8890,6 @@
}
}
},
"/v1/timeseries/query": {
"post": {
"tags": [
"metrics"
],
"summary": "Run timeseries query",
"description": "Queries are written in OxQL.",
"operationId": "timeseries_query",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TimeseriesQuery"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OxqlQueryResult"
}
}
}
},
"4XX": {
"$ref": "#/components/responses/Error"
},
"5XX": {
"$ref": "#/components/responses/Error"
}
}
}
},
"/v1/timeseries/schema": {
"get": {
"tags": [
"metrics"
],
"summary": "List timeseries schemas",
"operationId": "timeseries_schema_list",
"parameters": [
{
"in": "query",
"name": "limit",
"description": "Maximum number of items returned by a single call",
"schema": {
"nullable": true,
"type": "integer",
"format": "uint32",
"minimum": 1
}
},
{
"in": "query",
"name": "page_token",
"description": "Token returned by previous call to retrieve the subsequent page",
"schema": {
"nullable": true,
"type": "string"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TimeseriesSchemaResultsPage"
}
}
}
},
"4XX": {
"$ref": "#/components/responses/Error"
},
"5XX": {
"$ref": "#/components/responses/Error"
}
},
"x-dropshot-pagination": {
"required": []
}
}
},
"/v1/users": {
"get": {
"tags": [
Expand Down
Loading