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.
52 lines
1.0 KiB
52 lines
1.0 KiB
export enum QueryType { |
|
DIRECT = 'direct', |
|
GRAFANA = 'grafana', |
|
} |
|
|
|
export enum DatasourceType { |
|
INFLUXDB = 'influxdb', |
|
GRAPHITE = 'graphite', |
|
PROMETHEUS = 'prometheus', |
|
POSTGRES = 'postgres', |
|
ELASTICSEARCH = 'elasticsearch', |
|
MYSQL = 'mysql', |
|
} |
|
|
|
export declare type Datasource = { |
|
url: string; |
|
type: DatasourceType; |
|
params?: { |
|
db: string; |
|
q: string; |
|
epoch: string; |
|
}; |
|
data?: any; |
|
datasourceId?: string; |
|
}; |
|
|
|
export type DatasourceQuery = { |
|
url: string; |
|
method: string; |
|
schema: any; |
|
headers?: any; |
|
} |
|
|
|
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; |
|
}
|
|
|