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.
 
 

58 lines
1.1 KiB

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
export declare type Datasource = {
url: string;
type: DatasourceType;
params?: {
db: string;
q: string;
epoch: string;
};
data?: any;
datasourceId?: string;
auth?: any;
};
export type DatasourceQuery = {
url: string;
method: string;
schema: any;
headers?: any;
auth?: {
username: string;
password: string;
};
}
export type DataTable = {
values: (number | null)[][];
columns: string[];
}
export abstract class DatasourceConnector {
constructor(
public datasource: Datasource,
// TODO: Target type
public targets: any[],
) {}
/*
from / to - timestamp in ms
limit - max number of items in result
offset - number of items to skip from timerange start
*/
abstract getQuery(from: number, to: number, limit: number, offset: number): DatasourceQuery;
abstract parseResponse(res): DataTable;
}