Skip to content
Draft
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
5 changes: 5 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions clickhouse-admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ clickhouse-admin-test-utils.workspace = true
dropshot.workspace = true
expectorate.workspace = true
omicron-test-utils.workspace = true
oximeter.workspace = true
oximeter-test-utils.workspace = true
openapi-lint.workspace = true
openapiv3.workspace = true
Expand Down
83 changes: 83 additions & 0 deletions clickhouse-admin/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ api_versions!([
// | example for the next person.
// v
// (next_int, IDENT), // NOTE: read the note at the start of this macro!
(2, ADD_RETENTION_POLICY_AND_TABLE_USAGE),
(1, INITIAL),
]);

Expand Down Expand Up @@ -200,6 +201,47 @@ pub trait ClickhouseAdminServerApi {
async fn init_db(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseUpdatedNoContent, HttpError>;

/// Set the retention policy for timeseries data.
#[endpoint {
method = PUT,
path = "/retention-policy",
versions = VERSION_ADD_RETENTION_POLICY_AND_TABLE_USAGE..,
}]
async fn set_retention_policy(
rqctx: RequestContext<Self::Context>,
policy: TypedBody<latest::retention::RetentionPolicy>,
) -> Result<HttpResponseUpdatedNoContent, HttpError>;

/// Get the retention policy for timeseries data from the database
#[endpoint {
method = GET,
path = "/retention-policy",
versions = VERSION_ADD_RETENTION_POLICY_AND_TABLE_USAGE..,
}]
async fn retention_policy(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<latest::retention::RetentionPolicy>, HttpError>;

/// Return the resource usage of database tables.
#[endpoint {
method = GET,
path = "/usage/database",
versions = VERSION_ADD_RETENTION_POLICY_AND_TABLE_USAGE..,
}]
async fn database_usage(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<latest::usage::DatabaseUsageResult>, HttpError>;

/// Return the resource usage of oximeter timeseries.
#[endpoint {
method = PUT,
path = "/usage/oximeter-timeseries",
versions = VERSION_ADD_RETENTION_POLICY_AND_TABLE_USAGE..,
}]
async fn oximeter_usage(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<latest::usage::OximeterUsageResult>, HttpError>;
}

/// API interface for our clickhouse-admin-single server
Expand Down Expand Up @@ -235,4 +277,45 @@ pub trait ClickhouseAdminSingleApi {
path_params: Path<latest::server::MetricInfoPath>,
query_params: Query<latest::server::TimeSeriesSettingsQuery>,
) -> Result<HttpResponseOk<Vec<latest::server::SystemTimeSeries>>, HttpError>;

/// Set the retention policy for timeseries data.
#[endpoint {
method = PUT,
path = "/retention-policy",
versions = VERSION_ADD_RETENTION_POLICY_AND_TABLE_USAGE..,
}]
async fn set_retention_policy(
rqctx: RequestContext<Self::Context>,
policy: TypedBody<latest::retention::RetentionPolicy>,
) -> Result<HttpResponseUpdatedNoContent, HttpError>;

/// Get the retention policy for timeseries data from the database
#[endpoint {
method = GET,
path = "/retention-policy",
versions = VERSION_ADD_RETENTION_POLICY_AND_TABLE_USAGE..,
}]
async fn retention_policy(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<latest::retention::RetentionPolicy>, HttpError>;

/// Return the resource usage of database tables.
#[endpoint {
method = GET,
path = "/usage/database",
versions = VERSION_ADD_RETENTION_POLICY_AND_TABLE_USAGE..,
}]
async fn database_usage(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<latest::usage::DatabaseUsageResult>, HttpError>;

/// Return the resource usage of oximeter timeseries.
#[endpoint {
method = PUT,
path = "/usage/oximeter-timeseries",
versions = VERSION_ADD_RETENTION_POLICY_AND_TABLE_USAGE..,
}]
async fn oximeter_usage(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<latest::usage::OximeterUsageResult>, HttpError>;
}
Loading
Loading