Commit Graph

158 Commits

Author SHA1 Message Date
Andreas Christou
e27cb67776
AzureMonitor: Fix Log Analytics portal links (#65482)
* Fix and update Log Analytics portal links

- Build portal URL in backend
- Correctly set multiple resource value
- Move AddConfigLinks util function
- Add necessary types
- Remove unused functions

* Fix lint issue

* Remove unused cache variable
2023-03-29 19:01:18 +03:00
Ryan McKinley
4b94c7e5d2
Schema: Remove key from root DataQuery type (#64467) 2023-03-08 16:52:31 -05:00
Serge Zaitsev
0bdb105df2
Chore: Remove xorcare/pointer dependency (#63900)
* Chore: remove pointer dependency

* fix type casts

* deprecate xorcare/pointer library in linter

* rooky mistake
2023-03-06 05:23:15 -05:00
Selene
e1350a905f
Chore: Update thema and cuesty v0.1.6 (#63629)
* Update thema and cuesty

* Update thema version

* Update thema again

* update thema

---------

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>
2023-03-01 00:23:57 -05:00
zhichli
3c218d742f
Datasources: Add user_agent header customization for outgoing HTTP requests (#63769) 2023-02-28 14:10:05 +01: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
Selene
7ace44c8b5
Chore: Update oapi-codegen library (#62962)
* Update oapi library and thema

* Use fork commit to fix elasticsearch and cloudwatch generators

* Update thema

* Fixes

* Update thema with last fixes

* Sync

* Fix test

* Update thema and schemas

* Update thema
2023-02-21 12:34:24 +01:00
Andreas Christou
d7f7cd1e61
Schema: Initial Azure Monitor query schema (#62018)
* Initial schema

- Add types based off of current frontend

* Rename and field-level comments

* Update report and regenerate files

* Rename frontend Azure folder

- Doing this for consistency and to ensure code-generation works
- Update betterer results due to file renames

* Remove default and add back enum vals that I deleted

* Set workspace prop as optional

* Replace template variable types

* Connect frontend query types

- Keep properties optional for now to avoid major changes
- Rename AzureMetricResource
- Correctly use ResultFormat

* Add TSVeneer decorator

* Update schema

* Update type

* Update CODEOWNERS

* Fix gen-cue issue

* Fix backend test

* Fix e2e test

* Update code coverage

* Remove references to old Azure Monitor path

* Review

* Regen files
2023-02-03 16:06:54 +00: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
Andres Martinez Gotor
13f8ea2656
Azure Monitor: Return query error for metrics (#62570) 2023-01-31 13:28:35 +01:00
Andres Martinez Gotor
d4e0e75c0c
Azure Monitor: Fix frame display name with multiple resources (#61750) 2023-01-20 12:20:01 +01:00
Andres Martinez Gotor
f6e735cd29
AzureMonitor: Keep resource in the URL for single requests (#61414) 2023-01-13 12:30:45 +01:00
Andres Martinez Gotor
9055e1993d
AzureMonitor: API support for multiple resources (#61315) 2023-01-12 17:25:13 +01:00
Andreas Christou
2e4bc200f5
AzureMonitor: Correctly set filter values in portal URL (#60627)
* Correctly set filter values in portal URL

* Refactor to include dimensions as a part of AzureMonitor query

* Correctly set splitting value in URL

- Add type for dimension filters object

* Update tests

* Don't test dimensions
2022-12-21 16:30:17 +00:00
Andreas Christou
f3f043e097
AzureMonitor: Set Logs portal URL from resource URI (#60583)
Set URL based off of resource URI
2022-12-21 15:46:31 +00:00
Andres Martinez Gotor
733dbe0163
Azure Monitor: Remove references to Germany cloud (#60588) 2022-12-21 11:51:57 +01:00
Andres Martinez Gotor
10cfc27397
AzureMonitor: Update SDK version (#60372) 2022-12-20 16:20:31 +01:00
Andres Martinez Gotor
7db8d031d3
Azure Monitor: Fix health check for empty default subscription (#60569) 2022-12-20 15:32:22 +01:00
Andreas Christou
c81df0dec0
AzureMonitor: Add custom header support to Azure Monitor (#60269)
* Add integration test for Azure Monitor

- Add Azure Monitor to datasource types
- Update instance creation to correctly set HTTP client options
- Combine custom azure headers and custom grafana headers on HTTP client creation
- Update HTTP client tests

* Test custom azure headers
2022-12-14 15:09:11 +00:00
ms-hujia
5010765115
Azure Monitor: Propagate the error when failed to get datasource instance (#60210)
Propagate the error when failed to get instance
2022-12-14 10:36:41 +01:00
Andres Martinez Gotor
a7d4bbf024
AzureMonitor: Fix bad request when setting dimensions (#59700) 2022-12-02 13:17:11 +01:00
Andres Martinez Gotor
231b5b587c
AzureMonitor: Fix panic from empty response in ARG (#59691)
AzureMonitor: Avoid panic from empty response in ARG
2022-12-02 13:14:48 +01:00
Andres Martinez Gotor
276b54fe9d
Azure Monitor: Fix empty/errored responses for Logs variables (#59240) 2022-11-24 11:25:40 +01:00
Andres Martinez Gotor
9d88e14f01
Azure Monitor Logs: Avoid warning when the response is empty (#59211) 2022-11-23 16:15:18 +01:00
Andreas Christou
f8656d269d
AzureMonitor: Separate subscription health check API version (#58253)
Separate subscription health check API version
2022-11-21 13:03:16 +01:00
Yuriy Tseretyan
ff5cc3e640
Chore: Update cloud monitoring and Azure data sources to support contextual logs (#57844)
* update cloud monitoring to use log from context
* update azure monitor to use contextual logger
2022-11-04 09:28:38 -04:00
Andres Martinez Gotor
76868bad04
AzureMonitor: Allow multiple resources in the API for Metrics (#56118) 2022-10-07 14:57:01 +02:00
Andres Martinez Gotor
8594e648e8
Azure Monitor: Adapt empty Logs response (#56378) 2022-10-05 15:29:34 +02:00
ms-hujia
ec024ae960
Azure Monitor: Add support to customized routes (#54829) 2022-10-03 12:33:37 +02:00
Adam Simpson
879ee82b83
AzureMonitor: Fix custom namespaces (#54937) 2022-09-12 12:10:51 +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
Andres Martinez Gotor
43955bdebd
Azure Monitor: Early error if the client secret is not set (#53106) 2022-08-02 16:53:05 +02:00
Andres Martinez Gotor
d66e178b66
Azure Monitor: Append /default to the resource URI if needed (#52884) 2022-07-27 16:49:51 +02:00
Andres Martinez Gotor
7505cf418b
Azure Monitor: Deprecate metricDefinition (#52793) 2022-07-27 15:26:32 +02:00
Kristin Laemmert
945f015770
backend/datasources: move datasources models into the datasources service package (#51267)
* backend/datasources: move datasources models into the datasources service pkg
2022-06-27 12:23:15 -04:00
Andres Martinez Gotor
b10ddfdf8c
AzureMonitor: Parse non-fatal errors for Logs (#51320) 2022-06-24 08:56:58 +02:00
Andreas Christou
ecaa1dcbfd
AzureMonitor: Migrate to backend checkHealth API (#50448)
* Add check health functions for each datasource and generic checkHealth function

* Log backend errors

* Update testDatasource function

- Remove unused testDatasource functions from pseudo datasources

* Switch datasource to extend DataSourceWithBackend

* Improve errors and responses from health endpoint

* Fix backend lint issues

* Remove unneeded frontend tests

* Remove unused/unnecessary datasource methods

* Update types

* Improve message construction

* Stubbing out checkHealth tests

* Update tests

- Remove comments
- Simplify structure

* Update log analytics health check to query data rather than retrieve workspace metadata

* Fix lint issue

* Fix frontend lint issues

* Update pkg/tsdb/azuremonitor/azuremonitor.go

Co-authored-by: Andres Martinez Gotor <andres.martinez@grafana.com>

* Updates based on PR comments

- Don't use deprecated default workspace field
- Handle situation if no workspace is found by notifying user
- Correctly handle health responses

* Remove debug line

* Make use of defined api versions

* Remove field validation functions

* Expose errors in frontend

* Update errors and tests

* Remove instanceSettings

* Update error handling

* Improve error handling and presentation

* Update tests and correctly check error type

* Refactor AzureHealthCheckError and update tests

* Fix lint errors

Co-authored-by: Andres Martinez Gotor <andres.martinez@grafana.com>
2022-06-20 11:33:13 +01:00
Serge Zaitsev
ae9491c3a7
Chore: Make test tracer noop and return no errors (#50797) 2022-06-15 12:40:41 +02:00
Kat Yang
3c3039f5b3
Chore: Remove Wrap (#50048)
* Chore: Remove Wrap and Wrapf

* Fix: Add error check
2022-06-03 09:24:24 +02:00
Andreas Christou
2780651ea8
AzureMonitor: Fix auto-selection of time-grain for metrics. (#49278)
* Update query editor to fix auto time-grain selection

* Update new query editor to fix auto time-grain selection

* Remove log and fix lint issues

* Add test for useMetricMetadata

- Add necessary types

* More test updates

- Update old dataHooks test
- Ensure query changes

Co-authored-by: Kevin Yu <kevinwcyu@users.noreply.github.com>
Co-authored-by: Andres Martinez Gotor <andres.mgotor@gmail.com>
Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>
2022-05-20 15:45:54 +01:00
Andreas Christou
2bd9e9aca5
AzureMonitor: Add support for selecting multiple options when using the equals and not equals dimension filters (#48650)
* Add support for multiselect

- Add filters param to Dimensions
- Update existing tests
- Add MultiSelect component
- Add helper function to determine valid options
- Update labels hook to account for custom values
- Update go type
- Add function to build valid filters string

* Additional go tests

- Ensure query targets are built correctly

* Update DimensionFields frontend test

- Corrently rerender components
- Additional test for multiple labels selection
- Better selection of options in react-select components

* Fix lint issue

* Reset filters when operator or dimension changes

* Terminology

* Update test

* Add backend migration

- Update types (deprecate Filter field)
- Add migration logic
- Update tests
- Update dimension filters buliding

* Add migration test code

* Simplify some logic

* Add frontend deprecation notice

* Add frontend migration logic and migration tests

* Update setting of filter values

* Update DimensionFields test

* Fix linting issues

* PR comment updates

- Remove unnecessary if/else condition
- Don't set filter default value as queries should be migrated
- Add comment explaining why sw operator only accepts one value
- Remove unnecessary test for merging of old and new filters

* Nit on terminology

Co-authored-by: Andres Martinez Gotor <andres.martinez@grafana.com>

* Rename migrations for clarity

Co-authored-by: Andres Martinez Gotor <andres.martinez@grafana.com>
2022-05-10 15:05:48 +01:00
Andreas Christou
d7c16e06d2
AzureMonitor: Add support for not equals and startsWith operators when creating Azure Metrics dimension filters. (#48077)
* 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
2022-04-29 17:01:13 +01:00
Andres Martinez Gotor
6edefe5147
AzureMonitor: Remove deprecated code (#48328) 2022-04-28 10:27:39 +02:00
Kevin Yu
eef22c05e1
AzureMonitor: build azure portal deep link with resource uri (#47947)
* 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
2022-04-26 04:30:28 +02:00
Kevin Yu
9829195829
AzureMonitor: fix the encoding of the metrics query deep link to Azure Portal (#48139) 2022-04-25 05:39:34 -07:00
Kristin Laemmert
8f6877e12a
chore: remove all remaining uses of golang.org/x/net/context (#47564)
* 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
2022-04-11 14:20:10 -04:00
Kevin Yu
ebe5f3646f
AzureMonitor: Use Resource Picker in Metrics Query Editor (#47164)
* 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
2022-04-08 08:49:46 -07:00
Sergey Kostrukov
5675496f6b
Migrate to Grafana Azure SDK (#47232) 2022-04-04 11:23:13 +02: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
Kevin Yu
1a4b1184bd
Azure Monitor: allow metrics call to use resource uri (#46858)
* 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>
2022-03-31 08:20:29 -07:00