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:
kay delaney
2019-11-15 15:38:25 +00:00
committed by David
parent 1248457fee
commit e0a2d4beac
32 changed files with 1541 additions and 493 deletions

View File

@@ -1,8 +1,8 @@
import { logStreamToDataFrame, appendResponseToBufferedData } from './result_transformer';
import { legacyLogStreamToDataFrame, appendLegacyResponseToBufferedData } from './result_transformer';
import { FieldType, MutableDataFrame } from '@grafana/data';
import { LokiLogsStream } from './types';
import { LokiLegacyStreamResult } from './types';
const streams: LokiLogsStream[] = [
const streams: LokiLegacyStreamResult[] = [
{
labels: '{foo="bar"}',
entries: [
@@ -25,7 +25,7 @@ const streams: LokiLogsStream[] = [
describe('logStreamToDataFrame', () => {
it('converts streams to series', () => {
const data = streams.map(stream => logStreamToDataFrame(stream));
const data = streams.map(stream => legacyLogStreamToDataFrame(stream));
expect(data.length).toBe(2);
expect(data[0].fields[1].labels['foo']).toEqual('bar');
@@ -46,7 +46,7 @@ describe('appendResponseToBufferedData', () => {
data.addField({ name: 'labels', type: FieldType.other });
data.addField({ name: 'id', type: FieldType.string });
appendResponseToBufferedData({ streams }, data);
appendLegacyResponseToBufferedData({ streams }, data);
expect(data.get(0)).toEqual({
ts: '1970-01-01T00:00:00Z',
line: "foo: 'bar'",