You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
870 B
27 lines
870 B
import { queryByConfig, QueryConfig } from '..'; |
|
|
|
import { DatasourceType, QueryType } from '../metrics/metric'; |
|
|
|
import * as _ from 'lodash'; |
|
|
|
|
|
// TODO: these `const`s should be CLI arguments |
|
const PROMETHEUS_URL = 'http://prometheus.metrics.corpglory.com'; |
|
const QUERY = '100-(avg by (instance) (irate(node_cpu_seconds_total{job="nvicta-ai-node-exporter",mode="idle"}[5m])) * 100)'; |
|
const FROM = 1660307430000; // ms |
|
const TO = 1660307437000; // ms |
|
|
|
const datasource = { |
|
type: DatasourceType.PROMETHEUS, |
|
url: `${PROMETHEUS_URL}/api/v1/query_range?query=${QUERY}&start=1543411320&end=1543432950&step=30` |
|
} |
|
const targets = []; |
|
const queryConfig = new QueryConfig(datasource, targets); |
|
queryByConfig(queryConfig, PROMETHEUS_URL, FROM, TO, QueryType.DIRECT) |
|
.then(res => { |
|
console.log(res); |
|
}) |
|
.catch(err => { |
|
console.error('Query error: ', err); |
|
}); |
|
|
|
|