Last active
September 3, 2024 10:12
-
-
Save suyashcjoshi/b683a718735964e63a5e665a76f09b54 to your computer and use it in GitHub Desktop.
Sample shell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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