|
|
@ -2,14 +2,26 @@ import { queryByConfig, QueryConfig } from '..'; |
|
|
|
|
|
|
|
|
|
|
|
import { DatasourceType, QueryType } from '../connectors'; |
|
|
|
import { DatasourceType, QueryType } from '../connectors'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { ArgumentParser } from 'argparse'; |
|
|
|
import * as _ from 'lodash'; |
|
|
|
import * as _ from 'lodash'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const parser = new ArgumentParser(); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: these `const`s should be CLI arguments
|
|
|
|
// TODO: parse version from package.json
|
|
|
|
const PROMETHEUS_URL = 'http://localhost:9090'; |
|
|
|
parser.add_argument('-v', '--version', { action: 'version', version: '0.1.1' }); |
|
|
|
const QUERY = '100-(avg by (instance) (irate(node_cpu_seconds_total{job="nvicta-ai-node-exporter",mode="idle"}[5m])) * 100)'; |
|
|
|
parser.add_argument('-u', '--url', { help: 'Datasource URL', required: true }); |
|
|
|
const FROM = 1660670020000; // ms
|
|
|
|
parser.add_argument('-q', '--query', { help: 'Query Template', required: true }); |
|
|
|
const TO = 1660670026000; // ms
|
|
|
|
parser.add_argument('-f', '--from', { help: 'From timestamp (ms), e.g. 1660670020000. If not specified, `now-5m` is used' }); |
|
|
|
|
|
|
|
parser.add_argument('-t', '--to', { help: 'To timestamp (ms), e.g. 1660670026000. If not specified, `now` is used' }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const args = parser.parse_args(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const timeNowInMs = new Date().getTime(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const PROMETHEUS_URL = args.url; |
|
|
|
|
|
|
|
const QUERY = args.query; |
|
|
|
|
|
|
|
const FROM = args.from || timeNowInMs - 5 * 60 * 1000; |
|
|
|
|
|
|
|
const TO = args.to || timeNowInMs; |
|
|
|
|
|
|
|
|
|
|
|
const datasource = { |
|
|
|
const datasource = { |
|
|
|
type: DatasourceType.PROMETHEUS, |
|
|
|
type: DatasourceType.PROMETHEUS, |
|
|
|