Commit Graph

92 Commits

Author SHA1 Message Date
Travis Patterson
c4c05a5b71
refactor promethueus package into sub packages (#43634) 2022-01-04 07:22:33 -07:00
Gábor Farkas
1879a6855e
prometheus: respect the http-method data source setting (#42753)
* prometheus: respect the http-method data source setting

* removed forgotten if-true section

* refactored json-check
2021-12-20 11:27:18 +01:00
Will Browne
e4ba5f17dd
add core plugins thru store (#43085) 2021-12-14 15:22:40 +01:00
Ivana Huckova
2655be61b6
Prometheus: Interpolate curly brackets syntax variable (#42927) 2021-12-09 14:37:24 +01:00
Ivana Huckova
21fe78302b
Prometheus: Fix passing of custom params when running queries (#42728)
* Prometheus: Fix passing of custom params

* Remove prints
2021-12-03 16:28:05 +01:00
Ivana Huckova
0b5d7067f9
Prometheus: Fix range variables interpolation for time ranges smaller than 1 second (#42242)
* Prometheus: Fix precision for queries with < 1s timeRange

* Update pkg/tsdb/prometheus/time_series_query.go

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
2021-11-29 12:41:23 +01:00
Ivana Huckova
9b9e41e036
Prometheus: Disable exemplar queries for alerting (#41607)
* Prometheus: Dont include empty exempalr frame in results

* Prometheus: Never run exemplar queries for alerting

* Remove exemplar field from alerting and set exemplar to false

* Add tests for frontend

* Add test for backend
2021-11-12 12:49:06 +01:00
Ivana Huckova
2daae9eba8
Prometheus: Fix showing of errors (#41356)
* Prometheus: Fix showing of errors

* Refactor and add comment
2021-11-05 18:00:48 +01:00
Will Browne
2faf3b6a31
rearrange log statements for log15 (#41137) 2021-11-02 10:20:17 +01:00
Will Browne
b80fbe03f0
Plugins: Refactor Plugin Management (#40477)
* add core plugin flow

* add instrumentation

* move func

* remove cruft

* support external backend plugins

* refactor + clean up

* remove comments

* refactor loader

* simplify core plugin path arg

* cleanup loggers

* move signature validator to plugins package

* fix sig packaging

* cleanup plugin model

* remove unnecessary plugin field

* add start+stop for pm

* fix failures

* add decommissioned state

* export fields just to get things flowing

* fix comments

* set static routes

* make image loading idempotent

* merge with backend plugin manager

* re-use funcs

* reorder imports + remove unnecessary interface

* add some TODOs + remove unused func

* remove unused instrumentation func

* simplify client usage

* remove import alias

* re-use backendplugin.Plugin interface

* re order funcs

* improve var name

* fix log statements

* refactor data model

* add logic for dupe check during loading

* cleanup state setting

* refactor loader

* cleanup manager interface

* add rendering flow

* refactor loading + init

* add renderer support

* fix renderer plugin

* reformat imports

* track errors

* fix plugin signature inheritance

* name param in interface

* update func comment

* fix func arg name

* introduce class concept

* remove func

* fix external plugin check

* apply changes from pm-experiment

* fix core plugins

* fix imports

* rename interface

* comment API interface

* add support for testdata plugin

* enable alerting + use correct core plugin contracts

* slim manager API

* fix param name

* fix filter

* support static routes

* fix rendering

* tidy rendering

* get tests compiling

* fix install+uninstall

* start finder test

* add finder test coverage

* start loader tests

* add test for core plugins

* load core + bundled test

* add test for nested plugin loading

* add test files

* clean interface + fix registering some core plugins

* refactoring

* reformat and create sub packages

* simplify core plugin init

* fix ctx cancel scenario

* migrate initializer

* remove Init() funcs

* add test starter

* new logger

* flesh out initializer tests

* refactoring

* remove unused svc

* refactor rendering flow

* fixup loader tests

* add enabled helper func

* fix logger name

* fix data fetchers

* fix case where plugin dir doesn't exist

* improve coverage + move dupe checking to loader

* remove noisy debug logs

* register core plugins automagically

* add support for renderer in catalog

* make private func + fix req validation

* use interface

* re-add check for renderer in catalog

* tidy up from moving to auto reg core plugins

* core plugin registrar

* guards

* copy over core plugins for test infra

* all tests green

* renames

* propagate new interfaces

* kill old manager

* get compiling

* tidy up

* update naming

* refactor manager test + cleanup

* add more cases to finder test

* migrate validator to field

* more coverage

* refactor dupe checking

* add test for plugin class

* add coverage for initializer

* split out rendering

* move

* fixup tests

* fix uss test

* fix frontend settings

* fix grafanads test

* add check when checking sig errors

* fix enabled map

* fixup

* allow manual setup of CM

* rename to cloud-monitoring

* remove TODO

* add installer interface for testing

* loader interface returns

* tests passing

* refactor + add more coverage

* support 'stackdriver'

* fix frontend settings loading

* improve naming based on package name

* small tidy

* refactor test

* fix renderer start

* make cloud-monitoring plugin ID clearer

* add plugin update test

* add integration tests

* don't break all if sig can't be calculated

* add root URL check test

* add more signature verification tests

* update DTO name

* update enabled plugins comment

* update comments

* fix linter

* revert fe naming change

* fix errors endpoint

* reset error code field name

* re-order test to help verify

* assert -> require

* pm check

* add missing entry + re-order

* re-check

* dump icon log

* verify manager contents first

* reformat

* apply PR feedback

* apply style changes

* fix one vs all loading err

* improve log output

* only start when no signature error

* move log

* rework plugin update check

* fix test

* fix multi loading from cfg.PluginSettings

* improve log output #2

* add error abstraction to capture errors without registering a plugin

* add debug log

* add unsigned warning

* e2e test attempt

* fix logger

* set home path

* prevent panic

* alternate

* ugh.. fix home path

* return renderer even if not started

* make renderer plugin managed

* add fallback renderer icon, update renderer badge + prevent changes when renderer is installed

* fix icon loading

* rollback renderer changes

* use correct field

* remove unneccessary block

* remove newline

* remove unused func

* fix bundled plugins base + module fields

* remove unused field since refactor

* add authorizer abstraction

* loader only returns plugins expected to run

* fix multi log output
2021-11-01 10:53:33 +01:00
Ivana Huckova
92cd44940a
Prometheus: Refactor backend for scalability for other query types (#40921)
* Prometheus: Refactor backend for scalability for other query types

* Fix linting
2021-10-26 14:47:40 +02:00
Igor Suleymanov
3f5dcbfdb5
Refactor Prometheus response handling and reduce allocations (#40765)
Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>
2021-10-22 12:34:21 +02:00
Ivana Huckova
ba90b57b66
Prometheus: Transform NaN values from matrix response to null on backend (#40757)
* avoid duplicate allocations

* set labels

* Replace NaN in matrix with null

* Refactor and add test

* Update test

* Append response only if no error

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2021-10-21 15:01:14 +02:00
Ivana Huckova
3718494b35
Prometheus: Send errors from backend in response (#40674)
* Prometheus: Send errors in response

* Remove debugging placeholder

* Add debugging logs
2021-10-20 16:50:34 +02:00
Ivana Huckova
7140867868
Prometheus: Run dashboard queries trough backend (#40333)
* Fix processing for table in dashboard - expolre compatible

* Add processing of histograms

* Interpolsate rate_interval in step field

* Add tests

* Fix function name

* Extract internal range and interval variables to constants

* Fix typings, refactor, simplify

* Fix constant that was missing _ms
2021-10-15 13:37:27 +02:00
Ivana Huckova
48eacd1ea6
Remove unused httpMethod (#40471) 2021-10-14 16:20:06 +02:00
Kevin Minehart
23bee50474
Prometheus: Fix issue where TCP connections not being reused when querying from Grafana alerting (#40349)
Fixes #40366

Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2021-10-13 10:22:26 +02:00
Ivana Huckova
19ad08e6b8
Prometheus: Run exemplars explore queries through backend (#39531)
* Prometheus: Run Explore both queries trough backend

* Refactor, simplify

* Set default values for query type selector

* Run multiple queries as one query trough backend

* Remove trailing newlines

* Pass utcOffset

* Remove trailing comma

* WIP: Implementatioon of exemplars

* add sampling for exemplars

* Refactor to use response as custom metadata

* Simplify processing of exemplars

* Update, clean up

* Refactor the way how we get available exemplars

* Simplify exemplars disabling and running on frontend

* Add tests

* Update toggle

* Remove console log

* Fix go linting

* Fix e2e test

* Trigger Build

* Compare lengts, small fix

* Remove duplicated time check

* Address feedback

* Remove redundant ! as not needed

* Update
2021-10-12 13:16:09 +02:00
Dimitris Sotirakis
d023cabae6
Add Headers to http client Options (#40214) 2021-10-08 16:52:41 +03:00
Ivana Huckova
df81676d9e
Prometheus: Run Explore both queries trough backend (#39462)
* Prometheus: Run Explore both queries trough backend

* Refactor, simplify

* Set default values for query type selector

* Run multiple queries as one query trough backend

* Remove trailing newlines

* Pass utcOffset

* Remove trailing comma

* Add meta to frames only at 1 place

* Set exemplars to falsee if they are disabled

* Revert "Set exemplars to falsee if they are disabled"

This reverts commit e7b697c9f3.
2021-09-29 16:42:31 +02:00
Marcus Efraimsson
45a844e77e
Elasticsearch/Prometheus: Set correct service namespace for SigV4 (#39439)
Makes sure to set the SigV4 service namespace for Elasticsearch and Prometheus.

Fixes #38440
2021-09-27 14:32:19 +02:00
Ivana Huckova
ffdeb4a57a
Prometheus: Run Explore instant queries trough backend (#39351)
* Prometheus: Add running of instant queries trough backend

* Rename response, keep zero length frames

* Remove debug log

* Simplify and fix value text

* Update duplicated and redundant go test

* Update public/app/plugins/datasource/prometheus/datasource.ts

Co-authored-by: Giordano Ricci <me@giordanoricci.com>

* Refactor using model to create Promquery

* Fix the response length

Co-authored-by: Giordano Ricci <me@giordanoricci.com>
2021-09-20 16:05:21 +02:00
Ivana Huckova
81756cd702
Prometheus: Run Explore range queries trough backend (#39133)
* Run Explore range queries trough backend

* Remove trailing comma

* Add timeRange step alignment to backend

* Remove creation of instant query on backend as it is not supported ATM

* Remove non-related frontend changes

* Pass offset to calculate aligned range trough prom query

* Update order in query error message

* tableRefIds shouldn't contain undefined refIds

* Remove cloning of dataframes when processing

* Don't mutate response

* Remove ordering of processed frames

* Remove df because not needed
2021-09-17 13:39:26 +02:00
Ivana Huckova
f172701043
IntervalV2: Use maxDataPoints to calculate correct interval (#39036)
* Use max data points to calculate interval

* Fix mockCalculator to mach Calculator

* Fix incorrect merge, replace queryModel with query
2021-09-13 14:58:32 +02:00
Ivana Huckova
4952f6fc58
Prometheus: Add interpolation for built-in-time variables to backend (#39051)
* Add grafana variable interpolation to backend

* Remove newlines
2021-09-10 22:56:15 +02:00
Giordano Ricci
dc36f15fbb
Prometheus: Revert stepMode functionality (#38982)
* Revert "Prometheus: add functionality to specify desired step interval in dashboards panels (#36422)"

This reverts commit ddf5b65c51.
Co-authored-by: Ivana Huckova <ivana.huckova@gmail.com>

* Revert "Explore: add functionality for supporting different step modes in prometheus (#37829)"

This reverts commit f433cfd8d9.
Co-authored-by: Ivana Huckova <ivana.huckova@gmail.com>

* Revert stepMode BE implementation from #36796
Co-authored-by: "Ivana Huckova" <ivana.huckova@gmail.com>
2021-09-09 14:05:08 +02:00
ying-jeanne
c989f0fbbe
SQL: Migrate to use SDK contracts (#36635)
* convert SQLs to use sdk contracts

* make draft

* postgres

* intermedia

* get datasourceinfo filled at the beginning of the service

* move the interval into package because of cyclict  import and fix all postgres tests

* fix mysql test

* fix mssql

* fix the test for pr https://github.com/grafana/grafana/issues/35839

* fix some issue about intervalv2 package

* update sql test

* wire migration for SQLs

* add sqls to the background process

* make it register instead of register and start

* revert formatting

* fix tests

* fix linter

* remove integration test

* Postgres test fix

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2021-09-07 09:35:37 +02:00
Arve Knudsen
78596a6756
Migrate to Wire for dependency injection (#32289)
Fixes #30144

Co-authored-by: dsotirakis <sotirakis.dim@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
Co-authored-by: spinillos <selenepinillos@gmail.com>
Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: Leonard Gram <leo@xlson.com>
2021-08-25 15:11:22 +02:00
Domas
2e8a7c1161
set basic auth for prometheus backend ds requests (#38496) 2021-08-25 10:05:17 +03:00
Ivana Huckova
74fef637af
Prometheus: Use default POST method if no httpMethod provided (#38446)
* Prometheus: If no httpMethod, use default POST method

* Use http.MethodPost
2021-08-23 15:25:40 +02:00
Gábor Farkas
668f397a8e
Prometheus/Alerting: handle datasource.timeRange is nil case (#37888) 2021-08-16 09:20:58 +02:00
Gábor Farkas
4afa74232f
prometheus: alerting: respect datasource.scrapeInterval (#37799) 2021-08-11 20:34:51 +02:00
Dimitris Sotirakis
27c71a1f09
Prometheus: Migrate to use SDK contracts (#37358)
* Use SDK contracts (test needs fixing)

* Fix tests

* Add customQueryParametersMiddleware

* Fix merge conflicts
2021-08-09 11:11:19 +02:00
Ivana Huckova
1083bef030
Prometheus: Implement stepMode for alerting queries (#36796)
* Add select component for choosing step option

* Add onStepChange

* Add functionality for max step

* Rename minInterval to stepInterval to describe min, max and exact step interval

* Change select option from standard to exact

* Add new type StepType for better type safety

* Add tests for adjustInterval

* Add functionality and tests for exact step option

* Prometheus: Spell out min and max in select component

* Prometheus: Change width of step select component and add placeholder

* Prometheus: Adjust for the factor in exact step

* Prometheus: Update tooltip of step lable to include max and exact options and add padding to select component to give it some breathing room from other components

* Update snapshot for step tooltip

* Prometheus: make tooltip more informative

* Prometheus: add tooltip to interval input element

* Prometheus: extract default step option

* Prometheus: update snapshot for PromQueryEditor

* Prometheus: change step labels to uppercase

* Prometheus: define a default step option

* Prometheus: use default step option in both ui component and logic

* Prometheus: update snapshot for PromQueryEditor

* Prometheus: refactor datasource.ts for better readability

* Prometheus: change tool tip for step

* Prometheus: update snapshots

* Prometheus: add correct styling

* Prometheus: update snapshots

* Prometheus change variable name to something less superfluous

* Prometheus: refactor

* Prometheus: add new test for adjustInterval

* Docs: Update docummentation on the step parameter for prometheus

* Prometheus: make step input field smaller and change placeholder text to 15s

* Prometheus: update snapshots

* Prometheus: Make stepMode uniform in all places in the code

* Adjust step based on stepMode

* Adjust comment

* Check if we have queryInterval

* Refactor, add safe interval

* Fix merge resolutions

* Fix tests and add tests

* Update snapshot

* Update docs/sources/datasources/prometheus.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update docs/sources/datasources/prometheus.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update docs/sources/datasources/prometheus.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update docs/sources/datasources/prometheus.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update docs/sources/datasources/prometheus.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update docs/sources/datasources/prometheus.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update docs/sources/datasources/prometheus.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Implement calculation with intervalMode in calculator.go

* Update tests, add calculate safe interval method

* Replace panic with error

* Update pkg/tsdb/interval/interval_test.go

Co-authored-by: idafurjes <36131195+idafurjes@users.noreply.github.com>

* Update pkg/tsdb/calculator_test.go

Co-authored-by: idafurjes <36131195+idafurjes@users.noreply.github.com>

* Impotrt require

* Remove lint errors

Co-authored-by: Olof Bourghardt <ob655088@gmail.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
Co-authored-by: idafurjes <36131195+idafurjes@users.noreply.github.com>
2021-08-05 09:09:49 +02:00
Marcus Efraimsson
c775708e45
Chore: Refactor Prometheus custom query parameters middleware (#34814)
Following #34473 refactor to use url.ParseQuery in the Prometheus 
custom query parameter middleware.

Ref #34473
2021-06-01 14:59:44 +02:00
Marcus Efraimsson
f76f426da3
Chore: Refactor Prometheus HTTP client middleware (#34473)
Following #33439 this refactors the Prometheus HTTP transport 
which is replaced by HTTP client middleware.
2021-05-27 12:43:21 +02:00
Marcus Efraimsson
348e76fc8e
Datasource: Shared HTTP client provider for core backend data sources and any data source using the data source proxy (#33439)
Uses new httpclient package from grafana-plugin-sdk-go introduced 
via grafana/grafana-plugin-sdk-go#328. 
Replaces the GetHTTPClient, GetTransport, GetTLSConfig methods defined 
on DataSource model.
Longer-term the goal is to migrate core HTTP backend data sources to use the 
SDK contracts and using httpclient.Provider for creating HTTP clients and such.

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2021-05-19 23:53:41 +02:00
Andrej Ocenas
293677a0cb
Prometheus: Add custom query params for alert and exemplars queries (#32440)
* Add configuration for custom query params

* Add custom transport in prometheus

* Move custom query handling to request method

* Add encoding
2021-05-12 19:30:41 +02:00
Ryan McKinley
7627b55ef4
TSDB: add deprecation comments to many tsdb structs (#33281) 2021-04-23 03:03:11 +02:00
Dimitris Sotirakis
2a5279911f
Add legend name to dataframes config (#32356) 2021-03-26 16:20:46 +02:00
Dimitris Sotirakis
2d72b4e69e
Prometheus: Convert Prometheus query response to dataframes (#31948)
* Convert Prometheus query response to dataframes

* Add parseResponse tests

* Fixed lint imports

* Force use UTC as timezone in timeVector

* Updated test to check timezone
2021-03-18 08:40:26 +02:00
Arve Knudsen
b79e61656a
Introduce TSDB service (#31520)
* Introduce TSDB service

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>
Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2021-03-08 07:02:49 +01:00
Emil Hessman
3c1bcc7275
Chore: Rewrite tsdb prometheus test to standard library (#29592)
Signed-off-by: Emil Hessman <emil@hessman.se>
2020-12-04 08:49:39 +01:00
Arve Knudsen
107f658229
prometheus: Improve IsAPIError's documentation (#29432)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-27 12:05:49 +01:00
Will Browne
d10a8b2761
Alerting: Improve Prometheus Alert Rule error message (#29390)
* provide better ctx for prom err

* rework

* Update pkg/tsdb/prometheus/prometheus.go

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Update pkg/tsdb/prometheus/prometheus.go

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* call func

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-26 13:38:36 +01:00
Arve Knudsen
574553ec7b
Chore: Fix issues found by staticcheck (#28802)
* Fix linting issues

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-05 11:29:39 +01:00
Arve Knudsen
41d432b5ae
Chore: Enable whitespace linter (#25903)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-07-06 20:17:28 +02:00
Arve Knudsen
07582a8e85
Chore: Fix various spelling errors in back-end code (#25241)
* Chore: Fix various spelling errors in back-end code
Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>>
2020-06-01 17:11:25 +02:00
Denis
26626d9073
Prometheus: Render missing labels in legend formats as an empty string (#22355)
* Empty value for unknown Prometheus label (grafana#16041)

* Empty value for unknown Prometheus label (grafana#16041)

* fix linter
2020-03-18 19:57:11 +01:00
Marcus Efraimsson
baba1634b8 Plugins: Use grafana-plugin-sdk-go v0.5.0 (#21116)
* fix dispense

* plugin loading refactor

Moves common functionality of registering, starting,
stopping and restarting backend plugins to
backendplugin package.

* simplify plugin descriptors

* target sdk v0.5.0

Co-authored-by: Kyle Brandt <kyle@kbrandt.com>
2020-01-08 11:43:28 -05:00