Unlike dashboard queries, alerting queries were not correctly applying
custom headers to datasource queries. This change mimics the dashboard
query code to apply custom headers.
Fixes#44460
Signed-off-by: Joe Blubaugh <joe.blubaugh@grafana.com>
* Elasticsearch: Remove support for versions after their EOL
* Update docs
* Remove old versions from config
* Update pkg/tsdb/elasticsearch/elasticsearch.go
Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
* Fix tests
* Fix typecheck errors
Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
* converter: remove __name__ customization because Loki does not do that
Loki does not handle __name__ in a special way.
for Prometheus, the caller can implement the formatting
by themselves
* converter: change labels-formatting
the labels.String() method does not handle strange values well
* loki: backend: use streaming-json parser
* more idiomatic code
Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>
* simpler row-length check
* simpler code
* fixed converter/prom tests
Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>
* converter: remove __name__ customization because Loki does not do that
Loki does not handle __name__ in a special way.
for Prometheus, the caller can implement the formatting
by themselves
* converter: change labels-formatting
the labels.String() method does not handle strange values well
* loki: backend: use streaming-json parser
* more idiomatic code
Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>
* simpler row-length check
* simpler code
Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>
* Allow dimension operator selection
- Add dimension operators and function to update the operator in the query
- Add logic to ensure the same dimension cannot be selected multiple times (Azure restriction)
- Add selection component
* Update backend logic to default operation and filter to eq '*'
- This must be done as the ne and sw operators do not work with the wildcard filter
* Add tests on dimension operators
* Correct placement of 'and' when building query
* Add comment and simplify filtering logic
* Allow multiSelect for eq and ne operators
- Pass PanelData to DimensionFields component
- Add logic to retrieve labels from PanelData
- Add MultiSelect component for relevant operators
- Update frontend types to allow filter to be an array of strings
- Update backend types to allow filter to be an array of strings
- Update filter string building
* Improve setting of labels
* Update go tests
* Update frontend tests
- Add panelData mock (to be expanded later)
- Update null check in DimensionFields
* Allow custom value and set default
* Add frontend test and fix lint issues
* Improved handling of options for sw operator
* Remove changes related to multiselect
* Add check on refId to ensure dimension labels are correct for query
* Extract custom hook for setting dimension labels
* Add documentation around Azure Monitor metrics dimensions
* Update MetricQueryEditor tests
- Add missing data prop
* Correctly set field values
* Add additional expect for onQueryChange
* Correctly set operators
- Simplify onFilterInputChange
* Ensure no duplicate filters appear
* Ensure that filters are displayed correctly for saved queries
* Update dimension filter test
* Include additional test around changing dimension labels
* Pass panel data through new metrics query editor
* loki: backend: better dataframe field names
* loki: backend: add dataframe-type to metric dataframes
* loki: backend: only add stats to the first metric dataframe
* AzureMonitor: build azure portal deep link with resource uri
* extract resource name from the metrics api query
* extract func for getting resource name from metrics url
* add additional valid characters to regex
* wip: Implement kvstore for secrets
* wip: Refactor kvstore for secrets
* wip: Add format key function to secrets kvstore sql
* wip: Add migration for secrets kvstore
* Remove unused Key field from secrets kvstore
* Remove secret values from debug logs
* Integrate unified secrets with datasources
* Fix minor issues and tests for kvstore
* Create test service helper for secret store
* Remove encryption tests from datasources
* Move secret operations after datasources
* Fix datasource proxy tests
* Fix legacy data tests
* Add Name to all delete data source commands
* Implement decryption cache on sql secret store
* Fix minor issue with cache and tests
* Use secret type on secret store datasource operations
* Add comments to make create and update clear
* Rename itemFound variable to isFound
* Improve secret deletion and cache management
* Add base64 encoding to sql secret store
* Move secret retrieval to decrypted values function
* Refactor decrypt secure json data functions
* Fix expr tests
* Fix datasource tests
* Fix plugin proxy tests
* Fix query tests
* Fix metrics api tests
* Remove unused fake secrets service from query tests
* Add rename function to secret store
* Add check for error renaming secret
* Remove bus from tests to fix merge conflicts
* Add background secrets migration to datasources
* Get datasource secure json fields from secrets
* Move migration to secret store
* Revert "Move migration to secret store"
This reverts commit 7c3f872072.
* Add secret service to datasource service on tests
* Fix datasource tests
* Remove merge conflict on wire
* Add ctx to data source http transport on prometheus stats collector
* Add ctx to data source http transport on stats collector test
* loki: add helper function to sort dataframe by time
* loki: add direction-attribute to queries
* loki: make log-row-context code backward-compatible
* better comment
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
* fixed test
* simplified code
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
* chore: remove all remaining uses of golang.org/x/net/context
This PR finishes the work started in #47532, replacing all calls to that package with the stdlib context and using http.NewRequestWithContext to include the context where necessary.
Bonus: small formatting fixes to goimports in these files.
closes#44178
* tweak: use context.Background in favor of TODO for tests
* wip: new metrics query editor
* prepend subscriptions to url path
* remove duplicated setQueryValue file
* add tests for new metrics query editor
* wip start extracting resource field into a shared component
* fix query editor test
* fix up backend tests
* move azure monitor specific getters to azure_monitor_datasource
* use existing useAsyncState hook
* extract useAsyncState into separate file
* add datahooks tests
* extract resource field component
* cleanup
* clarify variable names
* remove logs query specific resource field component
* add url_builder test
* add azure_monitor_datasources tests
* address comments
* add types
* pass resourceUri to resource field component
* add test to check we reset the query fields when changing resources
* CloudWatch: Handle new error codes for MetricInsights
* Changes/test to support case where only the first GetMetricDataOutput returns errors and refactoring
* Fix Potential file inclusion via variable
* Fix gosec 304 by assigning a new variable
* fix goimports issue
* Azure Monitor: allow metrics call to use resource uri
* test case when only resource uri is provided
* remove logs
* Rename json field name from resource to resourceUri
* Group legacy URL builder params test cases
* move comment to the correct position
* Add clarifications in comments
Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
* __unixEpochGroup to support arithmetic argument
Following call generates wrong expression :
$__unixEpochGroupAlias(height+42,$__interval)
=> floor(height+42/60)*60 AS "time"
instead of
=> floor((height+42)/60)*60 AS "time"
* Update test of __unixEpochGroup related to issue #46764
* set missing meta data for distribution type metrics
* add test
* add test
* simplify custom set
* add test for executedQueryString
* add test data
* fix tests
* check group by
* Check type and act accordingly
* Add string type
* Add bool type
* Change method name in test
* Remove comment
* Changed test var names to represent the float case
* Added string test case
* Added bool test case
* Update response in test
* Change string val
* Fix frame meta missing in tests
* Fixed test parse query
* Fixed out of bounds test
* parseFloatSeries
* parseStringSeries and parseBoolSeries
* Formatting
* Use multi frames for now
* strings.ToLower for time col check
* Move timeField out of if checks
* Trying out json formatting of azure graph err from frontend
* Added some tests wip
* Wrap text in popper tooltip
* fix conflict
* Wrap text in tooltip
* Complete tests
* Added invalid json test
* Backend changes and tests
* removed comments
* Added split of message / json and edge cases tests
* Addressed comments
* moved catch to parseErrorMessage
* Legend editor is working
* It's working
* Progress on auto legend mode
* Fixes
* added unit tests
* Added go tests
* Fixing tests
* Fix issue with timing and internal state
* Update public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryCodeEditor.tsx
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
* Send metricFindQuery to backend
* Added feature toggle
* Changed flag name
* metricFindQuery backend
* Added test for metricFindQuery backend parse
* Added test for show tag values
* Test for metricFindQueries
* Updated tests
* Put back comment
* Case insensitive in transformRows
* Check length ov value pair
* Sep tests
* Updated valuePair index
* InfluxDB backend migration
* Multiple queries and more
* Added types
* Updated preferredVisualisationType
* Updated model parser test to include limit,slimit,orderByTime
* Added test for building query with limit, slimit
* Added test for building query with limit, slimit, orderByTime and puts them in the correct order
* Add test: Influxdb response parser should parse two responses with different refIDs
* Moved methods to responds parser
* Add test to ensure ExecutedQueryString is populated
* Move functions out of response parser class
* Test for getSelectedParams
* Merge cases
* Change to const
* Test get table columns correctly
* Removed unecessary fields
* Test get table rows correctly
* Removed getSeries function
* Added test for preferredVisualisationType
* Added test for executedQueryString
* Modified response parser
* Removed test
* Improvements
* Tests
* Review changes
* Feature flag rename and code gen
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
* checks for empty URLs added
* check for TimeSeriesTypeNot to fix InfluxDB alerts
* log a warning when a data frame is ignored
* fix: add brittle Prometheus URL input selector
needs a proper aria-label or test-data-id selector
* test: add URL input aria-label
needs to use the grafana/e2e-selectors package
* test: run ci
* add URL validation for specific data sources, e2e tests
* Update pkg/api/datasource/validation.go
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
* delete duplicated logs
* delete unnecessary leading newline
Co-authored-by: gillesdemey <gilles.de.mey@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
* 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>
* AccessControl: POC scope attribute resolution
Refactor based on ScopeMutators
test errors and calls to cache
Add comments to tests
Rename logger
Create keywordMutator only once
* AccessControl: Add AttributeScopeResolver registration
Co-authored-by: gamab <gabriel.mabille@grafana.com>
* AccessControl: Add AttributeScopeResolver to datasources
Co-authored-by: gamab <gabriel.mabille@grafana.com>
* Test evaluation with translation
* fix imports
* AccessControl: Test attribute resolver
* Fix trailing white space
* Make ScopeResolver public for enterprise redefine
* Handle wildcard
Co-authored-by: Jguer <joao.guerreiro@grafana.com>
Co-authored-by: jguer <joao.guerreiro@grafana.com>
* Use integers for time range filter
Previously it was passed as a string which is automatically converted by Elastic to a number only if the field type is "date". For other types (e.g. "long") such conversion doesn't work. In theory "date" could be passed as a formatted string but we don't use it this way and always pass it as a number so it is safe to always pass numbers, not strings.
* Fix time_series_query_test
* Retrigger build
* Name fields based on targets length
* Remove rounding in rate interval variable replacing
* Refactor and fix edge case when interval and time duration would be rate interval
* Add tests
* Remove , from test
* Revert "Name fields based on targets length"
This reverts commit 5dcb34a765.
* add support for code editor and builder
* refactor cloudwatch migration
* Add tooltip to editor field (#56)
* add tooltip
* add old tooltips
* Bug bash feedback fixes (#58)
* make ASC the default option
* update sql preview whenever sql changes
* don't allow queries without aggregation
* set default value for aggregation
* use new input field
* cleanup
* pr feedback
* prevent unnecessary rerenders
* use frame error instead of main error
* remove not used snapshot
* Use dimension filter in schema picker (#63)
* use dimension key filter in group by and schema labels
* add dimension filter also to code editor
* add tests
* fix build error
* fix strict error
* remove debug code
* fix annotation editor (#64)
* fix annotation editor
* fix broken test
* revert annotation backend change
* PR feedback (#67)
* pr feedback
* removed dimension filter from group by
* add spacing between common fields and rest
* do not generate deep link for metric queries (#70)
* update docs (#69)
Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>
* fix lint problem caused by merge conflict
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
* Change the regex to allow to specified other connection attribute for MSSQL connection like ApplicationIntent property
* Docs update
* docs update
* some tests added
* formatting
* Change the regex to allow to specified other connection attribute for MSSQL connection like ApplicationIntent property
* Docs update
* docs update
* some tests added
* formatting
* docs and formatting
Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
Get rid of using legacydata.RequestHandler in HTTPServer, /api/tsdb/query and pkg/expr
with the goal of deprecating /api/tsdb/query and remove it completely eventually. This is
the first step of cleaning up the HTTP API query endpoint.
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
* 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>