256 Commits

Author SHA1 Message Date
b0ecc90329 InfluxDB: capture more downstream errors (#103978)
This adds more checks on the type of errors returned from InfluxDB
fsql datasource queries. The Grpc error code `Unavailable` is mapped
to a downstream error source.
2025-04-14 09:21:09 -04:00
757be6365a CI: Bump golangci-lint to 2.0.2 (#103572) 2025-04-10 14:42:23 +02:00
47ec51fda7 Influx: Support PDC for Influx SQL (#103032)
* Support PDC for Influx SQL

* Correctly set the gRPC transport creds dial option

* Logging and refactor

* Allow URLs with no scheme

* Use passthrough resolver for socks proxy

* Update comment

* Extract url parsing and add test

* Check err
2025-04-02 16:21:59 +01:00
360c57b3d7 InfluxDB: capture more downstream errors (#103274)
This adds more checks on the type of errors returned from InfluxDB fsql
datasource queries. Grpc errors with code `InvalidArgument`, `PermissionDenied`
and `NotFound` are mapped to downstream errors.
2025-04-02 08:47:47 -04:00
e1e1d3fd9f Fix: Prints should always include new lines (#102795)
* CI: Allow Bench conversion to fail

We shouldn't mark PRs and commits as X if they fail to convert logs with Bench.

* Fix: Prints should always include new lines

* fix: remove unused import
2025-03-27 12:27:53 +01:00
709723927f Assign errorsource to InfluxDB Flux http errors (#102823)
InfluxDB Flux queries can return a http.Error type that we can use to
assign errorsource to.

This PR checks for that type of error, and uses our errorsource
machinery to assign an errorsource.

This is part of https://github.com/grafana/data-sources/issues/377
2025-03-26 08:00:06 -04:00
3bdb2aa349 Plugins: Fix support for adhoc filters with raw queries in InfluxDB (#101966)
Plugins: Fix support for adhoc filters with raw queries in InfluxDB

Fixes #101635.
2025-03-17 12:07:33 -04:00
9de769318c Add more errorsource attribution to InfluxDb datasource (#100969)
This PR adds errorsource attribution to the influxql and flux query paths
when the query model cannot be parsed, which is a user error.

It also catches cases where the datasource configuration does not
contain a scheme or host, and adds downstream attribution to those
errors.

Error handling on the influxql query path is updated to match 'all errors
are per query, and stashed on the response object' pattern.

Fixes https://github.com/grafana/oss-plugin-partnerships/issues/1250
2025-02-20 11:53:28 -05:00
196a73ec72 influxdb - fix nil pointer usage - fixes #100723 (#100724)
When introducing errorsource over in:

https://github.com/grafana/grafana/pull/99900

I introduced a bug - trying to use a http response with a non-nil error.
In that case, the response is nil, so code panics.

This PR removes that check.
2025-02-14 08:25:26 -05:00
cfae9d20d2 Add errorsource to InfluxDB datasource plugin fixes #1072 (#99900)
This PR adds `backend.ErrorSourceDownstream` values to all `backend.DataResponse`
values where it's certain that the error wasn't the result of the
InfluxDB datasource plugin.
2025-02-04 09:33:32 -05:00
58d17ecad1 InfluxDB: Refactor frame and field creation (#97635)
* refactor frame and field creation

* use influxql package to get the type of the query

* remove unnecessary tests

* add influxql in go.mod

* fix unit test

* update ownership

* update query expression
2024-12-20 12:23:17 +01:00
6d21eddf13 Plugins: Update to latest go plugin SDK (v0.260.3) w/ arrow v18 (#97561)
Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>
2024-12-13 17:06:39 +03:00
488e71226b InfluxDB: Add support for LIST arrow type (#93227)
Add support for LIST arrow type
2024-09-24 18:36:07 +01:00
f5926af99a InfluxDB: Update macro regexp (#93040)
Update macro and tests
2024-09-11 14:26:09 +01:00
df3d8915ba Chore: Bump Go to 1.23.0 (#92105)
* chore: Bump Go to 1.23.0

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* update swagger files

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* chore: update .bingo/README.md formatting to satisfy prettier

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* chore(lint): Fix new lint errors found by golangci-lint 1.60.1 and Go 1.23

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* keep golden file

* update openapi

* add name to expected output

* chore(lint): rearrange imports to a sensible order

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

---------

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2024-08-21 11:40:42 -04:00
4fcd348366 InfluxDB: Fix returning InfluxDB error messages (#89973)
* Revert "Chore: Return influxdb query error early before parsing the result (#88549)"

This reverts commit a87c155c06bf3f92d711342131f68f3086b3f9d0.

* Handle error in buffered parser

* handle error message in streaming parser
2024-07-04 17:45:36 +02:00
dfcda2b14a InfluxDB: Don't interpolate bucket keyword in flux language if it is part of a join query (#89298)
don't interpolate bucket keyword if it is part of a join query
2024-06-19 08:22:16 +02:00
92233350f8 InfluxDB: Add custom metadata to the first frame via header (#88698)
* add custom metadata via header to the response

* use strings.CutPrefix instead of regex
2024-06-17 20:02:53 +03:00
8fddf30621 InfluxDB: Flight SQL test, add function to search for free port (#89255)
* add function to search for free port

* Update pkg/tsdb/influxdb/fsql/fsql_test.go

Co-authored-by: Dave Henderson <dave.henderson@grafana.com>

* Update pkg/tsdb/influxdb/fsql/fsql_test.go

Co-authored-by: Dave Henderson <dave.henderson@grafana.com>

* fix test

* fix go linting issue

* fix go lint

---------

Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
2024-06-17 09:16:52 -05:00
6262c56132 chore(perf): Pre-allocate where possible (enable prealloc linter) (#88952)
* chore(perf): Pre-allocate where possible (enable prealloc linter)

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* fix TestAlertManagers_buildRedactedAMs

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* prealloc a slice that appeared after rebase

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

---------

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
2024-06-14 14:16:36 -04:00
808cf75ff8 InfluxDB: Use json-iterator package for json operations (#88562)
* return error early

* enable gzip between grafana and influxdb

* use json-iterator package for json operations

* revert gzip changes

* update test

* go mod tidy
go work sync
2024-06-06 20:14:53 +03:00
08276bd8e7 InfluxDB: Revert calculation of maxPointsEnforced value (#88809)
revert calculation of maxPointsEnforced
2024-06-05 21:43:04 +02:00
a87c155c06 Chore: Return influxdb query error early before parsing the result (#88549)
return error early
2024-06-05 21:36:13 +02:00
c73bbf19a1 InfluxDB: Introduce maxDataPoints setting for flux variable query editor (#87935)
* Introduce custom variable support

* Remove comment lines

* introduce maxDataPoints

* fix tests

* update

* fix unit tests

* remove new line
2024-06-03 12:09:33 +03:00
194039c429 InfluxDB: Update alias regex pattern (#87713)
* use frontend mode alias regex

* remove comment
2024-05-14 09:53:18 +02:00
3317691615 InfluxDB: Support cardinality queries with backend mode (#87264)
support cardinality queries
2024-05-03 12:50:00 +02:00
96f49bfaee InfluxDB: Fix panic when reading concurrency count during influxql health check (#85771)
fix panic when reading concurrency count during influxql health check
2024-04-10 15:32:38 +02:00
fec7765111 Chore: InfluxQL stream parser improvements (#85041)
* don't iterate over first column as it is a time column already

* don't iterate over first column as it was handled earlier

* add more flexibility to run the commands

* Update pkg/tsdb/influxdb/influxql/converter/converter.go

Co-authored-by: Nick Richmond <5732000+NWRichmond@users.noreply.github.com>

---------

Co-authored-by: Nick Richmond <5732000+NWRichmond@users.noreply.github.com>
2024-03-26 19:25:03 +02:00
016d6f2f6d InfluxDB: Fix alias interpolation when it has $__interval or multiple tags (#84940)
fix $__interval interpolating in alias
2024-03-22 11:27:04 +01:00
297d73a7df InfluxDB: Add configuration option for enabling insecure gRPC connections (#83834)
* InfluxDB: add configuration option for enabling insecure gRPC connections

* fix: add insecureGrpc to InfluxOptions

* rename options label 'gRPC' -> 'Connection'

Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>

* update docs: rename options label 'gRPC' -> 'Connection'

Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>

* default insecure connection boolean to false in frontend

Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>

* run prettier:write

---------

Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>
2024-03-12 13:36:11 +01:00
2cce9aa2f7 Chore: Move tracing function in influxdb package (#83899)
move tracing function in influxdb package
2024-03-05 07:34:08 -06:00
94f544c9f6 InfluxDB: Fix tag interpolation when varable used within a regex pattern (#82785)
* fix tag interpolation

* remove redundant variables
2024-02-16 10:20:09 +01:00
3f940f4da1 Chore: Use jsoniter in influxdb from grafana-plugin-sdk-go (#82360)
use jsoniter from grafana-plugin-sdk-go
2024-02-13 17:47:00 +01:00
0c6e409350 Chore: Update arrow and prometheus dependencies (#82215)
* update arrow and prometheus

* keep codeowner

* use compare

* use grafana-plugin-sdk-go v0.210.0

---------

Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>
2024-02-13 01:50:25 +01:00
b0dfeb1911 Chore: Clean up intervalv2 functions (#82074)
* clean up intervalv2 functions

* use roundInterval from grafana-plugin-sdk-go

* use from grafana-plugin-sdk-go

* have intervalv2 in publicdashboards and remove tsdb/intervalv2

* legacydata cleanup

* remove unused variables

* Update pkg/tsdb/legacydata/interval/interval.go

Co-authored-by: Arati R. <33031346+suntala@users.noreply.github.com>

---------

Co-authored-by: Arati R. <33031346+suntala@users.noreply.github.com>
2024-02-09 11:39:21 +01:00
994aedaac3 Chore: Update InfluxDB response parser test files (#81899)
* add show diagnostics tests

* update test files
2024-02-06 11:31:55 +01:00
536153c336 InfluxDB: Run queries in parallel behind influxdbRunQueriesInParallel feature toggle (#81209)
* create the feature flag

* bring the concurrency in to the play

* Update feature flag

* Use concurrency number from settings

* update influxdb dependency

* use ConcurrentQueryCount from plugin-sdk-go

* use helper method for concurrent query count

* log the error

* add value guard

* add unit tests

* handle concurrency error
2024-02-01 11:58:24 +01:00
177fa1b947 InfluxDB: Fix template variable interpolation (#80971)
* use regex as templateSrv replace format

* use regex as templateSrv replace format for raw queries

* import path fix

* don't use regex formatter

* tag value escape

* tag value escape with wrappers

* polished interpolation logic

* update unit tests

* comments and more place to update

* unit test update

* fix escaping

* handle the string and array of string type separately

* update variable type
2024-02-01 00:30:21 +01:00
7d0017f3f2 InfluxDB: Use grafana timeout value for flux queries (#81252)
* use grafana timeout for flux queries

* get timeout from settings

* fix test
2024-01-25 17:05:08 +01:00
14e55fefbb InfluxDB: Check the value type before casting it to the string (#80986)
* Check the value type before casting it to the string

* set visualization as table by default

* append all values for show diagnostics

* golangci-lint

* append metadata only to first frame
2024-01-25 11:28:25 +01:00
1caaa56de0 FeatureFlags: Use interface rather than manager (#80000) 2024-01-09 10:38:06 -08:00
2edcf0edbd InfluxDB: Use database input for SQL configuration instead of metadata (#79579)
* introduce constants file

* update frontend to use database field

* use dbName field instead of metadata

* use secureGrpc

* betterer
2023-12-15 18:41:32 +01:00
03da1a3f3f InfluxDB: Update SQL language url specification (#79408)
* accept urls with or without port

* remove redundant comment

* remove redundant function
2023-12-13 16:01:01 +01:00
c088d003f2 InfluxDB: Implement InfluxQL json streaming parser (#76934)
* Have the first iteration

* Prepare bench testing

* rename the test files

* Remove unnecessary test file

* Introduce influxqlStreamingParser feature flag

* Apply streaming parser feature flag

* Add new tests

* More tests

* return executedQueryString only in first frame

* add frame meta and config

* Update golden json files

* Support tags/labels

* more tests

* more tests

* Don't change original response_parser.go

* provide context

* create util package

* don't pass the row

* update converter with formatted frameName

* add executedQueryString info only to first frame

* update golden files

* rename

* update test file

* use pointer values

* update testdata

* update parsing

* update converter for null values

* prepare converter for table response

* clean up

* return timeField in fields

* handle no time column responses

* better nil field handling

* refactor the code

* add table tests

* fix config for table

* table response format

* fix value

* if there is no time column set name

* linting

* refactoring

* handle the status code

* add tracing

* Update pkg/tsdb/influxdb/influxql/converter/converter_test.go

Co-authored-by: İnanç Gümüş <m@inanc.io>

* fix import

* update test data

* sanity

* sanity

* linting

* simplicity

* return empty rsp

* rename to prevent confusion

* nullableJson field type for null values

* better handling null values

* remove duplicate test file

* fix healthcheck

* use util for pointer

* move bench test to root

* provide fake feature manager

* add more tests

* partial fix for null values in table response format

* handle partial null fields

* comments for easy testing

* move frameName allocation in readSeries

* one less append operation

* performance improvement by making string conversion once

pkg: github.com/grafana/grafana/pkg/tsdb/influxdb/influxql
             │ stream2.txt │            stream3.txt             │
             │   sec/op    │   sec/op     vs base               │
ParseJson-10   314.4m ± 1%   303.9m ± 1%  -3.34% (p=0.000 n=10)

             │ stream2.txt  │             stream3.txt              │
             │     B/op     │     B/op      vs base                │
ParseJson-10   425.2Mi ± 0%   382.7Mi ± 0%  -10.00% (p=0.000 n=10)

             │ stream2.txt │            stream3.txt             │
             │  allocs/op  │  allocs/op   vs base               │
ParseJson-10   7.224M ± 0%   6.689M ± 0%  -7.41% (p=0.000 n=10)

* add comment lines

---------

Co-authored-by: İnanç Gümüş <m@inanc.io>
2023-12-06 12:39:05 +01:00
2b0e7afb4e InfluxDB: Fix an edge case while parsing table response (#78802)
* Prepare the test files

* use json files everywhere

* update golden json files

* disable update

* update test file

* fix naming

* lint

* InfluxDB: Add metadata information to first frame only (#78664)

* executedString in first frame only

* lint

* fix tests

* update tests

* don't update

* linting

* update

* update again

* handle nil values

* append in the right array

* add comments

* remove redundant if condition
2023-12-01 18:31:49 +01:00
dff5022021 Chore: Return executedString information even with frames has no time column (#78906)
* return executedString for no time column responses

* remove comment
2023-11-30 14:25:15 +01:00
aea5a9f01a Chore: Introduce util package for InfluxDB backend testing (#78826)
have a util package
2023-11-29 17:48:53 +01:00
23c7211f1d Chore: InlfuxDB testing update (#78663)
* Prepare the test files

* use json files everywhere

* update golden json files

* disable update

* update test file

* fix naming

* lint

* InfluxDB: Add metadata information to first frame only (#78664)

* executedString in first frame only

* lint

* fix tests

* update tests

* don't update

* linting

* update

* update again
2023-11-29 16:19:46 +01:00
c5f3ce1371 InfluxDB: Parse data for table view to have parity with frontend parser (#78365)
* Use TimeSeriesWide format for table response

* fix group by query result parsing

* handle labels

* provide a test where result has no tags

* parsing results without time column

* clean the code

* remove the comment line

* more cleaning

* lint
2023-11-22 19:27:42 +01:00
5096806eab InfluxDB: Don't sort retention policies on the backend (#78252)
don't sort retention policies
2023-11-16 10:39:15 +02:00