Hello.
I can not find any info about handling errors from http.post/http.get (DNS lookup errors, https cert errors, timeouts, etc.). How can I have that connection error as a string (or at least a null response) and continues script execution?
Or maybe there is a general way of error handling? Like try { 0/0 } catch() { ... }
Hello @3bl3gamer ,
Welcome!
You’ll have to use array.from() like:
import "array"
import "experimental/http"
got = http.get(
url: "myurl",
headers: { Authorization:"Token tweiriuosfjdlk=="},
timeout: 30s
)
array.from(rows: [{_time: 2020-01-01T00:00:00Z, _value: got.statusCode}])
|> yield()
But these issues are related to what you’re asking about, I encourage you to take a look/comment.
opened 09:02PM - 08 Jun 21 UTC
enhancement
team/ui
**Proposal:**
Support output from flux functions with data formats other than A… nnotated CSV.
**Current behavior:**
The user can't output or visualize any datatype other than Annotated CSV. This is relevant for any of the following functions:
- [http.get()](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/experimental/http/get/)
- [findRecord()](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord/)
- [getRecord](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getrecord/)
- [findColumn()](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn/)
- [usage.limits](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/experimental/usage/limits/)
...and any other functions that return different formats that I'm missing.
**Desired behavior:**
Enable users to visualize scalars in the UI when selecting the gauge or single stat visualization type. Output other data formats in the raw data view as txt.
**Use case:**
This lack of format support blocks users from sophisticated Flux development.
**Alternatives**
Include links to documentation with hacks to force visualization in error messages:
- https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/experimental/http/get/#get-the-status-of-influxdb-oss
- suggest they use array.from()
opened 08:16PM - 07 Jun 21 UTC
A blocker for users is the ability to use functions that return outputs in forma… ts other than Annotated CSV.
**Expectation:**
When users use any of the following functions:
- [http.get()](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/experimental/http/get/)
- [findRecord()](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord/)
- [getRecord](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getrecord/)
- [findColumn()](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn/)
- [usage.limits](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/experimental/usage/limits/)
...and any other functions I'm missing.
They must construct a temporary table and map the output to it in order to output these other formats. In otherwords they must use either use array.from() and map() or follow the example here:
https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/experimental/http/get/#get-the-status-of-influxdb-oss
**Reality:**
The query runs, and no output is generated. The extension doesn't provide any errors when running these queries so the users are unaware of the need to search for these hacks. Related to influxdata/ui#224.
**Proposal**
Provide support for other data types.
Hello!
Not sure how array.from() will help here. For example, I have currently no service at https://127.0.0.1:81 , and if I run:
import "array"
import "experimental/http"
got = http.get(
url: "https://127.0.0.1:81",
timeout: 30s
)
array.from(rows: [{_time: 2020-01-01T00:00:00Z, _value: got.statusCode}])
|> yield()
…script still just fails with error calling function "get" ... connect: connection refused
(no tables in output).
Ah if you have no service then that won’t work. But I’m confused why are you trying to use http.get() against an unavailable service? Can you please provide some more context around what you’re trying to do so I can help you better?
I want to make a task which checks my service availability and immediately sends notification unless it’s not. I assume that notification service is always available, but my service may be down. Currently this does not work, because if my service is down, the whole script will fail and there will be no notification.
I’m running into this same issue and need to be able to check if a service is available as well. Has there been any progress here?