Back to Influxdb

Create

content/shared/influxdb-v2/reference/cli/influx/scripts/create.md

latest2.9 KB
Original Source

The influx scripts create command creates an invokable script in InfluxDB.

Usage

influx scripts create [flags]

Flags

FlagDescriptionInput type{{< cli/mapped >}}
-c--active-configCLI configuration to use for commandstring
--configs-pathPath to influx CLI configurations (default ~/.influxdbv2/configs)stringINFLUX_CONFIGS_PATH
-d--description({{< req >}}) Purpose or functionality of the scriptstring
-f--filePath to file containing the script to be executedstring
-h--helpHelp for the create command
--hide-headersHide table headers (default false)INFLUX_HIDE_HEADERS
--hostHTTP address of InfluxDB (default http://localhost:8086)stringINFLUX_HOST
--http-debugInspect communication with InfluxDB serversstring
--jsonOutput data as JSON (default false)INFLUX_OUTPUT_JSON
-l--language({{< req >}}) Language the script is written instring
-n--name({{< req >}}) Script name of the scriptstring
-s--scriptContents of the script to be executedstring
--skip-verifySkip TLS certificate verificationINFLUX_SKIP_VERIFY
-t--tokenAPI tokenstringINFLUX_TOKEN

Example

{{< cli/influx-creds-note >}}

Create a script using raw Flux
sh
export FLUX_SCRIPT='
  from(bucket: "example-bucket")
    |> range(start: -10h)
    |> filter(fn: (r) => r._measurement == "m")
    |> aggregateWindow(every: 1h, fn: mean)
    |> to(bucket: "default-ds-1d", org: "my-org")
'

influx scripts create \
  -n "example-script" \
  -d "a simple example" \
  -l "flux" \
  -s $FLUX_SCRIPT
Create a script from a file
sh
influx scripts create \
  -n "example-script" \
  -d "a simple example" \
  -l "flux" \
  -f /path/to/example-script.flux