Skip to content

Instantly share code, notes, and snippets.

@suyashcjoshi
Last active September 3, 2024 10:12
Show Gist options
  • Save suyashcjoshi/b683a718735964e63a5e665a76f09b54 to your computer and use it in GitHub Desktop.
Save suyashcjoshi/b683a718735964e63a5e665a76f09b54 to your computer and use it in GitHub Desktop.
Sample shell script
#!/bin/bash
# Define variables
INFLUX_URL="http://localhost:8086" # URL of your InfluxDB instance
ORG="your_organization" # Your organization name
BUCKET="your_bucket" # Your bucket name
TOKEN="your_auth_token" # Your authentication token
# Define the Flux query
QUERY='from(bucket: "your_bucket") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "your_measurement")'
# Execute the query using influx CLI
influx query "$QUERY" \
--org "$ORG" \
--token "$TOKEN" \
--url "$INFLUX_URL"
# Check if the command was successful
if [ $? -eq 0 ]; then
echo "Query executed successfully."
else
echo "Error executing query."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment