Commit Graph

1124 Commits (933a14e16f0232c5ec883644b7363a59da7bcd90)

Author SHA1 Message Date
Sam Arnold d96c8fb125 chore: fix clustering build
Clustering requires taking the hash of synthetic points, so
allow this function to work on anything with a HashID.
2020-12-07 11:24:45 -04:00
Daniel Moran 5d922e9d0e
feat: Optimize shard lookups in groups containing only one shard (#20118) (#20200)
Co-authored-by: Yun Zhao <zhaoyun2316@gmail.com>
2020-11-30 15:16:21 -05:00
Ayan George e75e83314b
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-29 21:03:19 -05:00
Ayan George 8d90d953d7
fix: Properly shutdown http server on Close() (#20171) 2020-11-25 12:46:55 -05:00
Ayan George 225bcecd73
fix: Upgrade version of jwt-go package to v4.0.0 (#19893)
* fix: Upgrade version of jwt-go package to v4.0.0

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-05 10:55:24 -05:00
Ayan George f7eb697dd3
refactor: Use filepath.Walk (#19514)
Prior to this commit, we had our own recursive file walker which
required a condition based on if s.Config.TypesDB pointed to a directory
or a regular file.

This commit replaces our own readdir() with filepath.Walk() and treats
recursing directories and loading one file as a single case.  This
simplifies the code quite a bit.
2020-10-21 10:29:48 -04:00
Ayan George b1def70670
feat: generate modern profiles (#19655)
* 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 09:26:15 -04:00
Pavel Zavora e8f7b78d68 fix(CORS): allow PATCH 2020-09-24 11:55:22 +02:00
Ayan George 6ce0e11738
feat: Collect values written stats (#19187)
* 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-12 11:26:12 -04:00
David Norton 619f0ab78e
Merge pull request #18667 from influxdata/new-http-headers
feat(service/httpd): Add user configurable HTTP headers
2020-07-08 13:59:59 -04:00
Tristan Su 6910c53440
feat(prometheus): update prometheus remote protocol (#17814)
Fetched up-to-date protocol from prometheus project
2020-07-08 07:12:52 -07:00
Ayan George 04536858d7
Merge branch 'master-1.x' into new-http-headers 2020-06-30 11:03:04 -04:00
Ayan George dde8231d5c 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-06-30 10:59:25 -04:00
Pavel Závora 2ff73114a8
Merge branch 'master-1.x' into 18391/cors_v1 2020-06-26 06:29:30 +02:00
Tristan Su 57ea78e984
fix(httpd): add option to authenticate prometheus remote read (#18429) 2020-06-23 15:03:19 -07:00
Pavel Zavora 0c6940d0a3 fix(handler): allow CORS in v2 compatibility endpoints 2020-06-09 09:09:30 +02:00
Pavel Zavora 0e458e7175 fix(handler): add User-Agent to allowed CORS headers 2020-06-09 07:09:27 +02:00
Jakub Bednář 61606289db chore(handler): add 2.0 compatible health endpoint from v1.8 (#17252) 2020-06-09 06:53:32 +02:00
Ayan George 2529799abb
refactor: Change ToLower comparisons to EqualFold (#18147)
When comparing strings in a case-insensitive way, strings.EqualFold() is
(almost?) always faster than comparing the results of strings.ToLower().

In addition, strings.EqualFold() never causes an allocation.

This patch replaces case-insensitive string comparisons that use
strings.ToLower() with a strings.EqualFold() call.
2020-05-18 19:46:59 -04:00
Ayan George b7d3d21313
refactor(http): replace string(w.Body.Bytes()) with w.Body.String() (#18143)
Instead of type converting the Body.Bytes() to a string, we can simply
call Body.String().

While we're at it, this patch also uses a simple string comparison
instead of cmp.Equal() for two strings.

According to the docs, they're equivalent.
2020-05-18 17:31:15 -04:00
Ayan George 3b9be0145c
fix: address static check warning s1039 (#18135)
This commit quiets staticcheck's warnings about "unnecessary use of
fmt.Sprintf" and "unnecessary use of fmt.Sprint".

Prior to this commit we were wrapping simple constant strings without
any formatting verbs with fmt.Sprintf().
2020-05-18 13:55:05 -04:00
Stuart Carnie 8843a01ebf
fix(httpd): Fixes key collisions when serializing /debug/vars 2020-05-07 11:49:59 -07:00
Ayan George f51709f09c
refactor(http): Simplify Authorizer (#17704)
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-04-15 12:59:52 +00:00
David Norton f78b2aa24b
Merge pull request #17638 from influxdata/dn-fix-v2-write-precision
fix: verify precision parameter in write requests
2020-04-07 12:32:57 -04:00
David Norton 129a78ea08 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 11:29:53 -04:00
Ayan George 2f1344ffd7
fix(snapshotter): properly read payload (#17495)
This is a fix and a bit of a refactor of Service.readRequest().

This commit changes the signature so that it accepts an io.Reader
instead of a net.Conn because there's nothing about the function that
relies on it being a Conn; only a Reader.

We also changed the signature so that it returns a *Request instead of
Request -- this way we don't allocate an entire Request value on error.

This commit also attempts to document the few edge cases that the function has to
handle and one quirk where we expect to read a newline which isn't
accounted for by Request.UploadSize.
2020-03-31 12:19:25 -04: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
Dilan Bellinghoven fa7cafea41
Fixed issue where nil reads.ResultSet.Close() is called resulting in a panic 2018-12-19 15:45:12 -05:00
David Norton 8575378ae8 fix #10110: limit db & rp name length to 255 2018-12-17 16:58:28 -05:00
Stuart Carnie 39a3d2335e chore(flux): Update to Flux 0.7.1
Resolve breaking API changes
2018-11-30 10:38:56 -07:00
Stuart Carnie a52f96e03d feat(storage): Export GetReadSource API for Enterprise reuse 2018-11-21 15:51:52 -07:00
Stuart Carnie 369bc8cf29 feat(flux): Optional query parameter to limit Flux query to single node 2018-11-21 15:51:52 -07:00
Stuart Carnie b075de6c96 fix(storage): Fix go:generate line to refer to correct proto file
Closes #10473
2018-11-12 14:12:09 -08:00
Stuart Carnie 7e0be6fbaf fix(flux): Fix empty results when using _value in filter expression
Closes #10471
2018-11-12 11:00:45 -08:00
Stuart Carnie 6affa7c7f5 chore(flux): Remove Flux gRPC handler and update config.sample.toml 2018-11-05 14:26:37 -07:00
Jonathan A. Sternberg f436046b31
Merge pull request #9509 from influxdata/js-http-logging-levels
Add an access log filter for the access log
2018-11-05 12:08:09 -06:00
Jonathan A. Sternberg b3472a54ee
Add an access log filter for the access log
The access log filter allows the access log to be filtered by a status
code pattern. The pattern is a list of strings of the form `NXX`. At
least one number must be specified and up to 2 Xs can be used. That
means the filter can be an exact status code or it can be a range of
them. For example, `500` would only match the 500 http status code while
`5XX` would match any status code beginning with the number 5
(categorized as server errors). The pattern `50X` would also be
accepted. Both uppercase and lowercase Xs are allowed.

Multiple filters can be specified and the log line will be printed if
one of them matches. If there are no filters specified, all status codes
are printed.
2018-11-05 11:46:26 -06:00
Stuart Carnie 5bcb952b6f chore(cli): Improve APIs to increase reuse in Enterprise 2018-11-02 09:16:42 -07:00
Stuart Carnie 7511e46b34 chore(httpd): Update unit tests to verify 403 status response 2018-10-30 13:14:59 -07:00
Stuart Carnie f6426f269d feat(httpd): Return 403 Forbidden when Flux API is disabled 2018-10-30 13:14:59 -07:00
Stuart Carnie 04975c46ef fix(storage): Fix when filtering by _value, which would exclude all data
* The `Value` function must return a `string`, however `SeriesTags#Get`
  returns `[]byte`, resulting in the reduced expression always becoming
  `false`.

* Also added a specific case for the `$` key, which refers to `_value`
  in a Flux predicate. This will always return no value.
2018-10-25 15:57:05 -07:00
Stuart Carnie c5ec3a3244 feat(influx): Add Flux support, enabled by specifying -type=flux 2018-10-25 11:12:14 -07:00
Shobhit Gupta 9061245d77 Fix golint warnings 2018-10-23 18:19:52 -07:00
Shobhit Gupta b36353b5ae Update comment 2018-10-23 14:30:24 -07:00
Shobhit Gupta ea8182dee7 Fix linting warnings for snapshotter package 2018-10-23 14:23:47 -07:00
Stuart Carnie 691dfb8bc1 chore(httpd): Add basic Flux query tests
* added flux handler mocks
* test JSON and application/vnd.flux content-type
* basic errors
2018-10-23 10:01:31 -07:00
Stuart Carnie e1230802fb chore(httpd): Define interface for controller, for testing purposes 2018-10-23 10:01:31 -07:00
Stuart Carnie cf220c6471 feat(httpd): Add Flux query metrics
* debug/vars InfluxDB metrics
* append Prometheus metrics to default registry
2018-10-23 10:01:31 -07:00
Stuart Carnie a4dc81902a feat(httpd): Add config to specify availability of the Flux query API 2018-10-23 10:01:31 -07:00
Stuart Carnie 39011702e3 fix(httpd): Update flux API from /v2/query → /api/v2/query 2018-10-23 10:01:31 -07:00
Stuart Carnie b4fed53a68 feat(flux): Update platform / flux packages and implement from source 2018-10-12 07:40:46 -07:00
Jeff Wendling 70ca87ba60 Fix measurement filtering for flux queries
We rewrite queries for _measurement to _name, but we didn't also
rewrite _m. During some of the code sharing, it started being the
case that it received _m instead of _measurement. Additionally,
we need to start mapping _f to _field for the same reason.
2018-10-10 15:00:08 -06:00
Jeff Wendling 69dc031a75 Use platform for most of the read service code
This commit deletes most of the code to service reads from influxdb
and pulls it in from platform instead.

Of note, the models.Tag and models.Tags types are now aliases to the
platform models.Tag and models.Tags types. Additionally, many types
in the tsdb package relating to cursors are also aliases to the same
types in the platform cursors package.

This updates the platform and flux repos to the current master in the
Gopkg.lock.
2018-10-10 11:20:25 -06:00
ludweeg 5622355526 Simplify s[:] to s where s is a slice 2018-10-04 17:10:21 +03:00
Ryan Coleman 76fe3f081c
Changes /ping route to return status code 200 instead of 204 when verbose is set
Closes #9772.
2018-10-02 09:11:55 -05:00
Stuart Carnie 68e5807c82 fix(storage): Set the Type field to Tag
Transforming an RPC predicate to InfluxQL should set the Type field
to Tag, as it is explicitly set as a tag in the protobuf predicate
2018-09-25 16:58:57 -07:00
Edd Robinson 8d679cf0c3
Merge pull request #10265 from influxdata/er-go1.11
Update to Go 1.11
2018-09-21 12:04:57 -07:00
Stuart Carnie 62b9791da8 feat(flux): Add initial support for executing Flux queries 2018-09-17 22:38:27 -07:00
Tim Brooks 343ce42238 Fix #10261 ABS(int64)
Added inline bit-shift absolute value for int64 type as per:
http://cavaliercoder.com/blog/optimized-abs-for-int64-in-go.html
Updated implementations in Iterator and the continuous query service
2018-09-11 21:53:44 +01:00
Edd Robinson 18cb95f858 Update Go to 1.11 2018-09-06 16:40:20 +01:00
Stuart Carnie badc1d8ed3 fix(storage): Fix potential panic if nil is returned 2018-08-24 15:05:48 -07:00
Stuart Carnie 59bd822af9 refactor(storage): Export subset of APIs to facilitate reuse
* the protocol service definition, ReadRequest and ReadResponse is
  reused across projects, rather than requiring redefinition.

* the ReadRequest protocol buffer definition removes the concept of a
  database and retention policy, replacing it with a field named
  ReadSource of type google.protobuf.Any. OSS requests will use the
  ReadSource message structure defined in local to this package, which
  defines fields to represent a Database and RetentionPolicy. Other
  implementations can provide their own data structure allowing the
  remainder of the ReadRequest to be reused.

* The RPC service and Store are expected to be redefined to handle their
  specific requirements for resolving a ReadSource

* ResultSet and GroupResultSet are interfaces representing non-grouping
  and grouping read behavior respectively. Calling NewResultSet or
  NewGroupResultSet will construct instances of these types

* The ResponseWriter type is exported to deal with serialization of
  the ResultSet and GroupResultSet types
2018-08-24 11:56:04 -07:00
Stuart Carnie 2f4fcd8255 chore: Remove BatchCursor references 2018-08-24 11:56:04 -07:00
Edd Robinson ca1b780906
Merge pull request #10213 from influxdata/er-test-go1.11
Test InfluxDB on Go 1.11rc1
2018-08-21 18:19:25 +01:00
Edd Robinson 663566e3e0 Ensure go fmt passes on 1.10/11 2018-08-21 17:39:42 +01:00
Tanya Gordeeva 9d711d9417 httpd/meta: use open auth when unrestricted
This changes adds additional auth shortcutting, primarily for enterprise
usecases with simple FGA setups. OSS users won't see any changes.
2018-08-20 12:55:40 -07:00
Edd Robinson 9eece563b1 Simplify loops 2018-08-05 15:16:33 +01:00
Jeff Wendling 767b991089 implement using tls configuration 2018-08-02 14:29:07 -06:00
Stuart Carnie 468497c11f fix(storage): Check for Array cursor types 2018-07-18 12:43:53 -07:00
Edd Robinson f03101e660 PR feedback 2018-07-18 12:29:03 +01:00
Edd Robinson afa581ea08 Testing 2018-07-18 12:21:54 +01:00