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.

59 lines
1.1 KiB

2 years ago
export enum QueryType {
DIRECT = 'direct',
GRAFANA = 'grafana',
}
export enum DatasourceType {
INFLUXDB = 'influxdb',
GRAPHITE = 'graphite',
PROMETHEUS = 'prometheus',
POSTGRES = 'postgres',
ELASTICSEARCH = 'elasticsearch',
MYSQL = 'mysql',
}
// TODO: Datasource: type -> class
4 years ago
export declare type Datasource = {
url: string;
2 years ago
type: DatasourceType;
4 years ago
params?: {
db: string;
q: string;
epoch: string;
};
data?: any;
datasourceId?: string;
auth?: any;
4 years ago
};
2 years ago
export type DatasourceQuery = {
4 years ago
url: string;
method: string;
schema: any;
headers?: any;
auth?: {
username: string;
password: string;
};
4 years ago
}
2 years ago
export type DataTable = {
2 years ago
values: (number | null)[][];
columns: string[];
4 years ago
}
2 years ago
export abstract class DatasourceConnector {
4 years ago
constructor(
public datasource: Datasource,
2 years ago
// TODO: Target type
4 years ago
public targets: any[],
) {}
4 years ago
/*
from / to - timestamp in ms
limit - max number of items in result
offset - number of items to skip from timerange start
*/
2 years ago
abstract getQuery(from: number, to: number, limit: number, offset: number): DatasourceQuery;
abstract parseResponse(res): DataTable;
4 years ago
}