From 4e601710b1fc73559f970b2b4bdfbe9c6e935a78 Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Wed, 3 Jul 2024 13:23:57 -0500 Subject: [PATCH] chore(ci): Adjusts Unix timestamps (line protocol) and query time bounds for testing - Adjusts times for writing and querying data within a recent retention period. - Adjusts Unix timestamps (in line protocol samples) to yesterday's date. - Adjusts UTC time bounds (in queries) to today and yesterday. - Reverts mistakenly changed timestamps in clustered. --- .../cloud-dedicated/get-started/query.md | 48 ++++ .../influxdb/clustered/get-started/query.md | 78 +++++-- .../influxdb/clustered/get-started/write.md | 208 +++++++++--------- test/src/prepare-content.sh | 41 +++- 4 files changed, 253 insertions(+), 122 deletions(-) diff --git a/content/influxdb/cloud-dedicated/get-started/query.md b/content/influxdb/cloud-dedicated/get-started/query.md index e87a7001a..a3437de27 100644 --- a/content/influxdb/cloud-dedicated/get-started/query.md +++ b/content/influxdb/cloud-dedicated/get-started/query.md @@ -204,6 +204,44 @@ WHERE ``` {{% /influxdb/custom-timestamps %}} + + {{% note %}} Some examples in this getting started tutorial assume your InfluxDB credentials (**URL** and **token**) are provided by @@ -252,6 +290,16 @@ influxctl query \ {{% /code-placeholders %}} {{% /influxdb/custom-timestamps %}} +{{% note %}} +#### Query using stored credentials + +Optionally, you can configure `database` and `token` query credentials in your `influxctl` +[connection profile](/influxdb/clustered/reference/cli/influxctl/#create-a-configuration-file). + +The `--database` and `--token` command line flags override credentials in your +configuration file. +{{% /note %}} + {{% /tab-content %}} {{% tab-content %}} diff --git a/content/influxdb/clustered/get-started/query.md b/content/influxdb/clustered/get-started/query.md index 0f704a444..530c5551a 100644 --- a/content/influxdb/clustered/get-started/query.md +++ b/content/influxdb/clustered/get-started/query.md @@ -35,8 +35,10 @@ the simplicity of SQL. {{% note %}} The examples in this section of the tutorial query the -[**get-started** database](/influxdb/clustered/get-started/setup/#create-a-database) for data written in the -[Get started writing data](/influxdb/clustered/get-started/write/#write-line-protocol-to-influxdb) section. +[**get-started** database](/influxdb/clustered/get-started/setup/#create-a-database) +for data written in the +[Get started writing data](/influxdb/clustered/get-started/write/#write-line-protocol-to-influxdb) +section. {{% /note %}} ## Tools to execute queries @@ -202,6 +204,44 @@ WHERE ``` {{% /influxdb/custom-timestamps %}} + + {{% note %}} Some examples in this getting started tutorial assume your InfluxDB credentials (**URL** and **token**) are provided by @@ -233,21 +273,33 @@ Provide the following: {{% influxdb/custom-timestamps %}} {{% code-placeholders "get-started" %}} + ```sh influxctl query \ --database get-started \ --token $INFLUX_TOKEN \ "SELECT - * -FROM - home -WHERE - time >= '2022-01-01T08:00:00Z' - AND time <= '2022-01-01T20:00:00Z'" + * + FROM + home + WHERE + time >= '2022-01-01T08:00:00Z' + AND time <= '2022-01-01T20:00:00Z'" ``` + {{% /code-placeholders %}} {{% /influxdb/custom-timestamps %}} +{{% note %}} +#### Query using stored credentials + +Optionally, you can configure `database` and `token` query credentials in your `influxctl` +[connection profile](/influxdb/clustered/reference/cli/influxctl/#create-a-configuration-file). + +The `--database` and `--token` command line flags override credentials in your +configuration file. +{{% /note %}} + {{% /tab-content %}} {{% tab-content %}} @@ -308,12 +360,12 @@ _If your project's virtual environment is already running, skip to step 3._ - ```sh - influx3 sql "SELECT * + ```sh + influx3 sql "SELECT * FROM home WHERE time >= '2022-01-01T08:00:00Z' AND time <= '2022-01-01T20:00:00Z'" - ``` + ``` `influx3` displays query results in your terminal. @@ -606,7 +658,7 @@ _If your project's virtual environment is already running, skip to step 3._ 2. Defines a `Query()` function that does the following: - 1. Instantiates `influx.Client` with InfluxDB credentials. + 1. Instantiates `influx.Client` with the following parameters for InfluxDB credentials: - **`Host`**: your {{% product-name omit=" Clustered" %}} cluster URL - **`Database`**: the name of your {{% product-name %}} database @@ -637,7 +689,7 @@ _If your project's virtual environment is already running, skip to step 3._ ```sh - go mod tidy && go build && go run influxdb_go_client + go mod tidy && go run influxdb_go_client ``` The program executes the `main()` function that writes the data and prints the query results to the console. diff --git a/content/influxdb/clustered/get-started/write.md b/content/influxdb/clustered/get-started/write.md index fa3150f9b..18dd81f20 100644 --- a/content/influxdb/clustered/get-started/write.md +++ b/content/influxdb/clustered/get-started/write.md @@ -204,32 +204,32 @@ influxctl write \ --database get-started \ --token $INFLUX_TOKEN \ --precision s \ - 'home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1719734400 -home,room=Kitchen temp=21.0,hum=35.9,co=0i 1719734400 -home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1719738000 -home,room=Kitchen temp=23.0,hum=36.2,co=0i 1719738000 -home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1719741600 -home,room=Kitchen temp=22.7,hum=36.1,co=0i 1719741600 -home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1719745200 -home,room=Kitchen temp=22.4,hum=36.0,co=0i 1719745200 -home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1719748800 -home,room=Kitchen temp=22.5,hum=36.0,co=0i 1719748800 -home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1719752400 -home,room=Kitchen temp=22.8,hum=36.5,co=1i 1719752400 -home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1719756000 -home,room=Kitchen temp=22.8,hum=36.3,co=1i 1719756000 -home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1719759600 -home,room=Kitchen temp=22.7,hum=36.2,co=3i 1719759600 -home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1719763200 -home,room=Kitchen temp=22.4,hum=36.0,co=7i 1719763200 -home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1719766800 -home,room=Kitchen temp=22.7,hum=36.0,co=9i 1719766800 -home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1719770400 -home,room=Kitchen temp=23.3,hum=36.9,co=18i 1719770400 -home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1719774000 -home,room=Kitchen temp=23.1,hum=36.6,co=22i 1719774000 -home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1719777600 -home,room=Kitchen temp=22.7,hum=36.5,co=26i 1719777600' + 'home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000 +home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000 +home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600 +home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600 +home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200 +home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200 +home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800 +home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800 +home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400 +home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400 +home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000 +home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000 +home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600 +home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600 +home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200 +home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200 +home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800 +home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800 +home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400 +home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400 +home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000 +home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000 +home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600 +home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600 +home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200 +home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200' ``` {{% /code-placeholders %}} @@ -258,32 +258,32 @@ and then write it to {{< product-name >}}. ```sh cat <<- EOF > home.lp - home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1719820800 - home,room=Kitchen temp=21.0,hum=35.9,co=0i 1719820800 - home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1719824400 - home,room=Kitchen temp=23.0,hum=36.2,co=0i 1719824400 - home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1719828000 - home,room=Kitchen temp=22.7,hum=36.1,co=0i 1719828000 - home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1719831600 - home,room=Kitchen temp=22.4,hum=36.0,co=0i 1719831600 - home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1719835200 - home,room=Kitchen temp=22.5,hum=36.0,co=0i 1719835200 - home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1719838800 - home,room=Kitchen temp=22.8,hum=36.5,co=1i 1719838800 - home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1719842400 - home,room=Kitchen temp=22.8,hum=36.3,co=1i 1719842400 - home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1719846000 - home,room=Kitchen temp=22.7,hum=36.2,co=3i 1719846000 - home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1719849600 - home,room=Kitchen temp=22.4,hum=36.0,co=7i 1719849600 - home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1719853200 - home,room=Kitchen temp=22.7,hum=36.0,co=9i 1719853200 - home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1719856800 - home,room=Kitchen temp=23.3,hum=36.9,co=18i 1719856800 - home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1719860400 - home,room=Kitchen temp=23.1,hum=36.6,co=22i 1719860400 - home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1719864000 - home,room=Kitchen temp=22.7,hum=36.5,co=26i 1719864000 + home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000 + home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000 + home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600 + home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600 + home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200 + home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200 + home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800 + home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800 + home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400 + home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400 + home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000 + home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000 + home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600 + home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600 + home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200 + home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200 + home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800 + home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800 + home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400 + home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400 + home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000 + home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000 + home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600 + home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600 + home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200 + home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200 EOF ``` @@ -467,32 +467,32 @@ response=$(curl --silent --write-out "%{response_code}:-%{errormsg}" \ --header "Content-type: text/plain; charset=utf-8" \ --header "Accept: application/json" \ --data-binary " -home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1719734400 -home,room=Kitchen temp=21.0,hum=35.9,co=0i 1719734400 -home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1719738000 -home,room=Kitchen temp=23.0,hum=36.2,co=0i 1719738000 -home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1719741600 -home,room=Kitchen temp=22.7,hum=36.1,co=0i 1719741600 -home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1719745200 -home,room=Kitchen temp=22.4,hum=36.0,co=0i 1719745200 -home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1719748800 -home,room=Kitchen temp=22.5,hum=36.0,co=0i 1719748800 -home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1719752400 -home,room=Kitchen temp=22.8,hum=36.5,co=1i 1719752400 -home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1719756000 -home,room=Kitchen temp=22.8,hum=36.3,co=1i 1719756000 -home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1719759600 -home,room=Kitchen temp=22.7,hum=36.2,co=3i 1719759600 -home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1719763200 -home,room=Kitchen temp=22.4,hum=36.0,co=7i 1719763200 -home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1719766800 -home,room=Kitchen temp=22.7,hum=36.0,co=9i 1719766800 -home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1719770400 -home,room=Kitchen temp=23.3,hum=36.9,co=18i 1719770400 -home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1719774000 -home,room=Kitchen temp=23.1,hum=36.6,co=22i 1719774000 -home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1719777600 -home,room=Kitchen temp=22.7,hum=36.5,co=26i 1719777600 +home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000 +home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000 +home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600 +home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600 +home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200 +home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200 +home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800 +home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800 +home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400 +home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400 +home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000 +home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000 +home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600 +home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600 +home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200 +home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200 +home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800 +home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800 +home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400 +home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400 +home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000 +home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000 +home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600 +home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600 +home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200 +home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200 ") # Format the response code and error message output. @@ -578,32 +578,32 @@ response=$(curl --silent --write-out "%{response_code}:-%{errormsg}" \ --header "Content-Type: text/plain; charset=utf-8" \ --header "Accept: application/json" \ --data-binary " -home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1719734400 -home,room=Kitchen temp=21.0,hum=35.9,co=0i 1719734400 -home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1719738000 -home,room=Kitchen temp=23.0,hum=36.2,co=0i 1719738000 -home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1719741600 -home,room=Kitchen temp=22.7,hum=36.1,co=0i 1719741600 -home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1719745200 -home,room=Kitchen temp=22.4,hum=36.0,co=0i 1719745200 -home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1719748800 -home,room=Kitchen temp=22.5,hum=36.0,co=0i 1719748800 -home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1719752400 -home,room=Kitchen temp=22.8,hum=36.5,co=1i 1719752400 -home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1719756000 -home,room=Kitchen temp=22.8,hum=36.3,co=1i 1719756000 -home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1719759600 -home,room=Kitchen temp=22.7,hum=36.2,co=3i 1719759600 -home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1719763200 -home,room=Kitchen temp=22.4,hum=36.0,co=7i 1719763200 -home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1719766800 -home,room=Kitchen temp=22.7,hum=36.0,co=9i 1719766800 -home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1719770400 -home,room=Kitchen temp=23.3,hum=36.9,co=18i 1719770400 -home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1719774000 -home,room=Kitchen temp=23.1,hum=36.6,co=22i 1719774000 -home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1719777600 -home,room=Kitchen temp=22.7,hum=36.5,co=26i 1719777600 +home,room=Living\ Room temp=21.1,hum=35.9,co=0i 1641024000 +home,room=Kitchen temp=21.0,hum=35.9,co=0i 1641024000 +home,room=Living\ Room temp=21.4,hum=35.9,co=0i 1641027600 +home,room=Kitchen temp=23.0,hum=36.2,co=0i 1641027600 +home,room=Living\ Room temp=21.8,hum=36.0,co=0i 1641031200 +home,room=Kitchen temp=22.7,hum=36.1,co=0i 1641031200 +home,room=Living\ Room temp=22.2,hum=36.0,co=0i 1641034800 +home,room=Kitchen temp=22.4,hum=36.0,co=0i 1641034800 +home,room=Living\ Room temp=22.2,hum=35.9,co=0i 1641038400 +home,room=Kitchen temp=22.5,hum=36.0,co=0i 1641038400 +home,room=Living\ Room temp=22.4,hum=36.0,co=0i 1641042000 +home,room=Kitchen temp=22.8,hum=36.5,co=1i 1641042000 +home,room=Living\ Room temp=22.3,hum=36.1,co=0i 1641045600 +home,room=Kitchen temp=22.8,hum=36.3,co=1i 1641045600 +home,room=Living\ Room temp=22.3,hum=36.1,co=1i 1641049200 +home,room=Kitchen temp=22.7,hum=36.2,co=3i 1641049200 +home,room=Living\ Room temp=22.4,hum=36.0,co=4i 1641052800 +home,room=Kitchen temp=22.4,hum=36.0,co=7i 1641052800 +home,room=Living\ Room temp=22.6,hum=35.9,co=5i 1641056400 +home,room=Kitchen temp=22.7,hum=36.0,co=9i 1641056400 +home,room=Living\ Room temp=22.8,hum=36.2,co=9i 1641060000 +home,room=Kitchen temp=23.3,hum=36.9,co=18i 1641060000 +home,room=Living\ Room temp=22.5,hum=36.3,co=14i 1641063600 +home,room=Kitchen temp=23.1,hum=36.6,co=22i 1641063600 +home,room=Living\ Room temp=22.2,hum=36.4,co=17i 1641067200 +home,room=Kitchen temp=22.7,hum=36.5,co=26i 1641067200 ") # Format the response code and error message output. diff --git a/test/src/prepare-content.sh b/test/src/prepare-content.sh index 42ed5dfe9..4da6fa345 100644 --- a/test/src/prepare-content.sh +++ b/test/src/prepare-content.sh @@ -5,6 +5,12 @@ TEST_CONTENT="/app/content" +# Pattern to match a 10-digit Unix timestamp +TIMESTAMP_PATTERN='[0-9]{10}' + +NOW=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +YESTERDAY=$(date -u -d 'yesterday 00:00' '+%Y-%m-%dT%H:%M:%SZ') + function substitute_placeholders { for file in `find "$TEST_CONTENT" -type f \( -iname '*.md' \)`; do if [ -f "$file" ]; then @@ -12,9 +18,37 @@ function substitute_placeholders { # Replaces placeholder values with environment variable references. + # Date-specific replacements. + + grep -oE "$TIMESTAMP_PATTERN" "$file" | while read -r timestamp; do + # Replace Unix timestamps (for example, in line protocol sample data) with yesterday's date. + # Assuming the Unix timestamp is the whole line or a standalone word in the line + # Validate the extracted timestamp (optional) + if [[ $timestamp =~ ^1641[0-9]{6,12}$ ]]; then + specific_timestamp=$timestamp + + # Extract the time part + specific_time=$(date -u -d "@$specific_timestamp" '+%T') + + # Calculate 'yesterday' date but use 'specific_time' for the time part + yesterday_date=$(date -u -d 'yesterday' '+%Y-%m-%d') + yesterday_datetime="$yesterday_date"T"$specific_time"Z + + # Convert 'yesterday_datetime' to Unix timestamp + yesterday_timestamp=$(date -u -d "$yesterday_datetime" +%s) + + # Replace the extracted timestamp with `yesterday_timestamp` + sed -i "s|$specific_timestamp|$yesterday_timestamp|g;" $file + fi + done + + ## Adjust time bounds in queries to be the current time and yesterday. + sed -i "s|'2022-01-01T20:00:00Z'|'$NOW'|g; + s|'2022-01-01T08:00:00Z'|'$YESTERDAY'|g; + " $file + # Non-language-specific replacements. - sed -i 's|https:\/\/{{< influxdb/host >}}|$INFLUX_HOST|g; - ' $file + sed -i 's|https:\/\/{{< influxdb/host >}}|$INFLUX_HOST|g;' $file # Python-specific replacements. # Use f-strings to identify placeholders in Python while also keeping valid syntax if @@ -38,9 +72,6 @@ function substitute_placeholders { s|"name": "BUCKET_NAME"|"name": "$INFLUX_DATABASE"|g;' \ $file - sed -i 's|"influxctl database create --retention-period 1y get-started"|"influxctl database create --retention-period 1y $INFLUX_TMP_DATABASE"|g;' \ - $file - # Replace remaining placeholders with variables. # If the placeholder is inside of a Python os.getenv() function, don't replace it. # Note the specific use of double quotes for the os.getenv() arguments here. You'll need to use double quotes in your code samples for this to match.