Commit Graph

1068 Commits (bf45841359a06a4c3c923cfc29d5c2516cbaecc5)

Author SHA1 Message Date
Sam Arnold 79168cf671
refactor: separate coarse and fine permission interfaces (#20996) (#21035)
(cherry picked from commit b7e7de24d6)
2021-03-23 08:29:52 -04:00
davidby-influx 75612264e7
feat: Log query text for POST requests (#20993) (#21021)
The HTTP handler logs URLs, but not body values for POST requests.
This means that queries sent by GET are logged, because the query
is in the URL, but queries sent by POST have no query text in the
log.  This feature prints all the key-value pairs in the post body,
which includes the query text, except passwords, which are redacted.

Closes https://github.com/influxdata/influxdb/issues/20653

(cherry picked from commit 70755bf42c)

Closes https://github.com/influxdata/influxdb/issues/21000
2021-03-22 20:28:38 -07:00
davidby-influx 8a31b0ebdc
fix: infinite recursion bug (#20862) (#20914)
* fix: infinite recursion bug (#20862)

* Revert "fix(error): unsupported value: +Inf" error not handled gracefully (#20250)"

This reverts commit 6ac0bb3fe3.

* fix: No infinite recursion on write error

If there is some error writing to the response writer, we
would previous have infinite recursion.

Re-closes https://github.com/influxdata/influxdb/issues/20249

(cherry picked from commit d6f7716924)

* chore: update CHANGELOG.md

Co-authored-by: Sam Arnold <sarnold@influxdata.com>
2021-03-10 09:19:49 -08:00
davidby-influx 9c6e401372
feat: Make meta queries respect QueryTimeout values (#20910)
Meta queries (SHOW TAG VALUES, SHOW TAG KEYS, SHOW SERIES CARDINALITY, etc.) do not respect
the QueryTimeout config parameter. Meta queries should check the query context when possible
to allow cancellation and timeout. This will not be as frequent as regular queries, which
use iterators, because meta queries return data in batches.

Add a context.Context to
(*Store).MeasurementNames()
(*Store).MeasurementsCardinality()
(*Store).SeriesCardinality()
(*Store).TagValues()
(*Store).TagKeys()
(*Store).SeriesSketches()
(*Store).MeasurementsSketches()
which is tested for timeout or cancellation
to allow limitation of time spent in meta queries

https://github.com/influxdata/influxdb/issues/20736
(cherry picked from commit 092c7a9976)

* chore: move context.Context to first argument in methods per convention

(cherry picked from commit a8b2129df5)
2021-03-09 14:40:50 -08:00
davidby-influx 54d8d0180d
chore: run goimports on 1.8 branch to bring it up to new check-in standards (#20907)
Also manually edit imports section to meet our more granular conventions within the strictures of goimports.
2021-03-09 12:08:26 -08:00
davidby-influx 0212d3c6db
fix(error): unsupported value: +Inf" error not handled gracefully (#20276)
* fix(error): unsupported value: +Inf" error not handled gracefully

JSON marshalling errors should be returned properly formatted in JSON
like other errors. This fix formats marshalling errors the same way
influxdb formats other query errors.

Fixes https://github.com/influxdata/influxdb/issues/20249

(cherry picked from commit 2407077576)

* chore(changelog): update CHANGELOG.md for PR #20276
2020-12-07 13:55:13 -08:00
Sam Arnold 926a6ceef7 chore: fix clustering build
Clustering requires taking the hash of synthetic points, so
allow this function to work on anything with a HashID.

(cherry picked from commit d96c8fb125)
2020-12-07 14:00:52 -04:00
Yun Zhao a3a07fb2d1
feat: Optimize shard lookups in groups containing only one shard (#20118) 2020-11-30 14:04:11 -05:00
Ayan George 4c098bbe91 fix: Reuse http server (#20191)
Once applied, this patch will use the same net/http.Server value to
handle all http requests.

This simplifies cleanly shutting down the server.
2020-11-30 09:19:32 -05:00
Ayan George d6962a05a2 fix: Properly shutdown http server on Close() (#20171) 2020-11-29 21:05:37 -05:00
Ayan George c6f38a835f
fix: Upgrade version of jwt-go package to v4.0.0 (#19893) (#19910)
This commit updates the dependencies for influxdb to require v4.0.0-preview1 of
the jwt-go package.  This required updating the go.mod and go.sum files as well
as any source file that directly imported that package.

Prior to this commit, the TestHandler_Query_Auth() tests would fail as it
checked for specific error strigns returned by the jwt-go package.

Version 4.0.0-preview1 of the package changed the verbiage of those errors a
bit.  This patch updates the test to detect the new error string.
2020-11-06 05:30:44 -05:00
Ayan George 025cfe976a
feat: generate modern profiles (#19655) (#19792)
* feat: generate modern profiles

Prior to this commit, influxd was writing legacy profiling data which
often (always?) required an accompanying executable to use.

This commit instructs influxd to write profiles in the new format which
can be examined without a binary.

While we're at it, this commit also adds the allocs and threadcreate
profiles.

Finally, this patch also changes the format of the downloaded tar in the
following ways:

* The profiles are added to the profile/ directory -- so instead of
  extracting the profiles into your current directory, they're placed in
  a "profiles" directory.

* This commit adds the .pb.gz extension to each of the files since
  they're gzipped protobuf files and not .txt.
2020-10-21 16:15:44 -04:00
Christopher M. Wolff 25fb1077e2
fix(flux): add durations to Flux logging (#19697) 2020-10-13 10:59:39 -07:00
Jonathan A. Sternberg ceead88bd5
fix(services/storage): multi measurement queries return all applicable series (#19592)
This fixes multi measurement queries that go through the storage service
to correctly pick up all series that apply with the filter. Previously,
negative queries such as `!=`, `!~`, and predicates attempting to match
empty tags did not work correctly with the storage service when multiple
measurements or `OR` conditions were included.

This was because these predicates would be categorized as "multiple
measurements" and then it would attempt to use the field keys iterator
to find the fields for each measurement. The meta queries for these did
not correctly account for negative equality operators or empty tags when
finding appropriate measurements and those could not be changed because
it would cause a breaking change to influxql too.

This modifies the storage service to use new methods that correctly
account for the above situations rather than the field keys iterator.

Some queries that appeared to be single measurement queries also get
considered as multiple measurement queries. Any query with an `OR`
condition will be considered a multiple measurement query.

This bug did not apply to single measurement queries where one
measurement was selected and all of the logical operators were `AND`
values. This is because it used a different code path that correctly
handled these situations.

Backport of #19566.
2020-09-21 14:09:07 -05:00
Ayan George 9d26f53d79
feat: Collect values written stats (#19187) (#19445)
* feat(engine/tsm1): Add WritePointsWithContext()

Add WritePontsWithContext() and make WritePoints() a thin wrapper for
it.

The purpose is to add statistics context values that we'll use to
propagate the number of fields and points written to calls up the call
chain.

* feat(tsdb): Add WriteToShardWithContext()

When applied, this patch adds WriteToShardWithContext() and wraps it
with WriteToShard() to preserve the API.

The the purpose of this addition is to propagate a context.Context value
to Shard.WritePointsWithContext().

* feat(tsdb/shard): Add WritePointsWithContext()

The purpose of adding WritePointsWithContext() is to propage context
values down to engine code and propage statistics via the context.Value
up to callers.

This patch also adds values written statistics to the shard.

* feat(http): Gather values written stats

WritePointsWithContext() was added to propagate context values down to
the engine and communicate stats to the caller.

* feat(http): Gather values written stats

WritePointsWithContext() was added to propagate context values down to
the engine and communicate stats to the caller.

* refactor: Change MetricKey to ContextKey

This patch gives the type we're useing for context keys a better name.
2020-08-26 13:37:45 -04:00
Ayan George 58a324a63c feat(http): Allow user supplied HTTP headers
This patch adds the [http.headers] subsection to the configuration file
that allows users to supply headers that will be returned in all HTTP
responses.

Applying this patch will:

* Add code to implement new configuration items.
* Add test to ensure configuration is properly parsed.
* Add test to ensure http response headers are set
* Update sample configuration file
2020-07-08 14:03:07 -04:00
Ayan George 33d78a1d4b
refactor(http): Simplify Authorizer (#17704) (#18299)
Have AuthorizerIsOpen() assert if a given authizer has an
AuthorizeUnrestricted() method and if so, call that to provide the
result of AuthorizerIsOpen().

Otherwise we check if the supplied Authorizer is nil.

This preserves the fast-path for checking tag-level (and other) tsdb
operations.

This simplifies how we handle such authorizers by handling this case in
only one place.
2020-05-29 15:25:48 -04:00
David Norton 275b02e5dd fix: verify precision parameter in write requests
This change updates the HTTP endpoints that service v1 and v2 writes to
verify the values passed in the precision parameter.
2020-04-07 13:31:34 -04:00
Jakub Bednář 7047d87264
feat(handler): Add 2.0 compatible health endpoint (#17252) 2020-04-06 07:36:26 +02:00
Jonathan A. Sternberg 2852bf0399
fix: storage read service should not return a nil cursor (#17359)
The storage read service would return a nil cursor if there was no data
and no shards to read from. This modifies it to return an empty cursor
instead.
2020-03-20 09:23:47 -05:00
jsign 69519243fe
fix: services/httpd: parse correctly Accept header with extra test case
Signed-off-by: jsign <jsign.uy@gmail.com>
2020-03-12 14:01:49 -05:00
Ayan George f24bdb3ee5
feat(handler): Add 2.0 compatible write endpoint (#16908)
This commit adds a /api/v2/write endpoint that maps the supplied bucket
and org to a v1 database and retention policy.

* Add AllowedOrgs to httpd Config type.

* Add /api/v2/write handler
2020-03-06 10:03:25 -05:00
ricky c1e11e732e fix(meta): remove double index increment of set meta 2020-01-14 11:11:43 +08:00
Gunnar Aasen 0c4703aaa3 feat(httpd): Add option to authenticate debug/pprof and ping endpoints 2019-09-20 16:32:22 -07:00
Jonathan A. Sternberg c6764914a9
Fix the http handler to not mislabel series as partial
If a series was split by the encoder because of chunking and it was
reconstructed by the http handler, it would not reset the partial
indicator for the series to indicate if the series was still partial or
not. That meant that a result that returned more than the 10,000 values
in a single series with chunking disabled would say that the series was
partial, but it was not.

This fixes it so the handler now correctly sets the partial attribute of
the series to indicate if the series is still partial or not. This was
done when merging results, but was not done with series.
2019-07-23 11:52:16 -05:00
Gunnar Aasen 86f78523cc feat(go): Update Go version to 1.12 2019-07-11 12:52:36 -07:00
Jonathan A. Sternberg 2fccaaad24
Remove a debugging println call (#14297) 2019-07-10 11:47:24 -05:00
Jonathan A. Sternberg 7ca4e644f1
Update flux version to v0.33.2 (#14208)
The flux in influxdb has been upgraded to use v0.33.2. A lot of
interfaces for the storage engine were changed during this so code had
to change to accomodate the new interfaces and remove the old ones.

Included in this commit is a patch file for the changes that were made.
A patch was generated for the following packages:

* `flux/stdlib/influxdata/influxdb`
* `storage/reads`
* `tsdb/cursors`

These are the three packages that are in common with version 2 of the
database and the first of these packages contains the specific
implementations that are used for version 1.

It is very possible that the next time we upgrade this, the patch will
not apply cleanly just like it wouldn't have applied cleanly to this
update. The patch is mostly meant to document exactly what changed
during the copy over to help ensure we don't forget things when adapting
the interfaces.

Add a patch file to hopefully make this easier in the future
2019-06-27 13:52:02 -05:00
Adam 94ee5a5f2d fix csv decoder bug where empty tag values cause an array index panic 2019-04-22 18:36:03 -04:00
Stuart Carnie b222dfbe5b
fix(storage): Update predicate key mapping to match 2.x behavior
When a Flux predicate is transformed to a Store.Read / GroupRead request,
the `_measurement` and `_field` keys are remapped to match 2.x internal
tag keys.

This change does not modify the 2.x behavior, but rather updates the
1.x mapping, so merging future updates from the 2.x storage/reads
package should have fewer conflicts.
2019-04-05 12:14:20 -07:00
Jonathan A. Sternberg 3406e8c7ff
Merge pull request #13153 from influxdata/deps/upgrade-flux
Upgrade flux to the latest version and remove the platform dependency
2019-04-04 11:41:27 -05:00
Jonathan A. Sternberg 31501c9dcf
Upgrade flux to the latest version and remove the platform dependency
This integrates the influxdb 1.x series to the latest version of Flux
and updates the code to use it. It also removes the dependency on
platform and copies the necessary code from storage into the 1.x series
so the dependency is unneeded.

The flux functions specific to 1.x have been moved to the same structure
that flux changed to with having a `stdlib` directory instead of a
`functions` directory. It also adds a `databases()` function that
returns the databases from the meta client.
2019-04-04 10:55:09 -05:00
David Norton 0ab2a30497 fix(httpd): log when auth enabled & secret blank 2019-04-03 12:32:47 -04:00
David Norton 3ec2ac43a4 fix(httpd): fail bearerauth if shared secret blank 2019-04-02 11:26:57 -04:00
Edd Robinson 1d2be75615 Fixes #10490
This commit extends the Prometheus remote write endpoint to drop
unsupported Prometheus values, rather than reject the entire batch.

InfluxDB does not support NaN, -Inf or +Inf, but Prometheus does. The
remote write endpoint will now drop these and write valid values in the
provided batch.

If the user enabled write trace logging (`[http] write-tracing = true`)
then summaries of any dropped values within a batch will be logged.

If a batch of values contains any values that are subsequently dropped,
the returned status code will be `204`.
2019-03-21 12:20:58 +00:00
Ahmed Ashour 926fa7b079 Fix typos (#11494) 2019-02-21 08:28:01 -08:00
Edd Robinson 05e7def600
Merge pull request #10332 from ludweeg/ludweeg/unslice
Simplify s[:] to s where s is a slice
2019-02-11 10:24:43 +00:00
Dilan Bellinghoven cb9b89015d
Add back newlines to minimize changes 2019-02-05 07:47:29 -05:00
Dilan Bellinghoven 502ac291e7
Move resp after Store.Read 2019-02-05 07:45:59 -05:00
Dilan Bellinghoven 9aace188cc
Add back newline 2019-02-04 22:28:35 -05:00
Dilan Bellinghoven 4bd67c5c68
Merge branch '1.8' into fix-null-pointer-reference 2019-02-04 22:20:05 -05:00
Dilan Bellinghoven d2e6b91de2
Updated servePromRead to match #10617 and updated handler_test.go to reflect changes 2019-02-04 22:15:44 -05:00
Ben Wells e9bada090f Fix misspelling identified by misspell 2019-02-03 20:27:43 +00:00
Edd Robinson 7431808996
Merge pull request #10403 from gupsho/fix_golint_warnings_services_graphite
Fix golint warnings for services/graphite
2019-02-01 08:20:42 -08:00
Edd Robinson 424dce8173
Merge pull request #10401 from gupsho/fix_lint_warnings_snapshotter
Fix lint warnings snapshotter
2019-02-01 08:06:26 -08:00
Edd Robinson e7a40402ea
Merge pull request #10276 from brookst/abs-fix
Fix bug with incorrect ABS results for negative integer values
2019-02-01 07:54:46 -08:00
Stuart Carnie c47a3ea2af feat(flux): Add support for optionally logging Flux queries
New configuration:

```toml
[http]
flux-log-enabled = true
```

will produce log entries similar to:

```
ts=2019-01-11T14:47:46.124347Z lvl=info msg="Executed Flux query" log_id=0CwLysq0000 service=httpd compiler_type=flux response_size=1467 query="from(bucket:\"test\") |> range(start: -5000h) |> limit(n:5)" stat_total_duration=3.949ms stat_compile_duration=3.183ms stat_queue_duration=0.026ms stat_plan_duration=0.055ms stat_requeue_duration=0.000ms stat_execute_duration=0.668ms stat_max_allocated=3200 stat_concurrency=1
```
2019-01-11 09:09:26 -07:00
David Norton 8026cd6c86 fix #10595: fix panic in Prometheus read API 2019-01-08 13:41:41 -05:00
Dilan Bellinghoven 7666694cfc
services/http/handler_test.go: Added unit test to test for case when Store.Read() returns nil, nil 2018-12-19 17:57:43 -05:00
Stuart Carnie 216cfa329f feat(flux): Add user authentication and authorization support
* Add AuthorizeDatabase API to QueryAuthorizer to verify a user has
  appropriate access to the specified database
* Update serverFluxQuery handler to require a meta.User when auth is
  enabled
* update Flux createFromSource and createBucketsSource dependencies to
  require Authorizer when auth is enabled in configuration
* update createFromSource to verify read permissions for each bucket
  specified in a Flux query
* update BucketsDecoder, which implements the buckets() Flux function,
  to return buckets that the user has read or write permissions to
* add unit tests to verify authentication is required for Flux HTTP
  requests when auth is enabled in configuration
2018-12-19 14:46:12 -07:00