diff --git a/.github/workflows/semantic.yml b/.github/workflows/semantic.yml index ec1f36869c..cdf2797d28 100644 --- a/.github/workflows/semantic.yml +++ b/.github/workflows/semantic.yml @@ -8,6 +8,5 @@ on: jobs: semantic: with: - CHECK_PR_TITLE_OR_ONE_COMMIT: true + CHECK_PR_TITLE_OR_ONE_COMMIT: false uses: influxdata/validate-semantic-github-messages/.github/workflows/semantic.yml@main - diff --git a/libflux/go/libflux/buildinfo.gen.go b/libflux/go/libflux/buildinfo.gen.go index 577f76dd99..3fbf547197 100644 --- a/libflux/go/libflux/buildinfo.gen.go +++ b/libflux/go/libflux/buildinfo.gen.go @@ -94,6 +94,7 @@ var sourceHashes = map[string]string{ "stdlib/contrib/jsternberg/influxdb/influxdb.flux": "afc52f2e31d5e063e318b752d077c58189317c373494563ea0895cdcdea49074", "stdlib/contrib/qxip/clickhouse/clickhouse.flux": "8ad86d9c3c7a4271178d5e2fa9bb850856363cf470d92c3f5010b6de9e770db1", "stdlib/contrib/qxip/hash/hash.flux": "496d0ae212408a44f442bb5093fa92691d3f72927618ee1e841b52646db126c4", + "stdlib/contrib/qxip/iox/iox.flux": "c9bfbd83dac62ddcc85359d7e33168dc7ae7298492aaf5d2df1ea2dc2b9c5be4", "stdlib/contrib/qxip/logql/logql.flux": "f855e5a58efd4332c63bbdbb41efc9522c97722c44202f4b26c5226c89e7a646", "stdlib/contrib/rhajek/bigpanda/bigpanda.flux": "0f4d43a7ae08f0ce5e00a746082dbdae06008bcd69cb00b52f0b4f1bb10b7323", "stdlib/contrib/sranka/opsgenie/opsgenie.flux": "5313b78a30ffb01c606397c9bea954bdd4ca06c44663268bab1e0f706fc6d2c5", @@ -342,8 +343,8 @@ var sourceHashes = map[string]string{ "stdlib/sampledata/sampledata_test.flux": "70ba091a51d036a8cc25931808a39d81cf5d6dd17c2c7a5a081eb83fcfe5dd20", "stdlib/slack/slack.flux": "395d96eed6a8f8f6b275e8cc2f46f20326b92eff3cbb6a6583f216f146296d55", "stdlib/socket/socket.flux": "89b9c350c5cf8df5056a45623309be681c5472eadb9088ff5ee59a8c50b879b2", - "stdlib/sql/sql.flux": "b1d5ed22a2db2046b98d8fb43b8b84e32a613681943260b8990564f12998c7a6", - "stdlib/sql/sql_test.flux": "69b61fc1208bb986c14f2e50b004c5bf5004f9cdcfefad0313b5d3981184e1a3", + "stdlib/sql/sql.flux": "d114041fa023d42146c0dfac1ebb62832d45842cc345f2d935994d9cd19a4ea1", + "stdlib/sql/sql_test.flux": "bc43807f545de95046c1c8110530f84de9f2a28e6ef00dc261998bba1c1fcd89", "stdlib/strings/strings.flux": "15f029bbc9e907e09fdb41507df50208d5ad10c216256da68c4595d818483f2d", "stdlib/strings/strings_test.flux": "d972d0b63017d808de0c7342e98ea6e4a48e2564236d4a3eef4bc9fd0bb5ef5e", "stdlib/system/system.flux": "ce0b1ed2fa5cbf52345b3eccfd54a7637021d361a1c6c7f204b51fcfe4d9683a", diff --git a/stdlib/contrib/qxip/iox/iox.flux b/stdlib/contrib/qxip/iox/iox.flux new file mode 100644 index 0000000000..e4536b6afd --- /dev/null +++ b/stdlib/contrib/qxip/iox/iox.flux @@ -0,0 +1,122 @@ +// Package iox provides additional functions for querying data from InfluxDB IOx. +// +// ## Metadata +// introduced: 0.195.0 +// contributors: **GitHub**: [@qxip](https://github.com/qxip) +// +package iox + + +import "sql" +import "date" +import "strings" + +builtin _mask : (<-tables: stream[A], columns: [string]) => stream[B] where A: Record, B: Record + +// from retrieves data from an IOx bucket between the `start` and `stop` times. +// +// This version of `from` is equivalent to `from() |> range()` in a single call. +// +// ## Parameters +// +// - bucket: Name of the IOx bucket to query. +// +// - start: Earliest time to include in results. +// +// Results include points that match the specified start time. +// Use a relative duration, absolute time, or integer (Unix timestamp in seconds). +// For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. +// Durations are relative to `now()`. +// +// - stop: Latest time to include in results. Default is `now()`. +// +// Results exclude points that match the specified stop time. +// Use a relative duration, absolute time, or integer (Unix timestamp in seconds). +// For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`. +// Durations are relative to `now()`. +// +// - host: URL of the IOx instance to query. +// - org: Organization name. +// - token: [API token](https://docs.influxdata.com/influxdb/latest/security/tokens/). +// - table: Table used in the FlightSQL query. +// - limit: Limit for the FlightSQL query. Default is `1000`. +// - columns: Columns selected by the FlightSQL query. Default is `*`. +// - secure: Secure connection to IOx instance. Default is `true`. +// +// ## Examples +// +// ### Query using the bucket name +// +// ```no_run +// import "contrib/qxip/iox" +// +// iox.from(bucket: "sensors", org: "company", table: "cpu") +// ``` +// +// ### Query a remote InfluxDB Cloud instance +// +// ```no_run +// import "contrib/qxip/iox" +// import "influxdata/influxdb/secrets" +// +// token = secrets.get(key: "INFLUXDB_CLOUD_TOKEN") +// +// from( +// bucket: "sensors", +// host: "https://eu-central-1-1.aws.cloud2.influxdata.com:443", +// org: "company", +// token: token, +// table: "cpu", +// start: -1h, +// ) +// ``` +// +// ## Metadata +// tags: inputs +from = + ( + bucket, + start=-1h, + stop=now(), + org="", + host="", + token="", + table="", + columns="*", + limit="1000", + secure="true", + ) => + { + + dataSourceName = + if org != "" and host != "" and token != "" then + "iox://${host}/${bucket}?secure=${secure}&token=${token}" + else if org != "" and token != "" then + "iox://${host}/${org}_${bucket}?secure=${secure}&token=${token}" + else if org != "" and host != "" then + "iox://${host}/${org}_${bucket}?secure=${secure}" + else if host != "" and token != "" then + "iox://${host}/${bucket}?secure=${secure}&token=${token}" + else if org != "" then + "iox://${host}/${org}_${bucket}?secure=${secure}" + else if host != "" then + "iox://${host}/${bucket}?secure=${secure}&token=${token}" + else + "iox://${host}/${bucket}?secure=${secure}" + + qStart = date.time(t: start) + qStop = date.time(t: stop) + query = + "SELECT ${columns} FROM ${table} WHERE ( time >= '${qStart}' AND time <= '${qStop}') LIMIT ${limit}" + + source = + sql.from( + driverName: "influxdb-iox", + dataSourceName: "${dataSourceName}", + query: "${query}", + ) + + return source |> rename(columns: {time: "_time"}) + } + +_from = from diff --git a/stdlib/contrib/qxip/iox/placeholder.go b/stdlib/contrib/qxip/iox/placeholder.go new file mode 100644 index 0000000000..05e9d6e245 --- /dev/null +++ b/stdlib/contrib/qxip/iox/placeholder.go @@ -0,0 +1,5 @@ +// DO NOT EDIT: This file is autogenerated via the builtin command. +// +// This file ensures that this directory is a Go package + +package iox diff --git a/stdlib/packages.go b/stdlib/packages.go index 7b44e3bc34..f33dfb8ac5 100644 --- a/stdlib/packages.go +++ b/stdlib/packages.go @@ -21,6 +21,7 @@ import ( _ "github.com/InfluxCommunity/flux/stdlib/contrib/jsternberg/influxdb" _ "github.com/InfluxCommunity/flux/stdlib/contrib/qxip/clickhouse" _ "github.com/InfluxCommunity/flux/stdlib/contrib/qxip/hash" + _ "github.com/InfluxCommunity/flux/stdlib/contrib/qxip/iox" _ "github.com/InfluxCommunity/flux/stdlib/contrib/qxip/logql" _ "github.com/InfluxCommunity/flux/stdlib/contrib/rhajek/bigpanda" _ "github.com/InfluxCommunity/flux/stdlib/contrib/sranka/opsgenie"