-
Notifications
You must be signed in to change notification settings - Fork 833
API Design Proposal #2327
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
pracucci
merged 8 commits into
cortexproject:master
from
grafana:20200324_api_design_proposal
Apr 8, 2020
Merged
API Design Proposal #2327
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ee5c16b
initial draft of api design proposal
jtlisi 9b3c286
clarify backwards-compatibility
jtlisi 1bb940b
clarify root path routes
jtlisi 1b4a23f
update route section formatting
jtlisi be6c1bd
update design document
jtlisi df7c23f
refactor per PR comments
jtlisi beb38df
update endpoints and add style note about underscores
jtlisi 2d4b6f4
Fixed proposal header
pracucci File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
title: "HTTP API Design" | ||
linkTitle: "HTTP API Design" | ||
weight: 1 | ||
slug: http-api-design | ||
--- | ||
|
||
- Author: @jtlisi | ||
- Reviewers: @pracucci, @pstibrany, @khaines, @gouthamve | ||
- Date: March 2020 | ||
- Status: Accepted | ||
|
||
## Overview | ||
|
||
The purpose of this design document is to propose a set of standards that should be the basis of the Cortex HTTP API. This document will outline the current state of the Cortex http api and describe limitations that result from the current approach. It will also outline a set of paradigms on how http routes should be created within Cortex. | ||
|
||
## Current Design | ||
|
||
As things currently stand, the majority of HTTP API calls exist under the `/api/prom` path prefix. This prefix is configurable. However, since this prefix is shared between all the modules which leads to conflicts if the Alertmanager is attempted to be run as as part of the single binary (#1722). | ||
|
||
## Proposed Design | ||
pracucci marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
### Module-Based Routing | ||
|
||
Cortex incorporates three separate APIs: Alertmanager, Prometheus, and Cortex. Each of these APIs should use a separate route prefix that accurately describes the API. Currently, all of the api calls in Cortex reside under the configured http prefix. Instead the following routing tree is proposed: | ||
|
||
#### `/prometheus/*` | ||
|
||
Under this path prefix, Cortex will act as a Prometheus web server. It will host all of the required Prometheus api endpoints. For example to query cortex the endpoint `/prometheus/api/v1/query_range` will be used. | ||
|
||
#### `/alertmanager/*` | ||
|
||
Under this path prefix, Cortex will act as a Alertmanager web server. In this case, it will forward requests to the alertmanager and support the alertmanager API. This means for a user to access their Alertmanager UI, they will use the `/alertmanager` path of cortex. | ||
|
||
#### `/api/v1/*` -- The cortex API will exist under this path prefix. | ||
|
||
- `/push` | ||
- `/chunks` | ||
- `/rules/*` | ||
|
||
| Current | Proposed | | ||
| ------------------- | ----------------- | | ||
| `/api/prom/push` | `/api/v1/push` | | ||
| `/api/prom/chunks` | `/api/v1/chunks` | | ||
| `/api/prom/rules/*` | `/api/v1/rules/*` | | ||
|
||
|
||
#### Service Endpoints | ||
|
||
A number of endpoints currently exist that are not under the `/api/prom` prefix that provide basic web interfaces and trigger operations for cortex services. These endpoints will all be placed under a url with their service name as a prefix if it is applicable. | ||
|
||
| Current | Proposed | | ||
| --------------------- | ---------------------------------- | | ||
| `/status` | `/multitenant-alertmanager/status` | | ||
| `/config` | `/config` | | ||
| `/ring` | `/ingester/ring` | | ||
| `/ruler_ring` | `/ruler/ring` | | ||
| `/compactor/ring` | `/compactor/ring` | | ||
| `/store-gateway/ring` | `/store-gateway/ring` | | ||
| `/ha-tracker` | `/distributor/ha_tracker` | | ||
| `/all_user_stats` | `/distributor/all_user_stats` | | ||
| `/user_stats` | `/distributor/user_stats` | | ||
| `/flush` | `/ingester/flush` | | ||
| `/shutdown` | `/ingester/shutdown` | | ||
|
||
### Path Versioning | ||
|
||
Cortex will utilize path based versioning similar to both Prometheus and Alertmanager. This will allow future versions of the API to be released with changes over time. | ||
jtlisi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
### Backwards-Compatibility | ||
|
||
The new API endpoints and the current http prefix endpoints can be maintained concurrently. The flag to configure these endpoints will be maintained as `http.prefix`. This will allow us to roll out the new API without disrupting the current routing schema. The original http prefix endpoints can maintained indefinitely or be phased out over time. Deprecation warnings can be added to the current API either when initialized or utilized. This can be accomplished by injecting a middleware that logs a warning whenever a legacy API endpoint is used. | ||
|
||
In cases where Cortex is run as a single binary, the Alertmanager module will only be accesible using the new API. | ||
|
||
### Implementation | ||
|
||
This will be implemented by adding an API module to the Cortex service. This module will handle setting up all the required HTTP routes with Cortex. It will be designed around a set of interfaces required to fulfill the API. This is similar to how the `v1` Prometheus API is implemented. | ||
|
||
### Style | ||
|
||
* All new paths will utilize `_` instead of `-` for their url to conform with Prometheus and its use of the underscore in the `query_range` endpoint. This applies to all operations endpoints. Component names in the path can still contain dashes. For example: `/store-gateway/ring`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.