Commit Graph

180 Commits

Author SHA1 Message Date
Kyle Brandt
674144c8e8
Prometheus: Update FrameType and make __name__ the field name (#62694)
These changes would make the response more in line with the dataplane contract, changes are under the feature toggle prometheusDataplane
2023-03-29 11:26:32 -04:00
Arve Knudsen
f7ee42d871
Prometheus: Reduce memory allocations in QueryData.processExemplars (#63373)
* tsdb/prometheus/querydata: Reduce memory allocations in QueryData.processExemplars

---------

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2023-03-22 10:59:39 +01:00
Kristin Laemmert
8745d7ef1b
extract kindsys to external library (#64562)
* extract kindsys

* reinstate kindsys report

This may end up living somewhere else (or not! who knows!), but the important part is that I don't get rid of it right now :)

I hate the package layout (kindsysreport/codegen) for the main function and will take pretty much any alternative suggestion, but we can change also change it later.

Note that the generated report.json is in a different location - anything using this (ops something) needs to be updated.

* kindsysreport in codeowners
2023-03-15 12:04:28 -04:00
ismail simsek
68b588b912
Prometheus schematization (#63878)
* Schematize prometheus

* revert changes

* close response body

* Update report.json

* Update pkg/tsdb/prometheus/models/query.go

Co-authored-by: sam boyer <sdboyer@grafana.com>

* Use without pointers

* remove unused

* Specify query format

* Rename

* Clean up schema

* Update public/app/plugins/datasource/prometheus/dataquery.cue

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>

* Update pkg/tsdb/prometheus/models/query.go

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>

* Clean up tests

* Update public/app/plugins/datasource/prometheus/dataquery.cue

Co-authored-by: sam boyer <sdboyer@grafana.com>

* make gen-cue

* Add comments

* Make linter happy

* Remove editormode override

* Update

---------

Co-authored-by: sam boyer <sdboyer@grafana.com>
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2023-03-09 11:26:15 +01:00
Sofia Papagiannaki
e643437ee6
Prometheus: Fix panic-ing when closing response body (#63895)
Prometheus: Fix panicing when closing response body
2023-02-28 13:08:01 -05:00
Emil Tullstedt
3abaf32cf2
Chore: Upgrade golangci-lint to v1.51.2 (#63630)
Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
2023-02-23 15:10:03 +01:00
Kyle Brandt
52ed297ed5
Backend: Use latest plugin-sdk-go v0.149.1 (#63498)
Use latest github.com/grafana/grafana-plugin-sdk-go which includes changes to the TypeVersion property (always present in JSON).

Also included is squtil changes: SQL util - allow using the database scan type for converters
2023-02-21 09:06:15 -05:00
Sergey Kostrukov
2f218ab928
Azure: Update Grafana Azure SDK and middleware (#62050)
* Update middleware

* Update Grafana Azure SDK

* Client options to client builder

* Fix tests

* maputil from SDK
2023-02-02 16:58:10 +00:00
ismail simsek
49258b135a
Prometheus: Refactor error handling logic (#62254)
* Refactor error handling logic
- Enable query inspector to show error information
- Update naming

* Change fetch method return signature

* update the snapshot

* Revert "update the snapshot"

This reverts commit 28b26ce426.
2023-01-31 19:26:45 +01:00
Serge Zaitsev
f8ec35e643
Chore: Fix goimports grouping (#62427)
* fix goimports order

* fix goimports order
2023-01-30 09:38:51 +01:00
Kyle Brandt
5bb38293d2
SSE/Prom: Undo empty frame change that triggers 500s in SSE (#61871)
added in https://github.com/grafana/grafana/pull/61643
2023-01-20 17:32:14 +00:00
ismail simsek
29c8ce12a0
Prometheus: Fix handling errors in streaming client (#61643)
* Return errors from data parsing

* Better error handling

* Fix the tests

* When there is no frame add empty frame to get metadata attached to it

* Fix tests

* Update testdata
2023-01-18 22:30:15 +01:00
Christian Simon
a1f2d0e205
Prometheus: Reduce allocations parsing exemplars (#58959)
* Prometheus: Reduce allocations parsing exemplars

This reduces allocations for parsing exemplars.

name            old time/op    new time/op    delta
ExemplarJson-8    24.7ms ±15%    17.6ms ± 2%  -28.72%  (p=0.008 n=5+5)

name            old alloc/op   new alloc/op   delta
ExemplarJson-8    4.70MB ± 0%    3.58MB ± 0%  -23.79%  (p=0.008 n=5+5)

name            old allocs/op  new allocs/op  delta
ExemplarJson-8     72.6k ± 0%     69.1k ± 0%   -4.81%  (p=0.008 n=5+5)

* Ensure pairs is reset
2023-01-18 16:42:22 +01:00
KonH
4421b31b66
Loki/Prometheus: Change signature - return non-reference from ReadPrometheusStyleResult (#57209)
* Change signature - return non-reference from ReadPrometheusStyleResult

Related to https://github.com/grafana/grafana/issues/52430

* Fix invalid reference usage

* Potential fix for test data

* Remove additional ref usage

* Revert "Potential fix for test data"

This reverts commit 94ed588ab3.

* Commit changed test data

* Revert unwanted conflict resolution

* Add additional condition to track empty responses

* Setup valid empty response

* Re-introduce changes reverted by merge
2023-01-13 09:00:39 +01:00
Todd Treece
19ca93d5ce
Prometheus: Fix concurrency issue with exemplar sampler initialization (#61281) 2023-01-11 08:27:47 -05:00
Todd Treece
73d5aa4878
Prometheus: Refactor exemplar sampler (#60278) 2022-12-30 13:04:35 -05:00
ismail simsek
15d32546ea
Prometheus: Fix Instant query time calculation (#60815)
* Use single point in time instead of doing time range calculation

* Comment update
2022-12-29 16:32:08 +01:00
Marcus Efraimsson
c35c689a96
Plugins: Automatically forward plugin request HTTP headers in outgoing HTTP requests (#60417)
Automatically forward core plugin request HTTP headers in outgoing HTTP requests. 
Core datasource plugin authors don't have to specifically handle forwarding of HTTP 
headers, e.g. do not have to "hardcode" the header-names in the datasource plugin, 
if not having custom needs.

Fixes #57065
2022-12-21 13:25:58 +01:00
Ludovic Viaud
f67b8fe0dc
Prometheus: Create feature flag to disable exemplar sampling (#60105)
:Fix rebase
2022-12-19 16:00:15 +01:00
Fionera
055c3b7332
Prometheus: Add POST support to client (#60243)
* Prometheus: Add POST support to client

* Prometheus: Revert client test change from 1c503908
2022-12-16 11:15:19 +01:00
Giuseppe Guerra
92c01e416e
Prometheus: Fix X-Id-Token and X-ID-Token sent to Prometheus in query requests (#60342)
* Prometheus: Use Set rather than map assignment in sdkHeaderToHttpHeader
Fixes #59940

* Prometheus: Add TestPrometheusCanonicalHeaders
2022-12-15 17:18:38 +01:00
ismail simsek
5424ec4157
Prometheus: Remove buffered client and feature toggle related to it (#59898)
* Remove prometheus buffered client and feature toggle related to it

* Remove redundant pieces

* Clean the integration test
2022-12-12 18:05:55 +01:00
Marcus Efraimsson
7bf7308ea5
Plugins: Remove connection/hop-by-hop request/response headers for call resource (#60077)
Removes request/response connection/hop headers for call resource in similar 
manner as Go's reverse proxy functions. Also removes Prometheus datasource 
custom call resource header manipulation in regards to hop-by-hop headers.

Fixes #60076
Ref #58646

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2022-12-12 10:27:53 +01:00
Kyle Brandt
4e0f95dc31
Chore: Update SDK to v0.145.0 with TimeSeriesMulti Constant (#59729) 2022-12-05 12:48:10 -05:00
Denis Limarev
4d8287b319
Performance: add preallocation for some slice/map (#57860)
This change preallocates slices and maps where the size of the data is known before the object is created.

Co-authored-by: Joe Blubaugh <joe.blubaugh@grafana.com>
2022-11-22 20:24:36 +08:00
ismail simsek
1c5039085b
Prometheus: Make Prometheus streaming parser as default client (#58365)
* Introduce a new feature flag for prometheus buffered client

* Use querydata client as default and put buffered client behind the feature flag

* Remove prometheusStreamingJSONParser feature flag as it is not needed anymore

* Update tests

* Fix unit tests

* Update feature flag description
2022-11-11 17:53:12 +01:00
ismail simsek
8edeb1aa22
Prometheus: Handle errors in buffered client (#58504)
* Handle prometheus errors in buffered client

* Handle prometheus warnings

* Fix tests

* Add unit test for warnings
2022-11-11 15:49:46 +01:00
ismail simsek
93c1fbbe3f
Remove data comparison tool and feature flag (#58196) 2022-11-07 19:20:00 +01:00
ismail simsek
0367f61bb3
Share azureauth between prometheus clients (#58122)
* Move azureauth to upper package

* Refactor http transport options
2022-11-03 19:44:37 +01:00
Giuseppe Guerra
7996a1c8ad
Chore: Update grafana-plugin-sdk-go to v0.142.0 (#58115)
* Chore: Update grafana-plugin-sdk-go to v0.142.0

* Update tests and golden files for 207 status code

* Chore: Move update flag definition at the top in response_parser_test.go

* retrigger

Co-authored-by: Will Browne <will.browne@grafana.com>
2022-11-03 18:34:27 +01:00
Yuriy Tseretyan
fa043efb2c
Fix: correctly close trace span in Prometheus and Loki data sources (#57774)
* rename span for loki
2022-10-28 10:17:56 -04:00
Kyle Brandt
6126f56ef0
Prometheus: Do not drop errors in streaming parser (#57698)
- Fixes #57692
- and also takes care of #42776 when using the streaming parser, not an ideal fix for #42776 but makes explore work better I think. https://github.com/grafana/grafana/issues/57365 might be a better longer term solution
2022-10-28 10:11:06 -04:00
Kyle Brandt
2cd9cbd359
Prometheus: Chore - Remove incorrect FrameType from exemplar frame (#57695) 2022-10-28 09:15:01 -04:00
Yuriy Tseretyan
facf2b1ee8
Chore: Update prometheus, loki, graphite and influx plugins to support contextual logs. (#57708) 2022-10-27 12:05:06 -04:00
Galen Kistler
f93c3acc51
Prometheus: Flavor/version configuration (#57554)
* Revert "Revert "Prometheus: Type and flavor configuration (#56496)" (#57552)"
This reverts commit 2432ce619a.
* Adds new fields and documentation for Prometheus datasource configuration: prometheus type, and version
2022-10-24 14:53:11 -05:00
Galen Kistler
2432ce619a
Revert "Prometheus: Type and flavor configuration (#56496)" (#57552)
This reverts commit 7ecbc98b3e.
2022-10-24 12:33:11 -05:00
Galen Kistler
7ecbc98b3e
Prometheus: Type and flavor configuration (#56496)
* Adding two new fields to the data JSON in the prometheus datasource configuration: prometheusType, and prometheusVersion.
* Version field will attempt to auto-detect via buildinfo API when prometheus Type is selected
2022-10-24 09:26:32 -05:00
Todd Treece
152c7f149a
Prometheus: Add Exemplar sampling for streaming parser (#56049) 2022-10-04 08:40:01 -04:00
Todd Treece
1c61c81dde
Prometheus: Various buffered and streaming parsing fixes (#55941) 2022-10-03 10:26:54 -04:00
Kyle Brandt
27288276a2
Prometheus: Restore FromAlert header (#55255)
This restores the FromAlert header to prometheus for Grafana managed alert Queries. 

It does this by reverting "Prometheus: Remove middleware for custom headers (#51518)" , but also changing it so it is only the FromAlert header.

This reverts commit 2372501368.
2022-09-22 11:03:13 -04:00
Andreas Gerstmayr
2c622b912a
Prometheus: Fix integer overflow in rate interval calculation (#52051)
Affecting only 32-bit architectures.
2022-09-13 12:51:26 +02:00
Emil Tullstedt
b287047052
Chore: Upgrade Go to 1.19.1 (#54902)
* WIP

* Set public_suffix to a pre Ruby 2.6 version

* we don't need to install python

* Stretch->Buster

* Bump versions in lib.star

* Manually update linter

Sort of messy, but the .mod-file need to contain all dependencies that
use 1.16+ features, otherwise they're assumed to be compiled with
-lang=go1.16 and cannot access generics et al.

Bingo doesn't seem to understand that, but it's possible to manually
update things to get Bingo happy.

* undo reformatting

* Various lint improvements

* More from the linter

* goimports -w ./pkg/

* Disable gocritic

* Add/modify linter exceptions

* lint + flatten nested list

Go 1.19 doesn't support nested lists, and there wasn't an obvious workaround.
https://go.dev/doc/comment#lists
2022-09-12 12:03:49 +02:00
Andres Martinez Gotor
a31d96d20a
Prometheus: Promote Azure auth flag to configuration (#53447) 2022-08-11 16:12:57 +02:00
Jo
062d255124
Handle ioutil deprecations (#53526)
* replace ioutil.ReadFile -> os.ReadFile

* replace ioutil.ReadAll -> io.ReadAll

* replace ioutil.TempFile -> os.CreateTemp

* replace ioutil.NopCloser -> io.NopCloser

* replace ioutil.WriteFile -> os.WriteFile

* replace ioutil.TempDir -> os.MkdirTemp

* replace ioutil.Discard -> io.Discard
2022-08-10 15:37:51 +02:00
Andrej Ocenas
d0e548c3e5
Prometheus: Add flag to compare streaming and buffered responses (#51711)
* Add flag to compare streaming and buffered

* Move log

* Fix lint

* Fix tests

* Remove debug logs
2022-07-28 14:26:51 +02:00
Andrej Ocenas
bf334ab777
Prometheus: Small improvements to the custom client (#51709)
* Add suggestions

* Fix tests
2022-07-04 22:55:07 +02:00
Andrej Ocenas
3df34fe064
Prometheus: Remove cache, pass headers in request, simplify client creation for resource calls and custom client (#51436)
* Remove cache, pass headers in request, simplify client creation

* Add test for http options creation
2022-07-04 11:18:45 +02:00
Andreas Gerstmayr
040cc5021c
Prometheus: Fix integer overflow in rate interval calculation on 32-bit architectures (#51508) 2022-06-30 11:06:47 +02:00
Andrej Ocenas
2372501368
Prometheus: Remove middleware for custom headers (#51518) 2022-06-29 11:04:57 +02:00
Dan Keder
9595fd6b66
Prometheus: Support 1ms resolution intervals (#44707)
* Prometheus: Support 1ms resolution in time ranges

* UI: Support 1ms resolution in time ranges
2022-06-29 07:39:50 +02:00