Commit Graph

32 Commits

Author SHA1 Message Date
Andrew Hackmann
5e2ee56597
AzureMonitor: Remove subscriptions map (#70620)
remove subscription map
2023-06-23 15:38:46 -05:00
Andrew Hackmann
8d37d8f60b
Azuremonitor schematize backend (#69822)
* metrics schematize

* metrics now use schemas

* logs schema

* remove unused code

* fix tests
2023-06-10 23:30:49 +03:00
ZakharE
5e8bd48c3c
AzureMonitor: Remove simplejson
* tsdb: azuremonitor: Remove usage of simplejson

* Review fixes

* Fix lint errors; review fix
2023-05-23 12:01:49 +01:00
Andreas Christou
bca8428f63
AzureMonitor: Support multi-resource aliases and subscription aliases (#68648)
Update legend aliases

- Add subscription response type
- Update AzureMonitorQuery type
- Update docs
- Update tests
- Add function to retrieve subscription display name if not present
2023-05-22 11:03:43 +01:00
Alyssa Bull
dfc2ac284b
Azure Monitor: Fix bug with top value so more than 10 resources can be shown (#68333) 2023-05-18 10:50:48 -06:00
Andreas Christou
63383ef545
AzureMonitor: Application Insights Traces (#64859)
* Build out barebones Traces editor

- Add Traces query type and operation ID prop to query type
- Add necessary header types
- Update resource picker to appropriately work with traces query type
- Build out TracesQueryEditor component
- Include logic to retrieve operationId's for AI Workspaces
- Add backend route mapping
- Update macro to use timestamp as default time field for traces

* AzureMonitor: Traces - Response parsing (#65442)

* Update FormatAsField component

- Add trace ResultFormat type
- Generalise FormatAsField component
- Add component to TracesQueryEditor
- Remove duplicate code in setQueryValue

* Add custom filter function to improve performance

* Add basic conversion for logs to trace

- Add serviceTags converter
- Pass through required parameters (queryType and resultFormat)
- Appropriately set visualisation

* Update parsing to also fill trace tags

- Add constant values for each table schema (include legacy mapping for now if needed)
- Add constant for list of table tags
- Set the foundation for dynamic query building
- Update query to build tags value
- Appropriately set operationName
- Update tagsConverter to filter empty values

* Fix lint and test issues

* AzureMonitor: Traces - Data links (#65566)

* Add portal link for traces

- Pull out necessary values (itemId and itemType)
- Appropriately construct
- Fix ordering

* Set default format as value

- Also set default visualisation

* Fix event schema

* Set default formatAsField value

* Include logs link on traces results

- Adapt config links to allow custom title to be set

* Correctly set operationId for query

* Update backend types

- Include OperationID in query
- Pass forward datasource name and UID

* Ensure setTime doesn't consistently get called if operationID is defined

* Add explore link

- Update util functions to allow setting custom datalinks

* Fix tests

* AzureMonitor: Traces - Query and Editor updates (#66076)

* Add initial query

- Will query the resource as soon as a resource has been selected
- Updates the data links for the query without operationId
- Remove initial operationId query and timeRange dependency
- Update query building

* Add entirely separate traces query property

- Update shared types (also including future types for Azure traces)
- Update backend log analytics datasource to accept both azureLogAnalytics and azureTraces queries
- Update backend specific types
- Update frontend datasource for new properties
- Update mock query

* Update FormatAsField to be entirely generic

* Update query building to be done in backend

- Add required mappings in backend
- Update frontend querying

* Fix query and explore data link

* Add trace type selection

* Better method for setting explore link

* Fix operationId updating

* Run go mod tidy

* Unnecessary changes

* Fix tests

* AzureMonitor: Traces - Add correlation API support (#65855)

Add correlation API support

- Add necessary types
- Add correlation API request when conditions are met
- Update query

* Fix property from merge

* AzureMonitor: Traces - Filtering (#66303)

* Add initial query

- Will query the resource as soon as a resource has been selected
- Updates the data links for the query without operationId
- Remove initial operationId query and timeRange dependency
- Update query building

* Add entirely separate traces query property

- Update shared types (also including future types for Azure traces)
- Update backend log analytics datasource to accept both azureLogAnalytics and azureTraces queries
- Update backend specific types
- Update frontend datasource for new properties
- Update mock query

* Update FormatAsField to be entirely generic

* Update query building to be done in backend

- Add required mappings in backend
- Update frontend querying

* Fix query and explore data link

* Add trace type selection

* Better method for setting explore link

* Fix operationId updating

* Run go mod tidy

* Unnecessary changes

* Fix tests

* Start building out Filters component

- Configure component to query for Filter property values when a filter property is set
- Add setFilters function
- Add typing to tablesSchema
- Use component in TracesQueryEditor

* Update Filters

- Asynchronously pull property options
- Setup list of Filter components

* Update filters component

- Remove unused imports
- Have local filters state and query filters
- Correctly set filters values
- Don't update query every time a filter property changes (not performant)

* Update properties query

- Use current timeRange
- Get count to provide informative labels

* Reset map when time changes

* Add operation selection

* Reset filters when property changes

* Appropriate label name for empty values

* Add filtering to query

* Update filter components

- Fix rendering issue
- Correctly compare and update timeRange
- Split out files for simplicity

* Add checkbox option to multiselect

- Add custom option component
- Correctly call onChange
- Add variableOptionGroup for template variable selection

* Fix adding template vars

* Improve labels and refresh labels on query prop changes

* AzureMonitor: Traces - Testing (#66474)

* Select ds for template variable interpolation

* Update az logs ds tests

- Add templateVariables test
- Add filter test
- Update mock
- Remove anys

* Update QueryEditor test

- Update mocks with timeSrv for log analytics datasource
- Fix query mock
- Use appropriate and consistent selectors

* Add TracesQueryEditor test

- Update resourcePickerRows mock to include app insights resources
- Remove comments and extra new line

* Add FormatAsField test

- Remove unneeded condition

* Update resourcePicker utils test

* Don't hide selected options in filters

* Fix multi-selection on filters

* Add TraceTypeField test

- Add test file
- Update selectors (remove copy/paste mistake)
- Update placeholder text for select and add label

* Add basic filters test

* Begin filters test

* Update filters test

* Add final tests and simplify/generalise addFilter helper

* Minor update to datasource test

* Update macros test

* Update selectors in tests

* Add response-table-frame tests

* Add datasource tests

- Use sorting where JSON models are inconsistent
- Update filters clause
- Dedupe tags
- Correct operationId conditions

* Don't set a default value for blurInputOnSelect

* Simplify datasource test

* Update to use CheckGoldenJSON utils

- Update with generated frame files
- Remove redundant expected frame code
- Update all usages

* Fix lint

* AzureMonitor: Traces feedback (#67292)

* Filter traces if the visualisation is set to trace

- Update build query logic
- Added additional test cases
- Return an error if the traces type is set by itself with the trace visualisation
- Add descriptions to event types
- Update tests

* Fix bug for error displaying traces

* Update mappings and add error field

- Update tests
- Remove unnecessary comments

* Switch location of Operation ID field

* Re-order fields

* Update link title

* Update label for event type selection

* Update correct link title

* Update logs datalink to link to Azure Logs in explore

* Fix lint
2023-04-27 20:24:11 +01:00
Andreas Christou
a2b97547a6
AzureMonitor: Correct series name accounting for dimensions (#67050)
Correct displayName accounting for dimensions
2023-04-21 19:24:23 +01:00
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
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
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
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
Andres Martinez Gotor
a7d4bbf024
AzureMonitor: Fix bad request when setting dimensions (#59700) 2022-12-02 13:17:11 +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
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
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
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
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
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
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
Andres Martinez Gotor
48113beeeb
AzureMonitor: Fix missing top parameter when dimensions are set (#47010) 2022-03-29 16:27:09 +02:00
Andres Martinez Gotor
700f6863f2
AzureMonitor: Move Application Insights and Insight Analytics to a deprecated package (#45834) 2022-03-02 15:41:07 +01:00