|
| 1 | +import React from 'react' |
| 2 | +import CodeSnippet from 'src/shared/components/CodeSnippet' |
| 3 | + |
| 4 | +import {SafeBlankLink} from 'src/utils/SafeBlankLink' |
| 5 | +import {event} from 'src/cloud/utils/reporting' |
| 6 | + |
| 7 | +const logCopyCodeSnippet = () => { |
| 8 | + event('firstMile.cliWizard.executeAggregateQuery.code.copied') |
| 9 | +} |
| 10 | + |
| 11 | +const logDocsOpened = () => { |
| 12 | + event('firstMile.cliWizard.executeAggregateQuery.docs.opened') |
| 13 | +} |
| 14 | + |
| 15 | +type OwnProps = { |
| 16 | + bucket: string |
| 17 | +} |
| 18 | + |
| 19 | +export const ExecuteAggregateQuery = (props: OwnProps) => { |
| 20 | + const {bucket} = props |
| 21 | + |
| 22 | + const fromBucketSnippet = `from(bucket: "weather-data") |
| 23 | + |> range(start: -10m) |
| 24 | + |> filter(fn: (r) => r.measurement == "temperature") |
| 25 | + |> mean()` |
| 26 | + |
| 27 | + const codeSnippet = `influx query 'from(bucket:"${bucket}") |> range(start:-10m) |> mean()' --raw` |
| 28 | + |
| 29 | + return ( |
| 30 | + <> |
| 31 | + <h1>Execute a Flux Aggregate Query</h1> |
| 32 | + <p> |
| 33 | + An{' '} |
| 34 | + <SafeBlankLink |
| 35 | + href="https://docs.influxdata.com/flux/v0.x/function-types/#aggregates" |
| 36 | + onClick={logDocsOpened} |
| 37 | + > |
| 38 | + aggregate |
| 39 | + </SafeBlankLink>{' '} |
| 40 | + function is a powerful method for returning combined, summarized data |
| 41 | + about a set of time-series data. |
| 42 | + </p> |
| 43 | + <p> |
| 44 | + An aggregation is applied after the time range and filters, as seen in |
| 45 | + the example below. |
| 46 | + </p> |
| 47 | + <CodeSnippet |
| 48 | + text={fromBucketSnippet} |
| 49 | + showCopyControl={false} |
| 50 | + onCopy={logCopyCodeSnippet} |
| 51 | + language="properties" |
| 52 | + /> |
| 53 | + <p>In the InfluxCLI, run the following:</p> |
| 54 | + <CodeSnippet |
| 55 | + text={codeSnippet} |
| 56 | + onCopy={logCopyCodeSnippet} |
| 57 | + language="properties" |
| 58 | + /> |
| 59 | + <p style={{marginTop: '20px'}}> |
| 60 | + This will return the mean of the insect counts from the census data. |
| 61 | + </p> |
| 62 | + </> |
| 63 | + ) |
| 64 | +} |
0 commit comments