Commit Graph

105 Commits

Author SHA1 Message Date
Serge Zaitsev
f8ec35e643
Chore: Fix goimports grouping (#62427)
* fix goimports order

* fix goimports order
2023-01-30 09:38:51 +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
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
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
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
Andres Martinez Gotor
a31d96d20a
Prometheus: Promote Azure auth flag to configuration (#53447) 2022-08-11 16:12:57 +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
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
Andrej Ocenas
d20afa2a39
Prometheus: Use contextual middleware for req headers and simplify client creation (#51061)
* Use contextual middleware and simplify client creation

* Fix tests

* Add test for the header propagation

* Fix tests and lint

* Update pkg/tsdb/prometheus/prometheus.go

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

Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>
2022-06-23 14:48:16 +02:00
Stephanie Closson
53ee72d15d
Prometheus: Migrate metadata queries to use resource calls (#49921)
* Sent resource calls for metadata to the backend

* moved resource calls to the backend

* code review feedback

* fixed post with body

* statuscode >= 300

* cleanup

* fixed tests

* fixed datasource tests

* code review feedback

* force some other endpoints to only GET

* fix linting errors

* fixed tests

* was able to remove section of redundant code

* cleanup and code review feedback

* moved query_exemplars to get request

* fixed return on error

* went back to resource calls, but using the backendsrv directly

* moved to a resource call with fallback

* fixed tests

* check for proper messages

* proper check for invalid calls

* code review changes
2022-06-03 15:56:13 -03:00
Todd Treece
94b9c524a8
Prometheus: Streaming JSON parser performance improvements (#48792) 2022-05-24 16:17:11 -04:00
Todd Treece
87e8521591
Prometheus: Implement Streaming JSON Parser (#48477)
use `prometheusStreamingJSONParser` feature toggle to enable
2022-05-13 20:28:54 +02:00
Todd Treece
e1a9ce4cc4
Prometheus: Move existing query logic to new buffered package (#48668) 2022-05-12 05:34:09 -04:00
Sergey Kostrukov
656ade9884
Shared Azure middleware between Azure Monitor and Prometheus datasources (#46002)
* Scopes in Azure middleware

* Enable Azure middleware without feature flag

* Use common Azure middleware in Azure Monitor

* Apply feature flag to JsonData configuration of Azure auth

* Enforce feature flag in Prometheus datasource

* Prometheus provider tests

* Datasource service tests

* Fix http client provider tests

* Pass sdkhttpclient.Options by reference

* Add middleware to httpclient.Options

* Remove dependency on Grafana settings

* Unit-tests updated

* Fix ds_proxy_test

* Fix service_test
2022-04-01 13:26:49 +02:00
Sergey Kostrukov
85ea1a5d64
Prometheus: Fix Azure authentication support (#44407)
Re-adding back Azure authentication support to Prometheus datasource 
after the datasource query logic was rewritten from plugin.json routes to 
Go backend.

Ref #35857
2022-02-03 17:06:31 +01:00
Will Browne
7fbc7d019a
Plugins: Core plugins register via backend factory provider (#43171)
* refactoring store interface and init flow

* fix import

* fix linter

* refactor resource calling

* load with class

* re-order args

* fix tests

* fix linter

* remove old creator

* add custom config struct

* fix some tests

* cleanup

* fix

* tackle plugins

* fix linter

* refactor and fix test

* add connect failure error

* add fix for azure, cloud monitoring and test data

* restructure

* remove unused err

* add fake tracer for test

* fix grafana ds plugin
2022-01-20 18:16:22 +01:00
idafurjes
30aa24a183
Chore: Implement OpenTelemtry in Grafana (#42674)
* Separate Tracer interface to TracerService and Tracer

* Fix lint

* Fix:Make it possible to start spans for both opentracing and opentelemetry in ds proxy

* Add span methods, use span interface for rest of tracing

* Fix logs in tracing

* Fix tests that are related to tracing

* Fix resourcepermissions test

* Fix some tests

* Fix more tests

* Add TracingService to wire cli runner

* Remove GlobalTracer from bus

* Renaming test function

* Remove GlobalTracer from TSDB

* Replace GlobalTracer in api

* Adjust tests to the InitializeForTests func

* Remove GlobalTracer from services

* Remove GlobalTracer

* Remove bus.NewTest

* Remove Tracer interface

* Add InitializeForBus

* Simplify tests

* Clean up tests

* Rename TracerService to Tracer

* Update pkg/middleware/request_tracing.go

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>

* Initialize tracer before passing it to SQLStore initialization in commands

* Remove tests for opentracing

* Set span attributes correctly, remove unnecessary trace initiliazation form test

* Add tracer instance to newSQLStore

* Fix changes due to rebase

* Add modified tracing middleware test

* Fix opentracing implementation tags

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-01-20 11:10:12 +01:00
Travis Patterson
9eb82f9fff
Propagate all headers (#43812)
* Propagate all headers

* stable header order
2022-01-07 12:45:26 -07:00
Travis Patterson
20b3b2a448
Forward oauth tokens after prometheus datasource migration (#43686)
* create the prom client

* implement lru cache of prometheus clients based on auth headers

* linter
2022-01-05 13:55:55 -07:00
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
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