Skip to content

Commit cb4045b

Browse files
authored
feat: Add charts API (#811)
* Utilizes renderChartConfig and CH client to query for chart data * Implements API input schema * Adds lots of tests Testing Notes: * To use swagger, go to localhost:8000/api/v2/docs * Authorize using your access key found in localhost:8000/me * Under the charts route, click "Try it out" * Use example payload: * ``` { "startTime": <insert valid timestamp ms>, "endTime": <insert valid timestamp ms>, "granularity": "1h", "series": [ { "sourceId": "<insert valid sourceid>", "aggFn": "count", "where": "SeverityText:error", "groupBy": [] } ] } ``` It was easiest for me to go to the UI, create a new chart and grab the sourceid and start/end timestamps from the URL, plug it in and profit. Note: It was apparent to me that we will need to provide at least GET support for sources, otherwise that ID is not easily obtained. Ref: HDX-1651
1 parent 707ba7f commit cb4045b

File tree

8 files changed

+1643
-110
lines changed

8 files changed

+1643
-110
lines changed

packages/api/src/controllers/sources.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ export function getSources(team: string) {
44
return Source.find({ team });
55
}
66

7+
export function getSource(team: string, sourceId: string) {
8+
return Source.findOne({ _id: sourceId, team });
9+
}
10+
711
export function createSource(team: string, source: Omit<ISource, 'id'>) {
812
return Source.create({ ...source, team });
913
}

0 commit comments

Comments
 (0)