Grafana/Loki: Adds support for new Loki endpoints and metrics (#20158)
* Grafana/Loki: Adds support for new Loki endpoints and metrics * Adds `/loki/` prefix to new loki endpoints and updates response interfaces * Improved legacy support * Removed changes related to plugin.json and added Loki-specific hacks * Fixes live streaming for legacy loki datasources
This commit is contained in:
@@ -26,22 +26,24 @@ export class DataFrameView<T = any> implements Vector<T> {
|
||||
|
||||
constructor(private data: DataFrame) {
|
||||
const obj = ({} as unknown) as T;
|
||||
|
||||
for (let i = 0; i < data.fields.length; i++) {
|
||||
const field = data.fields[i];
|
||||
const getter = () => {
|
||||
return field.values.get(this.index);
|
||||
};
|
||||
const getter = () => field.values.get(this.index);
|
||||
|
||||
if (!(obj as any).hasOwnProperty(field.name)) {
|
||||
Object.defineProperty(obj, field.name, {
|
||||
enumerable: true, // Shows up as enumerable property
|
||||
get: getter,
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(obj, i, {
|
||||
enumerable: false, // Don't enumerate array index
|
||||
get: getter,
|
||||
});
|
||||
}
|
||||
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
@@ -59,11 +61,7 @@ export class DataFrameView<T = any> implements Vector<T> {
|
||||
}
|
||||
|
||||
toArray(): T[] {
|
||||
const arr: T[] = [];
|
||||
for (let i = 0; i < this.data.length; i++) {
|
||||
arr.push({ ...this.get(i) });
|
||||
}
|
||||
return arr;
|
||||
return new Array(this.data.length).fill(0).map((_, i) => ({ ...this.get(i) }));
|
||||
}
|
||||
|
||||
toJSON(): T[] {
|
||||
|
||||
@@ -261,6 +261,8 @@ export abstract class DataSourceApi<
|
||||
*/
|
||||
languageProvider?: any;
|
||||
|
||||
getVersion?(): Promise<string>;
|
||||
|
||||
/**
|
||||
* Can be optionally implemented to allow datasource to be a source of annotations for dashboard. To be visible
|
||||
* in the annotation editor `annotations` capability also needs to be enabled in plugin.json.
|
||||
@@ -302,6 +304,7 @@ export interface ExploreQueryFieldProps<
|
||||
|
||||
export interface ExploreStartPageProps {
|
||||
datasource?: DataSourceApi;
|
||||
exploreMode: 'Logs' | 'Metrics';
|
||||
onClickExample: (query: DataQuery) => void;
|
||||
}
|
||||
|
||||
@@ -443,18 +446,22 @@ export interface DataQueryError {
|
||||
|
||||
export interface DataQueryRequest<TQuery extends DataQuery = DataQuery> {
|
||||
requestId: string; // Used to identify results and optionally cancel the request in backendSrv
|
||||
|
||||
dashboardId: number;
|
||||
interval: string;
|
||||
intervalMs?: number;
|
||||
maxDataPoints?: number;
|
||||
panelId: number;
|
||||
range?: TimeRange;
|
||||
reverse?: boolean;
|
||||
scopedVars: ScopedVars;
|
||||
targets: TQuery[];
|
||||
timezone: string;
|
||||
range: TimeRange;
|
||||
|
||||
cacheTimeout?: string;
|
||||
exploreMode?: 'Logs' | 'Metrics';
|
||||
rangeRaw?: RawTimeRange;
|
||||
timeInfo?: string; // The query time description (blue text in the upper right)
|
||||
targets: TQuery[];
|
||||
panelId: number;
|
||||
dashboardId: number;
|
||||
cacheTimeout?: string;
|
||||
interval: string;
|
||||
intervalMs: number;
|
||||
maxDataPoints: number;
|
||||
scopedVars: ScopedVars;
|
||||
|
||||
// Request Timing
|
||||
startTime: number;
|
||||
|
||||
@@ -10,11 +10,10 @@ export type GraphSeriesValue = number | null;
|
||||
|
||||
/** View model projection of a series */
|
||||
export interface GraphSeriesXY {
|
||||
label: string;
|
||||
color: string;
|
||||
data: GraphSeriesValue[][]; // [x,y][]
|
||||
info?: DisplayValue[]; // Legend info
|
||||
isVisible: boolean;
|
||||
label: string;
|
||||
yAxis: YAxis;
|
||||
// Field with series' time values
|
||||
timeField: Field;
|
||||
@@ -22,6 +21,8 @@ export interface GraphSeriesXY {
|
||||
valueField: Field;
|
||||
seriesIndex: number;
|
||||
timeStep: number;
|
||||
|
||||
info?: DisplayValue[]; // Legend info
|
||||
}
|
||||
|
||||
export interface CreatePlotOverlay {
|
||||
|
||||
Reference in New Issue
Block a user