How to use the @influxdata/giraffe.fromFlux function in @influxdata/giraffe

To help you get started, we’ve selected a few @influxdata/giraffe 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 influxdata / influxdb / ui / src / timeMachine / apis / queryBuilder.ts View on Github external
export function extractCol(csv: string, colName: string): string[] {
  const {table} = fromFlux(csv)
  return table.getColumn(colName, 'string') || []
}
github influxdata / influxdb / ui / src / alerting / utils / history.ts View on Github external
const promise = queryPromise.then(resp => {
    if (resp.type !== 'SUCCESS') {
      return Promise.reject(new Error(resp.message))
    }

    const {table} = fromFlux(resp.csv)
    const rows: Row[] = []

    for (let i = 0; i < table.length; i++) {
      const row = {}

      for (const key of table.columnKeys) {
        row[key] = table.getColumn(key)[i]
      }

      rows.push(row)
    }

    return rows
  })
github influxdata / influxdb / ui / src / checks / components / CheckMatchingRulesCard.tsx View on Github external
const getMatchingRules = async (): Promise => {
    const checkTags = tags
      .filter(t => t.key && t.value)
      .map(t => [t.key, t.value])

    const queryTags = []

    if (queryResults) {
      const joined = queryResults.join('\n\n')
      const table = fromFlux(joined).table
      const fluxGroupKeyUnion = fromFlux(joined).fluxGroupKeyUnion.filter(
        v => v !== '_start' && v !== '_stop'
      )

      fluxGroupKeyUnion.forEach(gk => {
        const values = uniq(table.getColumn(gk, 'string'))
        values.forEach(v => {
          queryTags.push([gk, v])
        })
      })
    }

    const tagsList = [...checkTags, ...queryTags].map(t => [
      'tag',
      `${t[0].trim()}:${t[1].trim()}`,
    ])
github influxdata / influxdb / ui / src / shared / components / TimeSeries.tsx View on Github external
throw new Error(result.message)
        }

        if (result.didTruncate) {
          notify(resultTooLarge(result.bytesRead))
        }
      }

      const files = (results as RunQuerySuccessResult[]).map(r => r.csv)
      let giraffeResult

      if (isFlagEnabled('fluxParser')) {
        giraffeResult = fromFlux(files.join('\n\n'))
      } else {
        giraffeResult = fromFluxGiraffe(files.join('\n\n'))
      }

      this.pendingReload = false

      this.setState({
        giraffeResult,
        errorMessage,
        files,
        duration,
        loading: RemoteDataState.Done,
        statuses,
      })
    } catch (error) {
      if (error.name === 'CancellationError') {
        return
      }
github influxdata / influxdb / ui / src / checks / components / CheckMatchingRulesCard.tsx View on Github external
const getMatchingRules = async (): Promise => {
    const checkTags = tags
      .filter(t => t.key && t.value)
      .map(t => [t.key, t.value])

    const queryTags = []

    if (queryResults) {
      const joined = queryResults.join('\n\n')
      const table = fromFlux(joined).table
      const fluxGroupKeyUnion = fromFlux(joined).fluxGroupKeyUnion.filter(
        v => v !== '_start' && v !== '_stop'
      )

      fluxGroupKeyUnion.forEach(gk => {
        const values = uniq(table.getColumn(gk, 'string'))
        values.forEach(v => {
          queryTags.push([gk, v])
        })
      })
    }

    const tagsList = [...checkTags, ...queryTags].map(t => [
      'tag',
      `${t[0].trim()}:${t[1].trim()}`,
    ])
github influxdata / influxdb / ui / src / notebooks / context / query.tsx View on Github external
.then(raw => {
        return {
          source: text,
          raw: raw.csv,
          parsed: parse(raw.csv),
          error: null,
        }
      })
  }
github influxdata / influxdb / ui / src / shared / components / TimeSeries.tsx View on Github external
throw new Error(result.message)
        }

        if (result.didTruncate) {
          notify(resultTooLarge(result.bytesRead))
        }
      }

      const files = (results as RunQuerySuccessResult[]).map(r => r.csv)
      let giraffeResult

      if (isFlagEnabled('fluxParser')) {
        giraffeResult = fromFlux(files.join('\n\n'))
      } else {
        giraffeResult = fromFluxGiraffe(files.join('\n\n'))
      }

      this.pendingReload = false

      this.setState({
        giraffeResult,
        errorMessage,
        files,
        duration,
        loading: RemoteDataState.Done,
        statuses,
      })
    } catch (error) {
      if (error.name === 'CancellationError') {
        return
      }
github influxdata / influxdb / ui / src / alerting / utils / statusEvents.ts View on Github external
const promise = queryPromise.then(resp => {
    if (resp.type !== 'SUCCESS') {
      return Promise.reject(new Error(resp.message))
    }

    const {table} = fromFlux(resp.csv)
    const rows: Row[][] = [[]]

    for (let i = 0; i < table.length; i++) {
      const row = {}

      for (const key of table.columnKeys) {
        row[key] = table.getColumn(key)[i]
      }

      const tableIndex = row['table']

      if (!rows[tableIndex]) {
        rows[tableIndex] = [row]
      } else {
        rows[tableIndex].push(row)
      }

@influxdata/giraffe

[![Slack Status](https://img.shields.io/badge/slack-join_chat-white.svg?logo=slack&style=social)](https://www.influxdata.com/slack)

MIT
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis