How to use the @grafana/data.ArrayVector function in @grafana/data

To help you get started, we’ve selected a few @grafana/data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / plugins / datasource / loki / result_transformer.ts View on Github external
export function legacyLogStreamToDataFrame(
  stream: LokiLegacyStreamResult,
  reverse?: boolean,
  refId?: string
): DataFrame {
  let labels: Labels = stream.parsedLabels;
  if (!labels && stream.labels) {
    labels = parseLabels(stream.labels);
  }

  const times = new ArrayVector([]);
  const timesNs = new ArrayVector([]);
  const lines = new ArrayVector([]);
  const uids = new ArrayVector([]);

  for (const entry of stream.entries) {
    const ts = entry.ts || entry.timestamp;
    // iso string with nano precision, will be truncated but is parse-able
    times.add(ts);
    // So this matches new format, we are loosing precision here, which sucks but no easy way to keep it and this
    // is for old pre 1.0.0 version Loki so probably does not affect that much.
    timesNs.add(dateTime(ts).valueOf() + '000000');
    lines.add(entry.line);
    uids.add(createUid(ts, stream.labels, entry.line));
  }

  return constructDataFrame(times, timesNs, lines, uids, labels, reverse, refId);
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / plugins / datasource / loki / result_transformer.ts View on Github external
export function lokiStreamResultToDataFrame(stream: LokiStreamResult, reverse?: boolean, refId?: string): DataFrame {
  const labels: Labels = stream.stream;
  const labelsString = Object.entries(labels)
    .map(([key, val]) => `${key}="${val}"`)
    .sort()
    .join('');

  const times = new ArrayVector([]);
  const timesNs = new ArrayVector([]);
  const lines = new ArrayVector([]);
  const uids = new ArrayVector([]);

  for (const [ts, line] of stream.values) {
    // num ns epoch in string, we convert it to iso string here so it matches old format
    times.add(new Date(parseInt(ts.substr(0, ts.length - 6), 10)).toISOString());
    timesNs.add(ts);
    lines.add(line);
    uids.add(createUid(ts, labelsString, line));
  }

  return constructDataFrame(times, timesNs, lines, uids, labels, reverse, refId);
}
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / plugins / datasource / loki / result_transformer.ts View on Github external
export function legacyLogStreamToDataFrame(
  stream: LokiLegacyStreamResult,
  reverse?: boolean,
  refId?: string
): DataFrame {
  let labels: Labels = stream.parsedLabels;
  if (!labels && stream.labels) {
    labels = parseLabels(stream.labels);
  }

  const times = new ArrayVector([]);
  const timesNs = new ArrayVector([]);
  const lines = new ArrayVector([]);
  const uids = new ArrayVector([]);

  for (const entry of stream.entries) {
    const ts = entry.ts || entry.timestamp;
    // iso string with nano precision, will be truncated but is parse-able
    times.add(ts);
    // So this matches new format, we are loosing precision here, which sucks but no easy way to keep it and this
    // is for old pre 1.0.0 version Loki so probably does not affect that much.
    timesNs.add(dateTime(ts).valueOf() + '000000');
    lines.add(entry.line);
    uids.add(createUid(ts, stream.labels, entry.line));
  }

  return constructDataFrame(times, timesNs, lines, uids, labels, reverse, refId);
}
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / plugins / datasource / loki / result_transformer.ts View on Github external
export function lokiStreamResultToDataFrame(stream: LokiStreamResult, reverse?: boolean, refId?: string): DataFrame {
  const labels: Labels = stream.stream;
  const labelsString = Object.entries(labels)
    .map(([key, val]) => `${key}="${val}"`)
    .sort()
    .join('');

  const times = new ArrayVector([]);
  const timesNs = new ArrayVector([]);
  const lines = new ArrayVector([]);
  const uids = new ArrayVector([]);

  for (const [ts, line] of stream.values) {
    // num ns epoch in string, we convert it to iso string here so it matches old format
    times.add(new Date(parseInt(ts.substr(0, ts.length - 6), 10)).toISOString());
    timesNs.add(ts);
    lines.add(line);
    uids.add(createUid(ts, labelsString, line));
  }

  return constructDataFrame(times, timesNs, lines, uids, labels, reverse, refId);
}
github GridProtectionAlliance / openHistorian / Source / Applications / openHistorian / openHistorian / Grafana / public / app / plugins / datasource / loki / result_transformer.ts View on Github external
export function legacyLogStreamToDataFrame(
  stream: LokiLegacyStreamResult,
  reverse?: boolean,
  refId?: string
): DataFrame {
  let labels: Labels = stream.parsedLabels;
  if (!labels && stream.labels) {
    labels = parseLabels(stream.labels);
  }

  const times = new ArrayVector([]);
  const timesNs = new ArrayVector([]);
  const lines = new ArrayVector([]);
  const uids = new ArrayVector([]);

  for (const entry of stream.entries) {
    const ts = entry.ts || entry.timestamp;
    // iso string with nano precision, will be truncated but is parse-able
    times.add(ts);
    // So this matches new format, we are loosing precision here, which sucks but no easy way to keep it and this
    // is for old pre 1.0.0 version Loki so probably does not affect that much.
    timesNs.add(dateTime(ts).valueOf() + '000000');
    lines.add(entry.line);
    uids.add(createUid(ts, stream.labels, entry.line));
  }

  return constructDataFrame(times, timesNs, lines, uids, labels, reverse, refId);
}
github grafana / grafana / public / app / plugins / datasource / loki / result_transformer.ts View on Github external
export function legacyLogStreamToDataFrame(
  stream: LokiLegacyStreamResult,
  reverse?: boolean,
  refId?: string
): DataFrame {
  let labels: Labels = stream.parsedLabels;
  if (!labels && stream.labels) {
    labels = parseLabels(stream.labels);
  }
  const times = new ArrayVector([]);
  const lines = new ArrayVector([]);
  const uids = new ArrayVector([]);

  for (const entry of stream.entries) {
    const ts = entry.ts || entry.timestamp;
    times.add(ts);
    lines.add(entry.line);
    uids.add(`${ts}_${stream.labels}`);
  }

  if (reverse) {
    times.buffer = times.buffer.reverse();
    lines.buffer = lines.buffer.reverse();
  }

  return {
    refId,
    fields: [
github grafana / grafana / public / app / plugins / datasource / loki / result_transformer.ts View on Github external
export function lokiStreamResultToDataFrame(stream: LokiStreamResult, reverse?: boolean, refId?: string): DataFrame {
  const labels: Labels = stream.stream;

  const times = new ArrayVector([]);
  const lines = new ArrayVector([]);
  const uids = new ArrayVector([]);

  for (const [ts, line] of stream.values) {
    times.add(
      dateTime(Number.parseFloat(ts) / 1e6)
        .utc()
        .format()
    );
    lines.add(line);
    uids.add(
      `${ts}_{${Object.entries(labels)
        .map(([key, val]) => `${key}="${val}"`)
        .join('')}}`
    );
  }
github grafana / grafana / public / app / plugins / datasource / loki / result_transformer.ts View on Github external
export function legacyLogStreamToDataFrame(
  stream: LokiLegacyStreamResult,
  reverse?: boolean,
  refId?: string
): DataFrame {
  let labels: Labels = stream.parsedLabels;
  if (!labels && stream.labels) {
    labels = parseLabels(stream.labels);
  }
  const times = new ArrayVector([]);
  const lines = new ArrayVector([]);
  const uids = new ArrayVector([]);

  for (const entry of stream.entries) {
    const ts = entry.ts || entry.timestamp;
    times.add(ts);
    lines.add(entry.line);
    uids.add(`${ts}_${stream.labels}`);
  }

  if (reverse) {
    times.buffer = times.buffer.reverse();
    lines.buffer = lines.buffer.reverse();
  }

  return {
    refId,
github grafana / grafana / public / app / plugins / datasource / loki / result_transformer.ts View on Github external
export function lokiStreamResultToDataFrame(stream: LokiStreamResult, reverse?: boolean, refId?: string): DataFrame {
  const labels: Labels = stream.stream;

  const times = new ArrayVector([]);
  const lines = new ArrayVector([]);
  const uids = new ArrayVector([]);

  for (const [ts, line] of stream.values) {
    times.add(
      dateTime(Number.parseFloat(ts) / 1e6)
        .utc()
        .format()
    );
    lines.add(line);
    uids.add(
      `${ts}_{${Object.entries(labels)
        .map(([key, val]) => `${key}="${val}"`)
        .join('')}}`
    );
  }
github grafana / grafana / public / app / plugins / datasource / loki / result_transformer.ts View on Github external
export function legacyLogStreamToDataFrame(
  stream: LokiLegacyStreamResult,
  reverse?: boolean,
  refId?: string
): DataFrame {
  let labels: Labels = stream.parsedLabels;
  if (!labels && stream.labels) {
    labels = parseLabels(stream.labels);
  }
  const times = new ArrayVector([]);
  const lines = new ArrayVector([]);
  const uids = new ArrayVector([]);

  for (const entry of stream.entries) {
    const ts = entry.ts || entry.timestamp;
    times.add(ts);
    lines.add(entry.line);
    uids.add(`${ts}_${stream.labels}`);
  }

  if (reverse) {
    times.buffer = times.buffer.reverse();
    lines.buffer = lines.buffer.reverse();
  }

  return {