How to run a simple query in Flux?

Hi All, I want to run a simple query in Flux and not sure how to execute it. I am using Influx 1.7 .Can you please help how to execute the Flux Query and how to run it. i am new to this.

Hello @oom,
First please enable Flux:
https://docs.influxdata.com/influxdb/v1.7/flux/installation/
Here are all the ways to execute Flux queries. I recommend using Chronograf to start.
https://docs.influxdata.com/influxdb/v1.7/flux/guides/execute-queries/

Is that sufficient to get you started?

Hi Anais,
I have enabled the flux in our environment. I am able to run the Script as well. I want to know is there any way that I will keep the code in a file and run the file instead putting a big code upfront. Below is the command I use to run,

Is there anyway I can keep the code in a file and execute the file. The approach I am using is difficult to debug and occupying complete screen editor. We want to do this in CLI. Also how can we write the output of Flux to InfluxDB.

Our Version is InfluxDB shell version: 1.8.3