-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rewrite queries with InfluxQL
I first started to implement query by series, to support different aggregates (min, max) per paths, but switched to doing everything in InfluxQL instead because of way better performance. Flux performed abysmally. InfluxQL queries now use InfluxV2's V1 api, with the v1 client library.
- Loading branch information
Showing
4 changed files
with
255 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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,39 @@ | ||
import { ZonedDateTime } from '@js-joda/core' | ||
import { getValues } from './HistoryAPI' | ||
import { SKInflux } from './influx' | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
|
||
const toConsole = (s: any) => console.log(s) | ||
const logging = { | ||
debug: toConsole, | ||
error: toConsole, | ||
} | ||
|
||
const skinflux = new SKInflux( | ||
{ | ||
onlySelf: true, | ||
url: process.env.URL || '!!!', | ||
token: process.env.TOKEN || '!!!', | ||
bucket: process.env.BUCKET || '!!!', | ||
org: process.env.ORG || '!!!', | ||
writeOptions: {}, | ||
}, | ||
logging, | ||
() => undefined, | ||
) | ||
const context = process.env.CONTEXT || 'no-context' | ||
const start = ZonedDateTime.parse('2023-07-24T13:03:29.048Z') | ||
const end = ZonedDateTime.parse('2023-07-24T13:04:29.048Z') | ||
const req = { | ||
query: { | ||
paths: process.env.PATHS, | ||
resolution: '60s', | ||
}, | ||
} | ||
const resp = { | ||
status: (n: number) => undefined, | ||
json: (s: any) => console.log(JSON.stringify(s, null, 2)), | ||
} | ||
getValues(skinflux, context, start, end, toConsole, req, resp) |